linux/drivers/iio/frequency
Jinjie Ruan 9979cc6485 iio: frequency: adf4350: Use device managed functions and fix power down issue.
The devm_clk_get_enabled() helper:
    - calls devm_clk_get()
    - calls clk_prepare_enable() and registers what is needed in order to
      call clk_disable_unprepare() when needed, as a managed resource.

Also replace devm_regulator_get() and regulator_enable() with
devm_regulator_get_enable() helper and remove regulator_disable().

Replace iio_device_register() with devm_iio_device_register() and remove
iio_device_unregister().

And st->reg is not used anymore, so remove it.

As Jonathan pointed out, couple of things that are wrong:

1) The device is powered down 'before' we unregister it with the
   subsystem and as such userspace interfaces are still exposed which
   probably won't do the right thing if the chip is powered down.

2) This isn't done in the error paths in probe.

To solve this problem, register a new callback adf4350_power_down()
with devm_add_action_or_reset(), to enable software power down in both
error and device detach path. So the remove function can be removed.

Remove spi_set_drvdata() from the probe function, since spi_get_drvdata()
is not used anymore.

Fixes: e31166f0fd ("iio: frequency: New driver for Analog Devices ADF4350/ADF4351 Wideband Synthesizers")
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Link: https://lore.kernel.org/r/20230828062717.2310219-1-ruanjinjie@huawei.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-09-11 20:12:40 +01:00
..
ad9523.c iio: frequency: ad9523: Use devm_regulator_get_enable() 2022-11-23 19:44:01 +00:00
adf4350.c iio: frequency: adf4350: Use device managed functions and fix power down issue. 2023-09-11 20:12:40 +01:00
adf4371.c iio: frequency: adf4371: Benefit from devm_clk_get_enabled() to simplify 2022-08-15 22:30:02 +01:00
adf4377.c iio: frequency: adf4377: add support for ADF4377 2022-11-23 21:05:51 +00:00
admv1013.c Merge 6.5-rc6 into char-misc-next 2023-08-13 22:14:51 +02:00
admv1014.c iio: frequency: admv1014: return -EINVAL directly 2022-08-19 18:07:22 +01:00
admv4420.c iio: frequency: admv4420: Fix alignment for DMA safety 2022-06-14 11:53:18 +01:00
adrf6780.c iio: frequency: adrf6780: Benefit from devm_clk_get_enabled() to simplify 2022-08-15 22:30:02 +01:00
Kconfig iio: frequency: adf4377: add support for ADF4377 2022-11-23 21:05:51 +00:00
Makefile iio: frequency: adf4377: add support for ADF4377 2022-11-23 21:05:51 +00:00