staging: iio: adis16203: Use devm_iio_device_register
Subsystems (4)
PATCH 1/1 staging: iio: adis16203: Use devm_iio_device_register
This patch introduces the use of iio_device_register and does away with the call to the corressponding unregister function in the probe and remove functions of the driver respectively.
--- drivers/staging/iio/accel/adis16203_core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/iio/accel/adis16203_core.c +1 -2
@@ -175,7 +175,7 @@ static int adis16203_probe(struct spi_device *spi)if (ret) goto error_cleanup_buffer_trigger; - ret =iio_device_register (indio_dev); + ret =devm_iio_device_register (&spi->dev, indio_dev);if (ret) goto error_cleanup_buffer_trigger;
@@ -191,7 +191,6 @@ static int adis16203_remove(struct spi_device *spi)struct iio_dev *indio_dev =spi_get_drvdata (spi);struct adis *st =iio_priv (indio_dev); -iio_device_unregister (indio_dev);adis_cleanup_buffer_and_trigger (st, indio_dev);return 0 ;
Signature · 1 line
1.9.1
Quoted 6 lines · Himangi Saraogi
This patch introduces the use of
iio_device_registerand does away with the call to the corressponding unregister function in the probe and remove functions of the driver respectively.Signed-off-by Himangi Saraogi <[email protected]>Acked-by Julia Lawall <[email protected]>
No, you changed the relative order in which iio_device_unregister() and adis_cleanup_buffer_and_trigger() are called, this opens up the way for race conditions. Rule of thumb: Don't convert drivers to managed functions if this will change the order in which functions will called on device removal.
- Lars
Quoted 26 lines
--- drivers/staging/iio/accel/adis16203_core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/staging/iio/accel/adis16203_core.c +1
-2@@ -175,7 +175,7 @@ static int adis16203_probe(struct spi_device *spi)if (ret) goto error_cleanup_buffer_trigger; - ret =iio_device_register (indio_dev); + ret =devm_iio_device_register (&spi->dev, indio_dev);if (ret) goto error_cleanup_buffer_trigger;@@ -191,7 +191,6 @@ static int adis16203_remove(struct spi_device *spi)struct iio_dev *indio_dev =spi_get_drvdata (spi);struct adis *st =iio_priv (indio_dev); -iio_device_unregister (indio_dev);adis_cleanup_buffer_and_trigger (st, indio_dev);return 0 ;
Quoted 5 lines · Lars-Peter Clausen
Quoted 4 lines · Himangi Saraogi
This patch introduces the use of
iio_device_registerand does away with the call to the corressponding unregister function in the probe and remove functions of the driver respectively.
Quoted 7 lines
Quoted 2 lines
Signed-off-by Himangi Saraogi <[email protected]>Acked-by Julia Lawall <[email protected]>No, you changed the relative order in which
iio_device_unregister()andadis_cleanup_buffer_and_trigger()are called, this opens up the way for race conditions. Rule of thumb: Don't convert drivers to managed functions if this will change the order in which functions will called on device removal.
Thanks for the information. I was indeed not sure about this.
Unfortunately, removal code is not always perfectly written, and the operations are not always done in the right order...
julia
Quoted 31 lines
- Lars
Quoted 27 lines
--- drivers/staging/iio/accel/adis16203_core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/staging/iio/accel/adis16203_core.c +1
-2@@ -175,7 +175,7 @@ static int adis16203_probe(struct spi_device *spi)if (ret) goto error_cleanup_buffer_trigger; - ret =iio_device_register (indio_dev); + ret =devm_iio_device_register (&spi->dev, indio_dev);if (ret) goto error_cleanup_buffer_trigger;@@ -191,7 +191,6 @@ static int adis16203_remove(struct spi_device *spi)struct iio_dev *indio_dev =spi_get_drvdata (spi);struct adis *st =iio_priv (indio_dev); -iio_device_unregister (indio_dev);adis_cleanup_buffer_and_trigger (st, indio_dev);return 0 ;