iio: core: Simplify the registration of kfifo buffers
authorMiquel Raynal <miquel.raynal@bootlin.com>
Mon, 7 Feb 2022 14:38:39 +0000 (15:38 +0100)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sun, 10 Apr 2022 15:25:46 +0000 (16:25 +0100)
Among all the users of the kfifo buffers, no one uses the
INDIO_BUFFER_HARDWARE mode. So let's take this as a general rule and
simplify a little bit the internals - overall the documentation - by
eliminating unused specific cases. Use the INDIO_BUFFER_SOFTWARE mode by
default with kfifo buffers, which will basically mimic what all the "non
direct" modes do.

Cc: Benson Leung <bleung@chromium.org>
Cc: Guenter Roeck <groeck@chromium.org>
Cc: Jyoti Bhayana <jbhayana@google.com>
Cc: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Cc: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
Cc: Michael Hennerich <Michael.Hennerich@analog.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/r/20220207143840.707510-13-miquel.raynal@bootlin.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
18 files changed:
drivers/iio/accel/adxl367.c
drivers/iio/accel/fxls8962af-core.c
drivers/iio/accel/sca3000.c
drivers/iio/accel/ssp_accel_sensor.c
drivers/iio/adc/ina2xx-adc.c
drivers/iio/adc/ti_am335x_adc.c
drivers/iio/buffer/kfifo_buf.c
drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
drivers/iio/common/scmi_sensors/scmi_iio.c
drivers/iio/gyro/ssp_gyro_sensor.c
drivers/iio/health/max30100.c
drivers/iio/health/max30102.c
drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c
drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
drivers/iio/light/apds9960.c
drivers/staging/iio/impedance-analyzer/ad5933.c
include/linux/iio/kfifo_buf.h

