lkml.org 
[lkml]   [2020]   [Nov]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 2/2] iio: cros_ec: un-indent block that configures motion sensor fifo
Date
This change also reverses the condition of the FIFO setup. If the feature
setup does not include a EC_FEATURE_MOTION_SENSE_FIFO flag, then the
IIO triggered buffer setup is done and first and early exit is performed.
It'a done like this because the code block (for the IIO triggered buffer
setup) is smaller.

The code block for the EC_FEATURE_MOTION_SENSE_FIFO flag has been
un-indented.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
---
.../cros_ec_sensors/cros_ec_sensors_core.c | 63 +++++++++----------
1 file changed, 28 insertions(+), 35 deletions(-)

diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
index 9470014936f2..921eccd4f6a6 100644
--- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
+++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
@@ -258,6 +258,7 @@ int cros_ec_sensors_core_init(struct platform_device *pdev,
struct cros_ec_sensor_platform *sensor_platform = dev_get_platdata(dev);
u32 ver_mask;
int frequencies[ARRAY_SIZE(state->frequencies) / 2] = { 0 };
+ struct iio_buffer *buffer;
int ret, i;

platform_set_drvdata(pdev, indio_dev);
@@ -324,37 +325,7 @@ int cros_ec_sensors_core_init(struct platform_device *pdev,
(frequencies[i] % 1000) * 1000;
}

- if (cros_ec_check_features(ec, EC_FEATURE_MOTION_SENSE_FIFO)) {
- /*
- * Create a software buffer, feed by the EC FIFO.
- * We can not use trigger here, as events are generated
- * as soon as sample_frequency is set.
- */
- struct iio_buffer *buffer;
-
- buffer = devm_iio_kfifo_allocate(dev);
- if (!buffer)
- return -ENOMEM;
-
- iio_device_attach_buffer(indio_dev, buffer);
- indio_dev->modes = INDIO_BUFFER_SOFTWARE;
-
- ret = cros_ec_sensorhub_register_push_data(
- sensor_hub, sensor_platform->sensor_num,
- indio_dev, push_data);
- if (ret)
- return ret;
-
- ret = devm_add_action_or_reset(
- dev, cros_ec_sensors_core_clean, pdev);
- if (ret)
- return ret;
-
- /* Timestamp coming from FIFO are in ns since boot. */
- ret = iio_device_set_clock(indio_dev, CLOCK_BOOTTIME);
- if (ret)
- return ret;
- } else {
+ if (!cros_ec_check_features(ec, EC_FEATURE_MOTION_SENSE_FIFO)) {
const struct attribute **fifo_attrs;

if (has_hw_fifo)
@@ -366,14 +337,36 @@ int cros_ec_sensors_core_init(struct platform_device *pdev,
* The only way to get samples in buffer is to set a
* software trigger (systrig, hrtimer).
*/
- ret = devm_iio_triggered_buffer_setup_ext(
+ return devm_iio_triggered_buffer_setup_ext(
dev, indio_dev, NULL, trigger_capture,
NULL, fifo_attrs);
- if (ret)
- return ret;
}

- return 0;
+ /*
+ * Create a software buffer, feed by the EC FIFO.
+ * We can not use trigger here, as events are generated
+ * as soon as sample_frequency is set.
+ */
+ buffer = devm_iio_kfifo_allocate(dev);
+ if (!buffer)
+ return -ENOMEM;
+
+ iio_device_attach_buffer(indio_dev, buffer);
+ indio_dev->modes = INDIO_BUFFER_SOFTWARE;
+
+ ret = cros_ec_sensorhub_register_push_data(
+ sensor_hub, sensor_platform->sensor_num,
+ indio_dev, push_data);
+ if (ret)
+ return ret;
+
+ ret = devm_add_action_or_reset(
+ dev, cros_ec_sensors_core_clean, pdev);
+ if (ret)
+ return ret;
+
+ /* Timestamp coming from FIFO are in ns since boot. */
+ return iio_device_set_clock(indio_dev, CLOCK_BOOTTIME);
}
EXPORT_SYMBOL_GPL(cros_ec_sensors_core_init);

--
2.17.1
\
 
 \ /
  Last update: 2020-11-23 15:41    [W:0.103 / U:0.396 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site