iio: accel: bmc150: use iio_triggered_buffer_setup_ext()
authorAlexandru Ardelean <alexandru.ardelean@analog.com>
Tue, 29 Sep 2020 12:59:45 +0000 (15:59 +0300)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 21 Nov 2020 14:53:20 +0000 (14:53 +0000)
This change switches to the new iio_triggered_buffer_setup_ext()
function and removes the iio_buffer_set_attrs() call, for assigning the
HW FIFO attributes to the buffer.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20200929125949.69934-6-alexandru.ardelean@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/accel/bmc150-accel-core.c

index 48435865fdaf34387b563b9ce025e00fddedcc0b..c641ee55203862177bfd9eca11fb1e0d9a8cb8f5 100644 (file)
@@ -1558,6 +1558,7 @@ static int bmc150_accel_chip_init(struct bmc150_accel_data *data)
 int bmc150_accel_core_probe(struct device *dev, struct regmap *regmap, int irq,
                            const char *name, bool block_supported)
 {
+       const struct attribute **fifo_attrs;
        struct bmc150_accel_data *data;
        struct iio_dev *indio_dev;
        int ret;
@@ -1590,10 +1591,19 @@ int bmc150_accel_core_probe(struct device *dev, struct regmap *regmap, int irq,
        indio_dev->modes = INDIO_DIRECT_MODE;
        indio_dev->info = &bmc150_accel_info;
 
-       ret = iio_triggered_buffer_setup(indio_dev,
-                                        &iio_pollfunc_store_time,
-                                        bmc150_accel_trigger_handler,
-                                        &bmc150_accel_buffer_ops);
+       if (block_supported) {
+               indio_dev->modes |= INDIO_BUFFER_SOFTWARE;
+               indio_dev->info = &bmc150_accel_info_fifo;
+               fifo_attrs = bmc150_accel_fifo_attributes;
+       } else {
+               fifo_attrs = NULL;
+       }
+
+       ret = iio_triggered_buffer_setup_ext(indio_dev,
+                                            &iio_pollfunc_store_time,
+                                            bmc150_accel_trigger_handler,
+                                            &bmc150_accel_buffer_ops,
+                                            fifo_attrs);
        if (ret < 0) {
                dev_err(dev, "Failed: iio triggered buffer setup\n");
                return ret;
@@ -1628,13 +1638,6 @@ int bmc150_accel_core_probe(struct device *dev, struct regmap *regmap, int irq,
                ret = bmc150_accel_triggers_setup(indio_dev, data);
                if (ret)
                        goto err_buffer_cleanup;
-
-               if (block_supported) {
-                       indio_dev->modes |= INDIO_BUFFER_SOFTWARE;
-                       indio_dev->info = &bmc150_accel_info_fifo;
-                       iio_buffer_set_attrs(indio_dev->buffer,
-                                            bmc150_accel_fifo_attributes);
-               }
        }
 
        ret = pm_runtime_set_active(dev);