index 62960134ea195532c42dc765ab64fa5165b7f6f4..0289ed8cf2c6a72f1e415ef40eeb0493f4cdeb8d 100644 (file)
@@ -1567,7 +1567,6 @@ int adxl367_probe(struct device *dev, const struct adxl367_ops *ops,
                return ret;
 
        ret = devm_iio_kfifo_buffer_setup_ext(st->dev, indio_dev,
-                                             INDIO_BUFFER_SOFTWARE,
                                              &adxl367_buffer_ops,
                                              adxl367_fifo_attributes);
        if (ret)
index a9d2f10d5d4581735d198ca93ca592a93f6a456b..8874d6d617253c04233abf0c4429e102849f6c4f 100644 (file)
@@ -1217,7 +1217,6 @@ int fxls8962af_core_probe(struct device *dev, struct regmap *regmap, int irq)
                        return ret;
 
                ret = devm_iio_kfifo_buffer_setup(dev, indio_dev,
-                                                 INDIO_BUFFER_SOFTWARE,
                                                  &fxls8962af_buffer_ops);
                if (ret)
                        return ret;
index 83c81072511ee2c30e7d1893c4b354a86913bec0..29a68a7d34cdaca0b5c13f102bca2221616a49c1 100644 (file)
@@ -1474,7 +1474,6 @@ static int sca3000_probe(struct spi_device *spi)
        indio_dev->modes = INDIO_DIRECT_MODE;
 
        ret = devm_iio_kfifo_buffer_setup(&spi->dev, indio_dev,
-                                         INDIO_BUFFER_SOFTWARE,
                                          &sca3000_ring_setup_ops);
        if (ret)
                return ret;
index a1164b439f412e645a61b29f6a20e0b6f524f2e9..7ca9d0d543e04c3fddd178e8e8afd5222b99d23d 100644 (file)
@@ -113,7 +113,6 @@ static int ssp_accel_probe(struct platform_device *pdev)
        indio_dev->available_scan_masks = ssp_accel_scan_mask;
 
        ret = devm_iio_kfifo_buffer_setup(&pdev->dev, indio_dev,
-                                         INDIO_BUFFER_SOFTWARE,
                                          &ssp_accel_buffer_ops);
        if (ret)
                return ret;
index 8d902a32a0fdb0546727b61068db0657c5b0ad16..08a2c547f0b3c007af98022608537fcc3b7d06dc 100644 (file)
@@ -1027,7 +1027,6 @@ static int ina2xx_probe(struct i2c_client *client,
        indio_dev->name = id->name;
 
        ret = devm_iio_kfifo_buffer_setup(&client->dev, indio_dev,
-                                         INDIO_BUFFER_SOFTWARE,
                                          &ina2xx_setup_ops);
        if (ret)
                return ret;
index dbdc1ef485668c8e739d2ffcb6cc253af321c753..567d43a3095504eb029f6992db6dc91394807e5d 100644 (file)
@@ -376,9 +376,7 @@ static int tiadc_iio_buffered_hardware_setup(struct device *dev,
 {
        int ret;
 
-       ret = devm_iio_kfifo_buffer_setup(dev, indio_dev,
-                                         INDIO_BUFFER_SOFTWARE,
-                                         setup_ops);
+       ret = devm_iio_kfifo_buffer_setup(dev, indio_dev, setup_ops);
        if (ret)
                return ret;
 
index 416d35a61ae2d44c6dd7a1875a80a2548dfb729a..35d8b4077376c040bb605df9ddd06e837f8dfe91 100644 (file)
@@ -259,8 +259,6 @@ static struct iio_buffer *devm_iio_kfifo_allocate(struct device *dev)
  * devm_iio_kfifo_buffer_setup_ext - Allocate a kfifo buffer & attach it to an IIO device
  * @dev: Device object to which to attach the life-time of this kfifo buffer
  * @indio_dev: The device the buffer should be attached to
- * @mode_flags: The mode flags for this buffer (INDIO_BUFFER_SOFTWARE and/or
- *             INDIO_BUFFER_TRIGGERED).
  * @setup_ops: The setup_ops required to configure the HW part of the buffer (optional)
  * @buffer_attrs: Extra sysfs buffer attributes for this IIO buffer
  *
@@ -271,22 +269,16 @@ static struct iio_buffer *devm_iio_kfifo_allocate(struct device *dev)
  */
 int devm_iio_kfifo_buffer_setup_ext(struct device *dev,
                                    struct iio_dev *indio_dev,
-                                   int mode_flags,
                                    const struct iio_buffer_setup_ops *setup_ops,
                                    const struct attribute **buffer_attrs)
 {
        struct iio_buffer *buffer;
 
-       if (!mode_flags)
-               return -EINVAL;
-
        buffer = devm_iio_kfifo_allocate(dev);
        if (!buffer)
                return -ENOMEM;
 
-       mode_flags &= kfifo_access_funcs.modes;
-
-       indio_dev->modes |= mode_flags;
+       indio_dev->modes |= INDIO_BUFFER_SOFTWARE;
        indio_dev->setup_ops = setup_ops;
 
        buffer->attrs = buffer_attrs;
index b2725c6adc7f1fbb40a9ab6fc953653a63661497..a4cf1d9a8a4929a5c32b9ce3bd54d5bebeaa88b9 100644 (file)
@@ -333,8 +333,7 @@ int cros_ec_sensors_core_init(struct platform_device *pdev,
                         * We can not use trigger here, as events are generated
                         * as soon as sample_frequency is set.
                         */
-                       ret = devm_iio_kfifo_buffer_setup_ext(dev, indio_dev,
-                                                             INDIO_BUFFER_SOFTWARE, NULL,
+                       ret = devm_iio_kfifo_buffer_setup_ext(dev, indio_dev, NULL,
                                                              cros_ec_sensor_fifo_attributes);
                        if (ret)
                                return ret;
index d538bf3ab1ef97f2e56ca5e129041bd57c268325..793d628db55fbbc748c691f7169120d2437a11e1 100644 (file)
@@ -686,7 +686,6 @@ static int scmi_iio_dev_probe(struct scmi_device *sdev)
 
                err = devm_iio_kfifo_buffer_setup(&scmi_iio_dev->dev,
                                                  scmi_iio_dev,
-                                                 INDIO_BUFFER_SOFTWARE,
                                                  &scmi_iio_buffer_ops);
                if (err < 0) {
                        dev_err(dev,
index 5fd1bf9902ea0d25a307a0b28ed9e6de63a714ba..d332474bc484339f3f1ca3683645df98f2e55862 100644 (file)
@@ -113,7 +113,6 @@ static int ssp_gyro_probe(struct platform_device *pdev)
        indio_dev->available_scan_masks = ssp_gyro_scan_mask;
 
        ret = devm_iio_kfifo_buffer_setup(&pdev->dev, indio_dev,
-                                         INDIO_BUFFER_SOFTWARE,
                                          &ssp_gyro_buffer_ops);
        if (ret)
                return ret;
index 36ba7611d9ceb58a1711d7a30b807e0e8fe3fdbe..ad571796522318d2064c21a6cec5cd0644558b36 100644 (file)
@@ -433,7 +433,6 @@ static int max30100_probe(struct i2c_client *client,
        indio_dev->modes = INDIO_DIRECT_MODE;
 
        ret = devm_iio_kfifo_buffer_setup(&client->dev, indio_dev,
-                                         INDIO_BUFFER_SOFTWARE,
                                          &max30100_buffer_setup_ops);
        if (ret)
                return ret;
index 2292876c55e2dc67d71919c29e1f94e3a4fd6929..abbcef56380786273bed2e9e7a2fb2807aeda95b 100644 (file)
@@ -542,7 +542,6 @@ static int max30102_probe(struct i2c_client *client,
        }
 
        ret = devm_iio_kfifo_buffer_setup(&client->dev, indio_dev,
-                                         INDIO_BUFFER_SOFTWARE,
                                          &max30102_buffer_setup_ops);
        if (ret)
                return ret;
index 383cc32503425562b0ed28bff76e3737321ea69a..c3f433ad3af6b5e672d3e9850e9ba49cfc9f44fb 100644 (file)
@@ -731,7 +731,6 @@ struct iio_dev *inv_icm42600_accel_init(struct inv_icm42600_state *st)
        indio_dev->available_scan_masks = inv_icm42600_accel_scan_masks;
 
        ret = devm_iio_kfifo_buffer_setup(dev, indio_dev,
-                                         INDIO_BUFFER_SOFTWARE,
                                          &inv_icm42600_buffer_ops);
        if (ret)
                return ERR_PTR(ret);
index cec1dd0e04646b6486a2ec17b2a483a7edd73f45..9d94a8518e3ca4b52bc3d8aa55e8519ee1f00f40 100644 (file)
@@ -743,7 +743,6 @@ struct iio_dev *inv_icm42600_gyro_init(struct inv_icm42600_state *st)
        indio_dev->setup_ops = &inv_icm42600_buffer_ops;
 
        ret = devm_iio_kfifo_buffer_setup(dev, indio_dev,
-                                         INDIO_BUFFER_SOFTWARE,
                                          &inv_icm42600_buffer_ops);
        if (ret)
                return ERR_PTR(ret);
index 16730a7809643695d838187d8bf2d6227c86404d..f80c62849d30b58f8a42d80588953fd5d4fe4a8d 100644 (file)
@@ -746,7 +746,6 @@ int st_lsm6dsx_fifo_setup(struct st_lsm6dsx_hw *hw)
                        continue;
 
                ret = devm_iio_kfifo_buffer_setup(hw->dev, hw->iio_devs[i],
-                                                 INDIO_BUFFER_SOFTWARE,
                                                  &st_lsm6dsx_buffer_ops);
                if (ret)
                        return ret;
index 4141c0fa7bc46a24014d748b60521f6e512e0cf4..09b831f9f40b656458b5156cf6f2b170746d95c8 100644 (file)
@@ -1003,7 +1003,6 @@ static int apds9960_probe(struct i2c_client *client,
        indio_dev->modes = INDIO_DIRECT_MODE;
 
        ret = devm_iio_kfifo_buffer_setup(&client->dev, indio_dev,
-                                         INDIO_BUFFER_SOFTWARE,
                                          &apds9960_buffer_setup_ops);
        if (ret)
                return ret;
index 793918e1c45fa400ce3189ffb0b7b71079f0ea7a..f177b20f0f2d983f4244228112d3051f60e9a60e 100644 (file)
@@ -749,7 +749,6 @@ static int ad5933_probe(struct i2c_client *client,
        indio_dev->num_channels = ARRAY_SIZE(ad5933_channels);
 
        ret = devm_iio_kfifo_buffer_setup(&client->dev, indio_dev,
-                                         INDIO_BUFFER_SOFTWARE,
                                          &ad5933_ring_setup_ops);
        if (ret)
                return ret;
index ccd2ceae7b25c92fb21da4f23479deee3d557254..8a83fb58232d5f40c750cfe4aa9c217788d4dd6a 100644 (file)
@@ -12,11 +12,10 @@ void iio_kfifo_free(struct iio_buffer *r);
 
 int devm_iio_kfifo_buffer_setup_ext(struct device *dev,
                                    struct iio_dev *indio_dev,
-                                   int mode_flags,
                                    const struct iio_buffer_setup_ops *setup_ops,
                                    const struct attribute **buffer_attrs);
 
-#define devm_iio_kfifo_buffer_setup(dev, indio_dev, mode_flags, setup_ops)     \
-       devm_iio_kfifo_buffer_setup_ext((dev), (indio_dev), (mode_flags), (setup_ops), NULL)
+#define devm_iio_kfifo_buffer_setup(dev, indio_dev, setup_ops) \
+       devm_iio_kfifo_buffer_setup_ext((dev), (indio_dev), (setup_ops), NULL)
 
 #endif