[PATCH v3 3/4] iio: accel: adxl372: add additional events ABIs

From: Alexandru Tachici
Date: Wed Mar 18 2020 - 05:10:14 EST


Adxl372 uses the standard event interface. The additional
ABIs aim to explain to the user that the values set in
./events/thresh_falling_period and ./events/thresh_rising_period
control the state of the device, not just the events timings.

Signed-off-by: Alexandru Tachici <alexandru.tachici@xxxxxxxxxx>
---
drivers/iio/accel/adxl372.c | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/accel/adxl372.c b/drivers/iio/accel/adxl372.c
index d8f95c9f9587..1122c27fc37e 100644
--- a/drivers/iio/accel/adxl372.c
+++ b/drivers/iio/accel/adxl372.c
@@ -239,6 +239,29 @@ static const struct adxl372_axis_lookup adxl372_axis_lookup_table[] = {
{ BIT(0) | BIT(1) | BIT(2), ADXL372_XYZ_FIFO },
};

+static ssize_t adxl372_read_detect_event(struct iio_dev *indio_dev, uintptr_t p,
+ const struct iio_chan_spec *chan,
+ char *buf)
+{
+ return sprintf(buf, "%s", (const char *)p);
+}
+
+static const struct iio_chan_spec_ext_info adxl372_ext_info[] = {
+ {
+ .name = "activity_detect_event",
+ .shared = IIO_SHARED_BY_ALL,
+ .read = adxl372_read_detect_event,
+ .private = (uintptr_t)"in_accel_thresh_x_rising\n",
+ },
+ {
+ .name = "inactivity_detect_event",
+ .shared = IIO_SHARED_BY_ALL,
+ .read = adxl372_read_detect_event,
+ .private = (uintptr_t)"in_accel_thresh_x_falling\n",
+ },
+ {},
+};
+
static const struct iio_event_spec adxl372_events[] = {
{
.type = IIO_EV_TYPE_THRESH,
@@ -272,7 +295,8 @@ static const struct iio_event_spec adxl372_events[] = {
.shift = 4, \
}, \
.event_spec = adxl372_events, \
- .num_event_specs = 2 \
+ .num_event_specs = 2, \
+ .ext_info = adxl372_ext_info, \
}

static const struct iio_chan_spec adxl372_channels[] = {
--
2.20.1