summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAxel Haslam <ahaslam@baylibre.com>2024-10-31 10:17:46 +0300
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2024-11-03 23:33:42 +0300
commit7f36074c0f8f21f25d2c40cceb1524048f617e76 (patch)
treeb9eeef20c607e88c449ca91aa2b645a7dc7c2d9a
parent7bf7b297b6832387b0dcf1840d9ebe913b2ff841 (diff)
downloadlinux-7f36074c0f8f21f25d2c40cceb1524048f617e76.tar.xz
iio: dac: ad5791: Use devm_iio_device_register
Use devm_iio_device_register to automatically free the iio device. since this is the last remaining resource that was not automatically freed, we can drop the ".remove" callback. Suggested-by: David Lechner <dlechner@baylibre.com> Reviewed-by: David Lechner <dlechner@baylibre.com> Signed-off-by: Axel Haslam <ahaslam@baylibre.com> Link: https://patch.msgid.link/20241031071746.848694-7-ahaslam@baylibre.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
-rw-r--r--drivers/iio/dac/ad5791.c15
1 files changed, 1 insertions, 14 deletions
diff --git a/drivers/iio/dac/ad5791.c b/drivers/iio/dac/ad5791.c
index 92d47e766fd3..57374f78f6b8 100644
--- a/drivers/iio/dac/ad5791.c
+++ b/drivers/iio/dac/ad5791.c
@@ -411,24 +411,12 @@ static int ad5791_probe(struct spi_device *spi)
if (ret)
return dev_err_probe(&spi->dev, ret, "fail to write ctrl register\n");
- spi_set_drvdata(spi, indio_dev);
indio_dev->info = &ad5791_info;
indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->channels = &st->chip_info->channel;
indio_dev->num_channels = 1;
indio_dev->name = st->chip_info->name;
- ret = iio_device_register(indio_dev);
- if (ret)
- return dev_err_probe(&spi->dev, ret, "unable to register iio device\n");
-
- return 0;
-}
-
-static void ad5791_remove(struct spi_device *spi)
-{
- struct iio_dev *indio_dev = spi_get_drvdata(spi);
-
- iio_device_unregister(indio_dev);
+ return devm_iio_device_register(&spi->dev, indio_dev);
}
static const struct of_device_id ad5791_of_match[] = {
@@ -457,7 +445,6 @@ static struct spi_driver ad5791_driver = {
.of_match_table = ad5791_of_match,
},
.probe = ad5791_probe,
- .remove = ad5791_remove,
.id_table = ad5791_id,
};
module_spi_driver(ad5791_driver);