Skip to content

Commit 80346b2

Browse files
gwendalcrJonathan Cameron
authored andcommitted
iio: cros: unify hw fifo attributes without API changes
Commit 2e2366c ("iio: cros_ec: unify hw fifo attributes into the core file") should be reverted as it set buffer extended attributes at the wrong place. However, to revert it will requires to revert more commits: commit 165aea8 ("iio: cros_ec: use devm_iio_triggered_buffer_setup_ext()") commit 21232b4 ("iio: buffer: remove iio_buffer_set_attrs() helper")). and we would still have conflict with more recent development. commit ee708e6 ("iio: buffer: introduce support for attaching more IIO buffers") Instead, this commit reverts the first 2 commits without re-adding iio_buffer_set_attrs() and set the buffer extended attributes at the right place: 1. Instead of adding has_fw_fifo, deduct it from the configuration: - EC must support FIFO (EC_FEATURE_MOTION_SENSE_FIFO) set. - sensors send data a regular interval (accelerometer, gyro, magnetomer, barometer, light sensor). - "Legacy accelerometer" is only present on EC without FIFO, so we don't need to set buffer attributes. 2. devm_iio_triggered_buffer_setup_ext() does not need to be called when EC does not support FIFO, as there is no FIFO to manage. 3. Use devm_iio_triggered_buffer_setup_ext() when EC has a FIFO to specify the buffer extended attributes. Fixes: 2e2366c ("iio: cros_ec: unify hw fifo attributes into the core file") Fixes: 165aea8 ("iio: cros_ec: use devm_iio_triggered_buffer_setup_ext()") Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20210318184857.2679181-1-gwendal@chromium.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent 0a21526 commit 80346b2

7 files changed

Lines changed: 14 additions & 27 deletions

File tree

‎drivers/iio/accel/cros_ec_accel_legacy.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ static int cros_ec_accel_legacy_probe(struct platform_device *pdev)
215215
return -ENOMEM;
216216

217217
ret = cros_ec_sensors_core_init(pdev, indio_dev, true,
218-
cros_ec_sensors_capture, NULL, false);
218+
cros_ec_sensors_capture, NULL);
219219
if (ret)
220220
return ret;
221221

‎drivers/iio/common/cros_ec_sensors/cros_ec_lid_angle.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ static int cros_ec_lid_angle_probe(struct platform_device *pdev)
9797
if (!indio_dev)
9898
return -ENOMEM;
9999

100-
ret = cros_ec_sensors_core_init(pdev, indio_dev, false, NULL,
101-
NULL, false);
100+
ret = cros_ec_sensors_core_init(pdev, indio_dev, false, NULL, NULL);
102101
if (ret)
103102
return ret;
104103

‎drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,7 @@ static int cros_ec_sensors_probe(struct platform_device *pdev)
236236

237237
ret = cros_ec_sensors_core_init(pdev, indio_dev, true,
238238
cros_ec_sensors_capture,
239-
cros_ec_sensors_push_data,
240-
true);
239+
cros_ec_sensors_push_data);
241240
if (ret)
242241
return ret;
243242

‎drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c‎

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <linux/iio/iio.h>
1313
#include <linux/iio/kfifo_buf.h>
1414
#include <linux/iio/sysfs.h>
15+
#include <linux/iio/trigger.h>
1516
#include <linux/iio/trigger_consumer.h>
1617
#include <linux/iio/triggered_buffer.h>
1718
#include <linux/kernel.h>
@@ -240,16 +241,14 @@ static void cros_ec_sensors_core_clean(void *arg)
240241
* for backward compatibility.
241242
* @push_data: function to call when cros_ec_sensorhub receives
242243
* a sample for that sensor.
243-
* @has_hw_fifo: Set true if this device has/uses a HW FIFO
244244
*
245245
* Return: 0 on success, -errno on failure.
246246
*/
247247
int cros_ec_sensors_core_init(struct platform_device *pdev,
248248
struct iio_dev *indio_dev,
249249
bool physical_device,
250250
cros_ec_sensors_capture_t trigger_capture,
251-
cros_ec_sensorhub_push_data_cb_t push_data,
252-
bool has_hw_fifo)
251+
cros_ec_sensorhub_push_data_cb_t push_data)
253252
{
254253
struct device *dev = &pdev->dev;
255254
struct cros_ec_sensors_core_state *state = iio_priv(indio_dev);
@@ -334,9 +333,9 @@ int cros_ec_sensors_core_init(struct platform_device *pdev,
334333
* We can not use trigger here, as events are generated
335334
* as soon as sample_frequency is set.
336335
*/
337-
ret = devm_iio_kfifo_buffer_setup(dev, indio_dev,
338-
INDIO_BUFFER_SOFTWARE,
339-
NULL);
336+
ret = devm_iio_kfifo_buffer_setup_ext(dev, indio_dev,
337+
INDIO_BUFFER_SOFTWARE, NULL,
338+
cros_ec_sensor_fifo_attributes);
340339
if (ret)
341340
return ret;
342341

@@ -355,21 +354,14 @@ int cros_ec_sensors_core_init(struct platform_device *pdev,
355354
ret = iio_device_set_clock(indio_dev, CLOCK_BOOTTIME);
356355
if (ret)
357356
return ret;
358-
} else {
359-
const struct attribute **fifo_attrs;
360-
361-
if (has_hw_fifo)
362-
fifo_attrs = cros_ec_sensor_fifo_attributes;
363-
else
364-
fifo_attrs = NULL;
365357

358+
} else {
366359
/*
367360
* The only way to get samples in buffer is to set a
368361
* software trigger (systrig, hrtimer).
369362
*/
370-
ret = devm_iio_triggered_buffer_setup_ext(
371-
dev, indio_dev, NULL, trigger_capture,
372-
NULL, fifo_attrs);
363+
ret = devm_iio_triggered_buffer_setup(dev, indio_dev,
364+
NULL, trigger_capture, NULL);
373365
if (ret)
374366
return ret;
375367
}

‎drivers/iio/light/cros_ec_light_prox.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,7 @@ static int cros_ec_light_prox_probe(struct platform_device *pdev)
182182

183183
ret = cros_ec_sensors_core_init(pdev, indio_dev, true,
184184
cros_ec_sensors_capture,
185-
cros_ec_sensors_push_data,
186-
true);
185+
cros_ec_sensors_push_data);
187186
if (ret)
188187
return ret;
189188

‎drivers/iio/pressure/cros_ec_baro.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,7 @@ static int cros_ec_baro_probe(struct platform_device *pdev)
139139

140140
ret = cros_ec_sensors_core_init(pdev, indio_dev, true,
141141
cros_ec_sensors_capture,
142-
cros_ec_sensors_push_data,
143-
true);
142+
cros_ec_sensors_push_data);
144143
if (ret)
145144
return ret;
146145

‎include/linux/iio/common/cros_ec_sensors_core.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,7 @@ struct platform_device;
9696
int cros_ec_sensors_core_init(struct platform_device *pdev,
9797
struct iio_dev *indio_dev, bool physical_device,
9898
cros_ec_sensors_capture_t trigger_capture,
99-
cros_ec_sensorhub_push_data_cb_t push_data,
100-
bool has_hw_fifo);
99+
cros_ec_sensorhub_push_data_cb_t push_data);
101100

102101
irqreturn_t cros_ec_sensors_capture(int irq, void *p);
103102
int cros_ec_sensors_push_data(struct iio_dev *indio_dev,

0 commit comments

Comments
 (0)