Message ID | 20241028071118.699951-7-ahaslam@baylibre.com (mailing list archive) |
---|---|
State | Changes Requested |
Headers | show |
Series | Improvements and Enhancements for AD5791 DAC Driver | expand |
On Mon, 28 Oct 2024 08:11:18 +0100 ahaslam@baylibre.com wrote: > From: Axel Haslam <ahaslam@baylibre.com> > > 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> > Signed-off-by: Axel Haslam <ahaslam@baylibre.com> Hi Axel, The bot did a much better review job than me this time. Other than the obvious solutions to the things it pointed out, this series looks fine to me. Jonathan > --- > drivers/iio/dac/ad5791.c | 15 +-------------- > 1 file changed, 1 insertion(+), 14 deletions(-) > > diff --git a/drivers/iio/dac/ad5791.c b/drivers/iio/dac/ad5791.c > index cf3d41a10c20..21332c9aca5d 100644 > --- a/drivers/iio/dac/ad5791.c > +++ b/drivers/iio/dac/ad5791.c > @@ -405,24 +405,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[] = { > @@ -451,7 +439,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);
diff --git a/drivers/iio/dac/ad5791.c b/drivers/iio/dac/ad5791.c index cf3d41a10c20..21332c9aca5d 100644 --- a/drivers/iio/dac/ad5791.c +++ b/drivers/iio/dac/ad5791.c @@ -405,24 +405,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[] = { @@ -451,7 +439,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);