Skip to contentSkip to conversation

iio: gyro: adis16080: use devm_iio_device_register() in probe

PATCH In review Alexandru Ardelean 2 participants 2 messages Sep 13, 2021 – Sep 18, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: gyro: adis16080: use devm_iio_device_register() in probe

There is nothing else that needs to be done for this driver. The remove hook calls only the iio_device_unregister() hook.

So this driver can use devm_iio_device_register() directly.

---
 drivers/iio/gyro/adis16080.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)
drivers/iio/gyro/adis16080.c +1 -10
index e2f4d943e220..acef59d822b1 100644
@@ -195,8 +195,6 @@ static int adis16080_probe(struct spi_device *spi)
 	if (!indio_dev)
 		return -ENOMEM;
 	st = iio_priv(indio_dev);
-	/* this is only used for removal purposes */
-	spi_set_drvdata(spi, indio_dev);
 
 	mutex_init(&st->lock);
 
@@ -210,13 +208,7 @@ static int adis16080_probe(struct spi_device *spi)
 	indio_dev->info = &adis16080_info;
 	indio_dev->modes = INDIO_DIRECT_MODE;
 
-	return iio_device_register(indio_dev);
-}
-
-static int adis16080_remove(struct spi_device *spi)
-{
-	iio_device_unregister(spi_get_drvdata(spi));
-	return 0;
+	return devm_iio_device_register(&spi->dev, indio_dev);
 }
 
 static const struct spi_device_id adis16080_ids[] = {
@@ -231,7 +223,6 @@ static struct spi_driver adis16080_driver = {
 		.name = "adis16080",
 	},
 	.probe = adis16080_probe,
-	.remove = adis16080_remove,
 	.id_table = adis16080_ids,
 };
 module_spi_driver(adis16080_driver);
Signature · 1 line
2.31.1
maintainer
#1 lore raw
Quoted 6 lines · On Mon, 13 Sep 2021 14:53:08 +0300 Alexandru Ardelean <[email protected]>…

There is nothing else that needs to be done for this driver. The remove hook calls only the iio_device_unregister() hook.

So this driver can use devm_iio_device_register() directly.

huh? How did we end up with this one being so nearly done. I guess maybe it predates devm_iio_device_register()!

Applied to the togreg branch of iio.git and pushed out as testing for 0-day to waste time testing it for us ;)

Thanks,

Jonathan

Quoted 40 lines
---
 drivers/iio/gyro/adis16080.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)
drivers/iio/gyro/adis16080.c +1 -10
index e2f4d943e220..acef59d822b1 100644
@@ -195,8 +195,6 @@ static int adis16080_probe(struct spi_device *spi)
 	if (!indio_dev)
 		return -ENOMEM;
 	st = iio_priv(indio_dev);
-	/* this is only used for removal purposes */
-	spi_set_drvdata(spi, indio_dev);
 
 	mutex_init(&st->lock);
 
@@ -210,13 +208,7 @@ static int adis16080_probe(struct spi_device *spi)
 	indio_dev->info = &adis16080_info;
 	indio_dev->modes = INDIO_DIRECT_MODE;
 
-	return iio_device_register(indio_dev);
-}
-
-static int adis16080_remove(struct spi_device *spi)
-{
-	iio_device_unregister(spi_get_drvdata(spi));
-	return 0;
+	return devm_iio_device_register(&spi->dev, indio_dev);
 }
 
 static const struct spi_device_id adis16080_ids[] = {
@@ -231,7 +223,6 @@ static struct spi_driver adis16080_driver = {
 		.name = "adis16080",
 	},
 	.probe = adis16080_probe,
-	.remove = adis16080_remove,
 	.id_table = adis16080_ids,
 };
 module_spi_driver(adis16080_driver);