iio: maxim_thermocouple: Use device-managed APIs
PATCH 1/1 iio: maxim_thermocouple: Use device-managed APIs
Use device-managed APIs to simplify the code.
The remove functions are redundant now and can
be deleted.
Signed-off-by Chuhong Yuan <[email protected]>
--- drivers/iio/temperature/maxim_thermocouple.c | 23 ++++---------------- 1 file changed, 4 insertions(+), 19 deletions(-)
drivers/iio/temperature/maxim_thermocouple.c +4 -19
@@ -230,29 +230,15 @@ static int maxim_thermocouple_probe(struct spi_device *spi) data->spi = spi; data->chip = chip; - ret =iio_triggered_buffer_setup (indio_dev,NULL , + ret =devm_iio_triggered_buffer_setup (&spi->dev, + indio_dev,NULL , maxim_thermocouple_trigger_handler,NULL );if (ret)return ret; - ret =iio_device_register (indio_dev); + ret =devm_iio_device_register (&spi->dev, indio_dev);if (ret) - goto error_unreg_buffer; - -return 0 ; - -error_unreg_buffer: -iio_triggered_buffer_cleanup (indio_dev); - -return ret; -} - -static int maxim_thermocouple_remove (struct spi_device *spi) -{ -struct iio_dev *indio_dev =spi_get_drvdata (spi); - -iio_device_unregister (indio_dev); -iio_triggered_buffer_cleanup (indio_dev); +return ret;return 0 ; }
@@ -277,7 +263,6 @@ static struct spi_driver maxim_thermocouple_driver = { .of_match_table = maxim_thermocouple_of_match, }, .probe = maxim_thermocouple_probe, - .remove = maxim_thermocouple_remove, .id_table = maxim_thermocouple_id, };module_spi_driver (maxim_thermocouple_driver);
Signature · 1 line
2.20.1
Jonathan Cameron
maintainerQuoted 5 lines · On Fri, 26 Jul 2019 18:49:50 +0800 Chuhong Yuan <[email protected]> wrote:
Use device-managed APIs to simplify the code.
The remove functions are redundant now and can
be deleted.Signed-off-by Chuhong Yuan <[email protected]>
+CC Matt as I think this is one of his.
I modified slightly and applied to the togreg branch of iio.git.
See inline for the change.
Thanks,
Jonathan
Quoted 29 lines
--- drivers/iio/temperature/maxim_thermocouple.c | 23 ++++---------------- 1 file changed, 4 insertions(+), 19 deletions(-)drivers/iio/temperature/maxim_thermocouple.c +3
-9@@ -230,29 +230,15 @@ static int maxim_thermocouple_probe(struct spi_device *spi) data->spi = spi; data->chip = chip; - ret =iio_triggered_buffer_setup (indio_dev,NULL , + ret =devm_iio_triggered_buffer_setup (&spi->dev, + indio_dev,NULL , maxim_thermocouple_trigger_handler,NULL );if (ret)return ret; - ret =iio_device_register (indio_dev); + ret =devm_iio_device_register (&spi->dev, indio_dev);if (ret) - goto error_unreg_buffer; - -return 0 ; - -error_unreg_buffer: -iio_triggered_buffer_cleanup (indio_dev); -
drivers/iio/temperature/maxim_thermocouple.c static int maxim_thermocouple_probe(struct spi_device *spi) · line 241
Quoted 10 lines
drivers/iio/temperature/maxim_thermocouple.c +1
-9-return ret; -} - -static int maxim_thermocouple_remove (struct spi_device *spi) -{ -struct iio_dev *indio_dev =spi_get_drvdata (spi); - -iio_device_unregister (indio_dev); -iio_triggered_buffer_cleanup (indio_dev); +return ret;
Slight tweak. I'll do it whilst applying.
can just
return devm_iio_device_register(...) as same effect.
Quoted 11 lines
drivers/iio/temperature/maxim_thermocouple.c +0
-1return 0 ; }@@ -277,7 +263,6 @@ static struct spi_driver maxim_thermocouple_driver = { .of_match_table = maxim_thermocouple_of_match, }, .probe = maxim_thermocouple_probe, - .remove = maxim_thermocouple_remove, .id_table = maxim_thermocouple_id, };module_spi_driver (maxim_thermocouple_driver);