[PATCH v2 next 4/5] iio: sca3000: manage device registration with devm helper

Harshit Mogalapalli posted 5 patches 6 days, 20 hours ago
There is a newer version of this series
[PATCH v2 next 4/5] iio: sca3000: manage device registration with devm helper
Posted by Harshit Mogalapalli 6 days, 20 hours ago
Convert the iio registration to use devm_* helpers so the probe no
longer needs a separate cleanup path and remove callback can also drop
the unregister. After this there is no need for having a remove
callback, so remote it.

No functional change intended.

Suggested-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
---
v1-> v2: This was a patch 3 in v1 but moved it to patch4 to preserve the
teardown sequence (unregister the iio device first, we can disable
interrupts later) -- Thanks to Jonathan for the guidance on V1.
---
 drivers/iio/accel/sca3000.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/drivers/iio/accel/sca3000.c b/drivers/iio/accel/sca3000.c
index 4faffeea328c..989074de18b4 100644
--- a/drivers/iio/accel/sca3000.c
+++ b/drivers/iio/accel/sca3000.c
@@ -1520,18 +1520,7 @@ static int sca3000_probe(struct spi_device *spi)
 	if (ret)
 		return ret;
 
-	ret = iio_device_register(indio_dev);
-	if (ret)
-		return ret;
-
-	return 0;
-}
-
-static void sca3000_remove(struct spi_device *spi)
-{
-	struct iio_dev *indio_dev = spi_get_drvdata(spi);
-
-	iio_device_unregister(indio_dev);
+	return devm_iio_device_register(dev, indio_dev);
 }
 
 static const struct spi_device_id sca3000_id[] = {
@@ -1548,7 +1537,6 @@ static struct spi_driver sca3000_driver = {
 		.name = "sca3000",
 	},
 	.probe = sca3000_probe,
-	.remove = sca3000_remove,
 	.id_table = sca3000_id,
 };
 module_spi_driver(sca3000_driver);
-- 
2.47.3
Re: [PATCH v2 next 4/5] iio: sca3000: manage device registration with devm helper
Posted by David Lechner 6 days, 17 hours ago
On 2/2/26 1:40 PM, Harshit Mogalapalli wrote:
> Convert the iio registration to use devm_* helpers so the probe no
> longer needs a separate cleanup path and remove callback can also drop
> the unregister. After this there is no need for having a remove
> callback, so remote it.
> 
> No functional change intended.
> 
> Suggested-by: Andy Shevchenko <andriy.shevchenko@intel.com>
> Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
> ---
Reviewed-by: David Lechner <dlechner@baylibe.com>
Re: [PATCH v2 next 4/5] iio: sca3000: manage device registration with devm helper
Posted by Harshit Mogalapalli 6 days, 3 hours ago
Hi David,

On 03/02/26 04:37, David Lechner wrote:
> On 2/2/26 1:40 PM, Harshit Mogalapalli wrote:
>> Convert the iio registration to use devm_* helpers so the probe no
>> longer needs a separate cleanup path and remove callback can also drop
>> the unregister. After this there is no need for having a remove
>> callback, so remote it.
>>
>> No functional change intended.
>>
>> Suggested-by: Andy Shevchenko <andriy.shevchenko@intel.com>
>> Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
>> ---
> Reviewed-by: David Lechner <dlechner@baylibe.com>

While sending v3 with this RB tag added, I found that there is a missing 
r in baylibre in this and another patch.

I will wait for the comments on v3 first before fixing this.

Thanks,
Harshit