iio: core: Simplify the registration of kfifo buffers

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>
This commit is contained in:
Miquel Raynal 2022-02-07 15:38:39 +01:00 committed by Jonathan Cameron
parent 51570c9d4b
commit f67c6c73cb
18 changed files with 5 additions and 31 deletions

View File

@ -1567,7 +1567,6 @@ int adxl367_probe(struct device *dev, const struct adxl367_ops *ops,
return ret; return ret;
ret = devm_iio_kfifo_buffer_setup_ext(st->dev, indio_dev, ret = devm_iio_kfifo_buffer_setup_ext(st->dev, indio_dev,
INDIO_BUFFER_SOFTWARE,
&adxl367_buffer_ops, &adxl367_buffer_ops,
adxl367_fifo_attributes); adxl367_fifo_attributes);
if (ret) if (ret)

View File

@ -1217,7 +1217,6 @@ int fxls8962af_core_probe(struct device *dev, struct regmap *regmap, int irq)
return ret; return ret;
ret = devm_iio_kfifo_buffer_setup(dev, indio_dev, ret = devm_iio_kfifo_buffer_setup(dev, indio_dev,
INDIO_BUFFER_SOFTWARE,
&fxls8962af_buffer_ops); &fxls8962af_buffer_ops);
if (ret) if (ret)
return ret; return ret;

View File

@ -1474,7 +1474,6 @@ static int sca3000_probe(struct spi_device *spi)
indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->modes = INDIO_DIRECT_MODE;
ret = devm_iio_kfifo_buffer_setup(&spi->dev, indio_dev, ret = devm_iio_kfifo_buffer_setup(&spi->dev, indio_dev,
INDIO_BUFFER_SOFTWARE,
&sca3000_ring_setup_ops); &sca3000_ring_setup_ops);
if (ret) if (ret)
return ret; return ret;

View File

@ -113,7 +113,6 @@ static int ssp_accel_probe(struct platform_device *pdev)
indio_dev->available_scan_masks = ssp_accel_scan_mask; indio_dev->available_scan_masks = ssp_accel_scan_mask;
ret = devm_iio_kfifo_buffer_setup(&pdev->dev, indio_dev, ret = devm_iio_kfifo_buffer_setup(&pdev->dev, indio_dev,
INDIO_BUFFER_SOFTWARE,
&ssp_accel_buffer_ops); &ssp_accel_buffer_ops);
if (ret) if (ret)
return ret; return ret;

View File

@ -1027,7 +1027,6 @@ static int ina2xx_probe(struct i2c_client *client,
indio_dev->name = id->name; indio_dev->name = id->name;
ret = devm_iio_kfifo_buffer_setup(&client->dev, indio_dev, ret = devm_iio_kfifo_buffer_setup(&client->dev, indio_dev,
INDIO_BUFFER_SOFTWARE,
&ina2xx_setup_ops); &ina2xx_setup_ops);
if (ret) if (ret)
return ret; return ret;

View File

@ -376,9 +376,7 @@ static int tiadc_iio_buffered_hardware_setup(struct device *dev,
{ {
int ret; int ret;
ret = devm_iio_kfifo_buffer_setup(dev, indio_dev, ret = devm_iio_kfifo_buffer_setup(dev, indio_dev, setup_ops);
INDIO_BUFFER_SOFTWARE,
setup_ops);
if (ret) if (ret)
return ret; return ret;

View 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 * 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 * @dev: Device object to which to attach the life-time of this kfifo buffer
* @indio_dev: The device the buffer should be attached to * @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) * @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 * @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, int devm_iio_kfifo_buffer_setup_ext(struct device *dev,
struct iio_dev *indio_dev, struct iio_dev *indio_dev,
int mode_flags,
const struct iio_buffer_setup_ops *setup_ops, const struct iio_buffer_setup_ops *setup_ops,
const struct attribute **buffer_attrs) const struct attribute **buffer_attrs)
{ {
struct iio_buffer *buffer; struct iio_buffer *buffer;
if (!mode_flags)
return -EINVAL;
buffer = devm_iio_kfifo_allocate(dev); buffer = devm_iio_kfifo_allocate(dev);
if (!buffer) if (!buffer)
return -ENOMEM; return -ENOMEM;
mode_flags &= kfifo_access_funcs.modes; indio_dev->modes |= INDIO_BUFFER_SOFTWARE;
indio_dev->modes |= mode_flags;
indio_dev->setup_ops = setup_ops; indio_dev->setup_ops = setup_ops;
buffer->attrs = buffer_attrs; buffer->attrs = buffer_attrs;

View 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 * We can not use trigger here, as events are generated
* as soon as sample_frequency is set. * as soon as sample_frequency is set.
*/ */
ret = devm_iio_kfifo_buffer_setup_ext(dev, indio_dev, ret = devm_iio_kfifo_buffer_setup_ext(dev, indio_dev, NULL,
INDIO_BUFFER_SOFTWARE, NULL,
cros_ec_sensor_fifo_attributes); cros_ec_sensor_fifo_attributes);
if (ret) if (ret)
return ret; return ret;

View 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, err = devm_iio_kfifo_buffer_setup(&scmi_iio_dev->dev,
scmi_iio_dev, scmi_iio_dev,
INDIO_BUFFER_SOFTWARE,
&scmi_iio_buffer_ops); &scmi_iio_buffer_ops);
if (err < 0) { if (err < 0) {
dev_err(dev, dev_err(dev,

View File

@ -113,7 +113,6 @@ static int ssp_gyro_probe(struct platform_device *pdev)
indio_dev->available_scan_masks = ssp_gyro_scan_mask; indio_dev->available_scan_masks = ssp_gyro_scan_mask;
ret = devm_iio_kfifo_buffer_setup(&pdev->dev, indio_dev, ret = devm_iio_kfifo_buffer_setup(&pdev->dev, indio_dev,
INDIO_BUFFER_SOFTWARE,
&ssp_gyro_buffer_ops); &ssp_gyro_buffer_ops);
if (ret) if (ret)
return ret; return ret;

View File

@ -433,7 +433,6 @@ static int max30100_probe(struct i2c_client *client,
indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->modes = INDIO_DIRECT_MODE;
ret = devm_iio_kfifo_buffer_setup(&client->dev, indio_dev, ret = devm_iio_kfifo_buffer_setup(&client->dev, indio_dev,
INDIO_BUFFER_SOFTWARE,
&max30100_buffer_setup_ops); &max30100_buffer_setup_ops);
if (ret) if (ret)
return ret; return ret;

View File

@ -542,7 +542,6 @@ static int max30102_probe(struct i2c_client *client,
} }
ret = devm_iio_kfifo_buffer_setup(&client->dev, indio_dev, ret = devm_iio_kfifo_buffer_setup(&client->dev, indio_dev,
INDIO_BUFFER_SOFTWARE,
&max30102_buffer_setup_ops); &max30102_buffer_setup_ops);
if (ret) if (ret)
return ret; return ret;

View 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; indio_dev->available_scan_masks = inv_icm42600_accel_scan_masks;
ret = devm_iio_kfifo_buffer_setup(dev, indio_dev, ret = devm_iio_kfifo_buffer_setup(dev, indio_dev,
INDIO_BUFFER_SOFTWARE,
&inv_icm42600_buffer_ops); &inv_icm42600_buffer_ops);
if (ret) if (ret)
return ERR_PTR(ret); return ERR_PTR(ret);

View 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; indio_dev->setup_ops = &inv_icm42600_buffer_ops;
ret = devm_iio_kfifo_buffer_setup(dev, indio_dev, ret = devm_iio_kfifo_buffer_setup(dev, indio_dev,
INDIO_BUFFER_SOFTWARE,
&inv_icm42600_buffer_ops); &inv_icm42600_buffer_ops);
if (ret) if (ret)
return ERR_PTR(ret); return ERR_PTR(ret);

View File

@ -746,7 +746,6 @@ int st_lsm6dsx_fifo_setup(struct st_lsm6dsx_hw *hw)
continue; continue;
ret = devm_iio_kfifo_buffer_setup(hw->dev, hw->iio_devs[i], ret = devm_iio_kfifo_buffer_setup(hw->dev, hw->iio_devs[i],
INDIO_BUFFER_SOFTWARE,
&st_lsm6dsx_buffer_ops); &st_lsm6dsx_buffer_ops);
if (ret) if (ret)
return ret; return ret;

View File

@ -1003,7 +1003,6 @@ static int apds9960_probe(struct i2c_client *client,
indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->modes = INDIO_DIRECT_MODE;
ret = devm_iio_kfifo_buffer_setup(&client->dev, indio_dev, ret = devm_iio_kfifo_buffer_setup(&client->dev, indio_dev,
INDIO_BUFFER_SOFTWARE,
&apds9960_buffer_setup_ops); &apds9960_buffer_setup_ops);
if (ret) if (ret)
return ret; return ret;

View File

@ -749,7 +749,6 @@ static int ad5933_probe(struct i2c_client *client,
indio_dev->num_channels = ARRAY_SIZE(ad5933_channels); indio_dev->num_channels = ARRAY_SIZE(ad5933_channels);
ret = devm_iio_kfifo_buffer_setup(&client->dev, indio_dev, ret = devm_iio_kfifo_buffer_setup(&client->dev, indio_dev,
INDIO_BUFFER_SOFTWARE,
&ad5933_ring_setup_ops); &ad5933_ring_setup_ops);
if (ret) if (ret)
return ret; return ret;

View File

@ -12,11 +12,10 @@ void iio_kfifo_free(struct iio_buffer *r);
int devm_iio_kfifo_buffer_setup_ext(struct device *dev, int devm_iio_kfifo_buffer_setup_ext(struct device *dev,
struct iio_dev *indio_dev, struct iio_dev *indio_dev,
int mode_flags,
const struct iio_buffer_setup_ops *setup_ops, const struct iio_buffer_setup_ops *setup_ops,
const struct attribute **buffer_attrs); const struct attribute **buffer_attrs);
#define devm_iio_kfifo_buffer_setup(dev, indio_dev, mode_flags, setup_ops) \ #define devm_iio_kfifo_buffer_setup(dev, indio_dev, setup_ops) \
devm_iio_kfifo_buffer_setup_ext((dev), (indio_dev), (mode_flags), (setup_ops), NULL) devm_iio_kfifo_buffer_setup_ext((dev), (indio_dev), (setup_ops), NULL)
#endif #endif