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:
Родитель
51570c9d4b
Коммит
f67c6c73cb
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
Загрузка…
Ссылка в новой задаче