diff options
author | Andrey Smirnov <andrew.smirnov@gmail.com> | 2019-08-11 08:45:45 +0300 |
---|---|---|
committer | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2019-08-11 11:59:38 +0300 |
commit | ef19ee60f9cf713518c1d5e15946466d51e9f00b (patch) | |
tree | 5a416d9730c1d8cda7caf95b4acf6664ae5031d4 /drivers | |
parent | 6822dc9daa26102161e58a96b2ca938d14696006 (diff) | |
download | linux-ef19ee60f9cf713518c1d5e15946466d51e9f00b.tar.xz |
iio: hi8435: Drop hi8435_remove() by using devres for remaining elements
Convert the remainder of hi8435_probe() to use devres and get rid of
hi8435_remove().
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Cc: linux-kernel@vger.kernel.org
Cc: linux-iio@vger.kernel.org
Cc: Chris Healy <cphealy@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/iio/adc/hi8435.c | 32 |
1 files changed, 11 insertions, 21 deletions
diff --git a/drivers/iio/adc/hi8435.c b/drivers/iio/adc/hi8435.c index c15f0e154e4d..8da45bf36d36 100644 --- a/drivers/iio/adc/hi8435.c +++ b/drivers/iio/adc/hi8435.c @@ -456,6 +456,11 @@ err_read: return IRQ_HANDLED; } +static void hi8435_triggered_event_cleanup(void *data) +{ + iio_triggered_event_cleanup(data); +} + static int hi8435_probe(struct spi_device *spi) { struct iio_dev *idev; @@ -513,27 +518,13 @@ static int hi8435_probe(struct spi_device *spi) if (ret) return ret; - ret = iio_device_register(idev); - if (ret < 0) { - dev_err(&spi->dev, "unable to register device\n"); - goto unregister_triggered_event; - } - - return 0; - -unregister_triggered_event: - iio_triggered_event_cleanup(idev); - return ret; -} - -static int hi8435_remove(struct spi_device *spi) -{ - struct iio_dev *idev = spi_get_drvdata(spi); - - iio_device_unregister(idev); - iio_triggered_event_cleanup(idev); + ret = devm_add_action_or_reset(&spi->dev, + hi8435_triggered_event_cleanup, + idev); + if (ret) + return ret; - return 0; + return devm_iio_device_register(&spi->dev, idev); } static const struct of_device_id hi8435_dt_ids[] = { @@ -554,7 +545,6 @@ static struct spi_driver hi8435_driver = { .of_match_table = of_match_ptr(hi8435_dt_ids), }, .probe = hi8435_probe, - .remove = hi8435_remove, .id_table = hi8435_id, }; module_spi_driver(hi8435_driver); |