summaryrefslogtreecommitdiff
path: root/drivers/iio/accel
diff options
context:
space:
mode:
authorAlexandru Ardelean <alexandru.ardelean@analog.com>2021-02-15 12:40:23 +0200
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2021-03-11 20:47:01 +0000
commite03ed893e2cf7305183b3314ae80daa1e97667b2 (patch)
treea0729a67386d2476ff5ebc25b135c1871d5bb88a /drivers/iio/accel
parent17395ce299211a8148ee45d1d71eb740a3fec48d (diff)
iio: accel: sca3000: use devm_iio_kfifo_buffer_setup() helper
This change makes use of the devm_iio_kfifo_buffer_setup() helper, however the unwind order is changed. The life-time of the kfifo object is attached to the parent device object. This is to make the driver a bit more consistent with the other IIO drivers, even though (as it is now before this change) it shouldn't be a problem. Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Link: https://lore.kernel.org/r/20210215104043.91251-5-alexandru.ardelean@analog.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio/accel')
-rw-r--r--drivers/iio/accel/sca3000.c19
1 files changed, 3 insertions, 16 deletions
diff --git a/drivers/iio/accel/sca3000.c b/drivers/iio/accel/sca3000.c
index 194738660523..467b5fcb81db 100644
--- a/drivers/iio/accel/sca3000.c
+++ b/drivers/iio/accel/sca3000.c
@@ -1272,20 +1272,6 @@ static int sca3000_write_event_config(struct iio_dev *indio_dev,
return ret;
}
-static int sca3000_configure_ring(struct iio_dev *indio_dev)
-{
- struct iio_buffer *buffer;
-
- buffer = devm_iio_kfifo_allocate(&indio_dev->dev);
- if (!buffer)
- return -ENOMEM;
-
- iio_device_attach_buffer(indio_dev, buffer);
- indio_dev->modes |= INDIO_BUFFER_SOFTWARE;
-
- return 0;
-}
-
static inline
int __sca3000_hw_ring_state_set(struct iio_dev *indio_dev, bool state)
{
@@ -1479,7 +1465,9 @@ static int sca3000_probe(struct spi_device *spi)
}
indio_dev->modes = INDIO_DIRECT_MODE;
- ret = sca3000_configure_ring(indio_dev);
+ ret = devm_iio_kfifo_buffer_setup(&spi->dev, indio_dev,
+ INDIO_BUFFER_SOFTWARE,
+ &sca3000_ring_setup_ops);
if (ret)
return ret;
@@ -1493,7 +1481,6 @@ static int sca3000_probe(struct spi_device *spi)
if (ret)
return ret;
}
- indio_dev->setup_ops = &sca3000_ring_setup_ops;
ret = sca3000_clean_setup(st);
if (ret)
goto error_free_irq;