Re: [PATCH v2 5/5] iio: adc: bcm_iproc_adc: use devm_iio_device_register()
From: Marcelo Schmitt
Date: Mon Aug 31 2026 - 22:22:07 EST
Hello Mohammad,
This patch looks overall good.
Two minor things inline.
On 08/30, mdshahid03@xxxxxxxxx wrote:
> From: Mohammad Shahid <mdshahid03@xxxxxxxxx>
>
> Use `devm_iio_device_register()` to automatically unregister the IIO
> device when the device is detached.
>
> This removes the manual `iio_device_unregister()` call and makes the
> `iproc_adc_remove()` callback unnecessary.
>
> Signed-off-by: Mohammad Shahid <mdshahid03@xxxxxxxxx>
> ---
> drivers/iio/adc/bcm_iproc_adc.c | 10 +---------
> 1 file changed, 1 insertion(+), 9 deletions(-)
>
> diff --git a/drivers/iio/adc/bcm_iproc_adc.c b/drivers/iio/adc/bcm_iproc_adc.c
> index 11f2bc12c19a..38a153d6fc70 100644
> --- a/drivers/iio/adc/bcm_iproc_adc.c
> +++ b/drivers/iio/adc/bcm_iproc_adc.c
> @@ -570,7 +570,7 @@ static int iproc_adc_probe(struct platform_device *pdev)
> indio_dev->channels = iproc_adc_iio_channels;
> indio_dev->num_channels = ARRAY_SIZE(iproc_adc_iio_channels);
>
> - ret = iio_device_register(indio_dev);
> + ret = devm_iio_device_register(dev, indio_dev);
> if (ret)
> return dev_err_probe(dev, ret, "iio_device_register failed\n");
Optional change, the last return check can be skipped.
return devm_iio_device_register(dev, indio_dev);
>
> @@ -578,13 +578,6 @@ static int iproc_adc_probe(struct platform_device *pdev)
>
> }
>
> -static void iproc_adc_remove(struct platform_device *pdev)
> -{
> - struct iio_dev *indio_dev = platform_get_drvdata(pdev);
> -
> - iio_device_unregister(indio_dev);
> -}
> -
Now that we won't call platform_get_drvdata() anymore, another thing that can
be removed is platform_set_drvdata(pdev, indio_dev);
With that dropped,
Reviewed-by: Marcelo Schmitt <marcelo.schmitt1@xxxxxxxxx>