public inbox for linux-doc@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v6 0/5] iio: accel: adxl345: Implement event scaling and ABI compliance
@ 2026-02-26 15:11 Taha Ed-Dafili
  2026-02-26 15:11 ` [PATCH v6 1/5] docs: iio: adxl345: grammar and formatting cleanups Taha Ed-Dafili
                   ` (6 more replies)
  0 siblings, 7 replies; 9+ messages in thread
From: Taha Ed-Dafili @ 2026-02-26 15:11 UTC (permalink / raw)
  To: linux-iio, jic23
  Cc: dlechner, rdunlap, skhan, nuno.sa, andy, corbet, lars,
	Michael.Hennerich, linux-doc, linux-kernel, Taha Ed-Dafili

This series addresses ADXL345 driver non-compliance with the IIO ABI.

Currently, the driver exposes raw threshold values without a scale factor
to convert them to SI units (m/s^2). It also hides the double tap
threshold value because it shares a hardware register with single tap,
which violates ABI expectations.

This series implements `IIO_EV_INFO_SCALE` in the IIO core and applies it
to the ADXL345 driver. It also exposes the missing `IIO_EV_INFO_VALUE` for
double tap, ensuring userspace can correctly interpret all events, and
cleans up related documentation.

Changes in v6:
- Fixed bitmask pipe alignment(Andy Shevchenko).
- Squeezed IIO_EV_INFO_SCALE bitmask insertions to prevent unnecessary
  git blame churn on trailing list elements (Andy Shevchenko).
- Removed bouncing mentees mailing list from CC.

Changes in v5:
- Split the series into 5 patches for better logical separation.
- Patch 1: Moved alphabetical sorting of the event attribute table here
  (David Lechner).
- Patch 3 (new): Expose `IIO_EV_INFO_VALUE` for the double tap event to
  ensure ABI compliance (Jonathan Cameron).
- Patch 5: Add the newly exposed `in_accel_gesture_doubletap_value` to
  the documentation.

Changes in v4:
- Fixed missing IIO_EV_INFO_SCALE handling for MAG/MAG_ADAPTIVE events.
- Explicitly rejected writes to IIO_EV_INFO_SCALE with -EINVAL.
- Fixed bitmask ordering and whitespace alignment.
- Updated documentation with exact sysfs scale attributes.

Changes in v3:
- Reverted "axis" to "axes" in documentation.
- Removed repetitive scale values from documentation table.

Changes in v2:
- Added core infrastructure for IIO_EV_INFO_SCALE.
- Implemented event scaling (0.612915 m/s^2) for ADXL345.

Thanks to David Lechner for the structural patch feedback, Jonathan
Cameron for the architectural guidance on ABI compliance, and Andy
Shevchenko for the formatting and git history reviews.

Taha Ed-Dafili (5):
  docs: iio: adxl345: grammar and formatting cleanups
  iio: core: Add IIO_EV_INFO_SCALE to event info
  iio: accel: adxl345: Expose IIO_EV_INFO_VALUE for double tap
  iio: accel: adxl345: Implement event scaling for ABI compliance
  docs: iio: adxl345: update event attributes and scaling math

 Documentation/iio/adxl345.rst    | 81 ++++++++++++++++++++------------
 drivers/iio/accel/adxl345_core.c | 32 +++++++++----
 drivers/iio/industrialio-event.c |  1 +
 include/linux/iio/types.h        |  1 +
 4 files changed, 78 insertions(+), 37 deletions(-)

-- 
2.47.3


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v6 1/5] docs: iio: adxl345: grammar and formatting cleanups
  2026-02-26 15:11 [PATCH v6 0/5] iio: accel: adxl345: Implement event scaling and ABI compliance Taha Ed-Dafili
@ 2026-02-26 15:11 ` Taha Ed-Dafili
  2026-02-26 15:11 ` [PATCH v6 2/5] iio: core: Add IIO_EV_INFO_SCALE to event info Taha Ed-Dafili
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Taha Ed-Dafili @ 2026-02-26 15:11 UTC (permalink / raw)
  To: linux-iio, jic23
  Cc: dlechner, rdunlap, skhan, nuno.sa, andy, corbet, lars,
	Michael.Hennerich, linux-doc, linux-kernel, Taha Ed-Dafili

Correct several grammatical errors, typos, and pluralization issues
throughout the ADXL345 documentation.

Key changes include:
- Changing 'generic' to 'general-purpose'
- Correcting 'axis' to 'axes' in multiple tables and descriptions
- Improving phrasing in the device attributes section
- Fixing 'latent' to 'latency' in usage examples
- Sorting the existing event attribute table alphabetically for
  better readability and to establish a clean baseline for future
  additions.

Suggested-by: David Lechner <dlechner@baylibre.com>
Signed-off-by: Taha Ed-Dafili <0rayn.dev@gmail.com>
---
 Documentation/iio/adxl345.rst | 36 +++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/Documentation/iio/adxl345.rst b/Documentation/iio/adxl345.rst
index bb19d64f67c3..0e8977345e9d 100644
--- a/Documentation/iio/adxl345.rst
+++ b/Documentation/iio/adxl345.rst
@@ -12,16 +12,16 @@ This driver supports Analog Device's ADXL345/375 on SPI/I2C bus.
 * `ADXL345 <https://www.analog.com/ADXL345>`_
 * `ADXL375 <https://www.analog.com/ADXL375>`_
 
-The ADXL345 is a generic purpose low power, 3-axis accelerometer with selectable
+The ADXL345 is a general-purpose, low-power, 3-axis accelerometer with selectable
 measurement ranges. The ADXL345 supports the ±2 g, ±4 g, ±8 g, and ±16 g ranges.
 
 2. Device Attributes
 ====================
 
-Each IIO device, has a device folder under ``/sys/bus/iio/devices/iio:deviceX``,
+Each IIO device has a device folder under ``/sys/bus/iio/devices/iio:deviceX``,
 where X is the IIO index of the device. Under these folders reside a set of
 device files, depending on the characteristics and features of the hardware
-device in questions. These files are consistently generalized and documented in
+device in question. These files are consistently generalized and documented in
 the IIO ABI documentation.
 
 The following table shows the ADXL345 related device files, found in the
@@ -42,7 +42,7 @@ specific device folder path ``/sys/bus/iio/devices/iio:deviceX``.
 +-------------------------------------------+----------------------------------------------------------+
 | in_accel_x_raw                            | Raw X-axis accelerometer channel value.                  |
 +-------------------------------------------+----------------------------------------------------------+
-| in_accel_y_calibbias                      | y-axis acceleration offset correction                    |
+| in_accel_y_calibbias                      | Y-axis acceleration offset correction                    |
 +-------------------------------------------+----------------------------------------------------------+
 | in_accel_y_raw                            | Raw Y-axis accelerometer channel value.                  |
 +-------------------------------------------+----------------------------------------------------------+
@@ -68,7 +68,7 @@ present, simply assume its value is 0.
 +-------------------------------------+---------------------------+
 | Channel type                        | Measurement unit          |
 +-------------------------------------+---------------------------+
-| Acceleration on X, Y, and Z axis    | Meters per second squared |
+| Acceleration on X, Y, and Z axes    | Meters per second squared |
 +-------------------------------------+---------------------------+
 
 Sensor Events
@@ -78,8 +78,8 @@ Specific IIO events are triggered by their corresponding interrupts. The sensor
 driver supports either none or a single active interrupt (INT) line, selectable
 from the two available options: INT1 or INT2. The active INT line should be
 specified in the device tree. If no INT line is configured, the sensor defaults
-to FIFO bypass mode, where event detection is disabled and only X, Y, and Z axis
-measurements are available.
+to FIFO bypass mode, where event detection is disabled and only individual
+X, Y, and Z axis measurements are available.
 
 The table below lists the ADXL345-related device files located in the
 device-specific path: ``/sys/bus/iio/devices/iio:deviceX/events``.
@@ -90,37 +90,37 @@ listed.
 +---------------------------------------------+---------------------------------------------+
 | Event handle                                | Description                                 |
 +---------------------------------------------+---------------------------------------------+
-| in_accel_gesture_doubletap_en               | Enable double tap detection on all axis     |
+| in_accel_gesture_doubletap_en               | Enable double tap detection on all axes     |
 +---------------------------------------------+---------------------------------------------+
 | in_accel_gesture_doubletap_reset_timeout    | Double tap window in [us]                   |
 +---------------------------------------------+---------------------------------------------+
-| in_accel_gesture_doubletap_tap2_min_delay   | Double tap latent in [us]                   |
+| in_accel_gesture_doubletap_tap2_min_delay   | Double tap latency in [us]                  |
 +---------------------------------------------+---------------------------------------------+
 | in_accel_gesture_singletap_timeout          | Single tap duration in [us]                 |
 +---------------------------------------------+---------------------------------------------+
 | in_accel_gesture_singletap_value            | Single tap threshold value in 62.5/LSB      |
 +---------------------------------------------+---------------------------------------------+
-| in_accel_mag_falling_period                 | Inactivity time in seconds                  |
+| in_accel_mag_adaptive_falling_period        | AC coupled inactivity time in seconds       |
 +---------------------------------------------+---------------------------------------------+
-| in_accel_mag_falling_value                  | Inactivity threshold value in 62.5/LSB      |
+| in_accel_mag_adaptive_falling_value         | AC coupled inactivity threshold in 62.5/LSB |
 +---------------------------------------------+---------------------------------------------+
 | in_accel_mag_adaptive_rising_en             | Enable AC coupled activity on X axis        |
 +---------------------------------------------+---------------------------------------------+
-| in_accel_mag_adaptive_falling_period        | AC coupled inactivity time in seconds       |
+| in_accel_mag_adaptive_rising_value          | AC coupled activity threshold in 62.5/LSB   |
 +---------------------------------------------+---------------------------------------------+
-| in_accel_mag_adaptive_falling_value         | AC coupled inactivity threshold in 62.5/LSB |
+| in_accel_mag_falling_period                 | Inactivity time in seconds                  |
 +---------------------------------------------+---------------------------------------------+
-| in_accel_mag_adaptive_rising_value          | AC coupled activity threshold in 62.5/LSB   |
+| in_accel_mag_falling_value                  | Inactivity threshold value in 62.5/LSB      |
 +---------------------------------------------+---------------------------------------------+
 | in_accel_mag_rising_en                      | Enable activity detection on X axis         |
 +---------------------------------------------+---------------------------------------------+
 | in_accel_mag_rising_value                   | Activity threshold value in 62.5/LSB        |
 +---------------------------------------------+---------------------------------------------+
-| in_accel_x_gesture_singletap_en             | Enable single tap detection on X axis       |
+| in_accel_x&y&z_mag_adaptive_falling_en      | Enable AC coupled inactivity on all axes    |
 +---------------------------------------------+---------------------------------------------+
-| in_accel_x&y&z_mag_falling_en               | Enable inactivity detection on all axis     |
+| in_accel_x&y&z_mag_falling_en               | Enable inactivity detection on all axes     |
 +---------------------------------------------+---------------------------------------------+
-| in_accel_x&y&z_mag_adaptive_falling_en      | Enable AC coupled inactivity on all axis    |
+| in_accel_x_gesture_singletap_en             | Enable single tap detection on X axis       |
 +---------------------------------------------+---------------------------------------------+
 | in_accel_y_gesture_singletap_en             | Enable single tap detection on Y axis       |
 +---------------------------------------------+---------------------------------------------+
@@ -330,7 +330,7 @@ Configure one or several events:
         ## doubletap, window [us]
         root:/sys/bus/iio/devices/iio:device0> echo 0.025 > ./events/in_accel_gesture_doubletap_reset_timeout
 
-        ## doubletap, latent [us]
+        ## doubletap, latency [us]
         root:/sys/bus/iio/devices/iio:device0> echo 0.025 > ./events/in_accel_gesture_doubletap_tap2_min_delay
 
         ## AC coupled activity, enable
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v6 2/5] iio: core: Add IIO_EV_INFO_SCALE to event info
  2026-02-26 15:11 [PATCH v6 0/5] iio: accel: adxl345: Implement event scaling and ABI compliance Taha Ed-Dafili
  2026-02-26 15:11 ` [PATCH v6 1/5] docs: iio: adxl345: grammar and formatting cleanups Taha Ed-Dafili
@ 2026-02-26 15:11 ` Taha Ed-Dafili
  2026-02-26 15:11 ` [PATCH v6 3/5] iio: accel: adxl345: Expose IIO_EV_INFO_VALUE for double tap Taha Ed-Dafili
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Taha Ed-Dafili @ 2026-02-26 15:11 UTC (permalink / raw)
  To: linux-iio, jic23
  Cc: dlechner, rdunlap, skhan, nuno.sa, andy, corbet, lars,
	Michael.Hennerich, linux-doc, linux-kernel, Taha Ed-Dafili

Implement support for IIO_EV_INFO_SCALE in the internal enum
iio_event_info to allow proper ABI compliance.

This allows drivers (like the ADXL345) to expose event scale
attributes using the standard IIO ABI rather than manual
device attributes.

Signed-off-by: Taha Ed-Dafili <0rayn.dev@gmail.com>
---
 drivers/iio/industrialio-event.c | 1 +
 include/linux/iio/types.h        | 1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/iio/industrialio-event.c b/drivers/iio/industrialio-event.c
index 4149efcd5539..a0d6fcf2a9c9 100644
--- a/drivers/iio/industrialio-event.c
+++ b/drivers/iio/industrialio-event.c
@@ -256,6 +256,7 @@ static const char * const iio_ev_info_text[] = {
 	[IIO_EV_INFO_TAP2_MIN_DELAY] = "tap2_min_delay",
 	[IIO_EV_INFO_RUNNING_PERIOD] = "runningperiod",
 	[IIO_EV_INFO_RUNNING_COUNT] = "runningcount",
+	[IIO_EV_INFO_SCALE] = "scale",
 };
 
 static enum iio_event_direction iio_ev_attr_dir(struct iio_dev_attr *attr)
diff --git a/include/linux/iio/types.h b/include/linux/iio/types.h
index 34eebad12d2c..4e3099defc1d 100644
--- a/include/linux/iio/types.h
+++ b/include/linux/iio/types.h
@@ -21,6 +21,7 @@ enum iio_event_info {
 	IIO_EV_INFO_TAP2_MIN_DELAY,
 	IIO_EV_INFO_RUNNING_PERIOD,
 	IIO_EV_INFO_RUNNING_COUNT,
+	IIO_EV_INFO_SCALE,
 };
 
 #define IIO_VAL_INT 1
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v6 3/5] iio: accel: adxl345: Expose IIO_EV_INFO_VALUE for double tap
  2026-02-26 15:11 [PATCH v6 0/5] iio: accel: adxl345: Implement event scaling and ABI compliance Taha Ed-Dafili
  2026-02-26 15:11 ` [PATCH v6 1/5] docs: iio: adxl345: grammar and formatting cleanups Taha Ed-Dafili
  2026-02-26 15:11 ` [PATCH v6 2/5] iio: core: Add IIO_EV_INFO_SCALE to event info Taha Ed-Dafili
@ 2026-02-26 15:11 ` Taha Ed-Dafili
  2026-02-26 15:11 ` [PATCH v6 4/5] iio: accel: adxl345: Implement event scaling for ABI compliance Taha Ed-Dafili
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Taha Ed-Dafili @ 2026-02-26 15:11 UTC (permalink / raw)
  To: linux-iio, jic23
  Cc: dlechner, rdunlap, skhan, nuno.sa, andy, corbet, lars,
	Michael.Hennerich, linux-doc, linux-kernel, Taha Ed-Dafili

The ADXL345 uses a single hardware register (ADXL345_REG_THRESH_TAP) to
store the threshold for both single tap and double tap events.

Currently, the driver only exposes the IIO_EV_INFO_VALUE attribute for
the single tap event.

However, the IIO ABI dictates that if an event is supported, its
associated configuration attributes should be exposed to userspace. This
applies even if writing to one channel property alters the value of
another due to shared underlying hardware state.

Add IIO_EV_INFO_VALUE to the double tap event specification to ensure
full ABI compliance.

Suggested-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Taha Ed-Dafili <0rayn.dev@gmail.com>
---
 drivers/iio/accel/adxl345_core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/accel/adxl345_core.c b/drivers/iio/accel/adxl345_core.c
index 78e3f799ecc1..96d1417d77c6 100644
--- a/drivers/iio/accel/adxl345_core.c
+++ b/drivers/iio/accel/adxl345_core.c
@@ -235,7 +235,9 @@ static const struct iio_event_spec adxl345_events[] = {
 		/* double tap */
 		.type = IIO_EV_TYPE_GESTURE,
 		.dir = IIO_EV_DIR_DOUBLETAP,
-		.mask_shared_by_type = BIT(IIO_EV_INFO_ENABLE) |
+		.mask_shared_by_type =
+			BIT(IIO_EV_INFO_ENABLE) |
+			BIT(IIO_EV_INFO_VALUE) |
 			BIT(IIO_EV_INFO_RESET_TIMEOUT) |
 			BIT(IIO_EV_INFO_TAP2_MIN_DELAY),
 	},
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v6 4/5] iio: accel: adxl345: Implement event scaling for ABI compliance
  2026-02-26 15:11 [PATCH v6 0/5] iio: accel: adxl345: Implement event scaling and ABI compliance Taha Ed-Dafili
                   ` (2 preceding siblings ...)
  2026-02-26 15:11 ` [PATCH v6 3/5] iio: accel: adxl345: Expose IIO_EV_INFO_VALUE for double tap Taha Ed-Dafili
@ 2026-02-26 15:11 ` Taha Ed-Dafili
  2026-02-26 15:11 ` [PATCH v6 5/5] docs: iio: adxl345: update event attributes and scaling math Taha Ed-Dafili
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Taha Ed-Dafili @ 2026-02-26 15:11 UTC (permalink / raw)
  To: linux-iio, jic23
  Cc: dlechner, rdunlap, skhan, nuno.sa, andy, corbet, lars,
	Michael.Hennerich, linux-doc, linux-kernel, Taha Ed-Dafili

The ADXL345 uses a fixed threshold resolution of 62.5 mg/LSB for
event-related registers. Previously, the driver reported raw
values without a scale factor.

Implement IIO_EV_INFO_SCALE for all event types to provide the
conversion factor (0.612915 m/s^2) as required by the IIO ABI.

Consequently, remove the obsolete comment in adxl345_read_event_value()
which stated that the scale factor is not applied.

Add explicit write rejection for IIO_EV_INFO_SCALE in
adxl345_write_event_value() returning -EINVAL.

Suggested-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Taha Ed-Dafili <0rayn.dev@gmail.com>
---
 drivers/iio/accel/adxl345_core.c | 28 +++++++++++++++++++++-------
 1 file changed, 21 insertions(+), 7 deletions(-)

diff --git a/drivers/iio/accel/adxl345_core.c b/drivers/iio/accel/adxl345_core.c
index 96d1417d77c6..6c9080d88c60 100644
--- a/drivers/iio/accel/adxl345_core.c
+++ b/drivers/iio/accel/adxl345_core.c
@@ -213,6 +213,7 @@ static const struct iio_event_spec adxl345_events[] = {
 		.dir = IIO_EV_DIR_RISING,
 		.mask_shared_by_type =
 			BIT(IIO_EV_INFO_ENABLE) |
+			BIT(IIO_EV_INFO_SCALE) |
 			BIT(IIO_EV_INFO_VALUE),
 	},
 	{
@@ -221,6 +222,7 @@ static const struct iio_event_spec adxl345_events[] = {
 		.dir = IIO_EV_DIR_RISING,
 		.mask_shared_by_type =
 			BIT(IIO_EV_INFO_ENABLE) |
+			BIT(IIO_EV_INFO_SCALE) |
 			BIT(IIO_EV_INFO_VALUE),
 	},
 	{
@@ -228,7 +230,9 @@ static const struct iio_event_spec adxl345_events[] = {
 		.type = IIO_EV_TYPE_GESTURE,
 		.dir = IIO_EV_DIR_SINGLETAP,
 		.mask_separate = BIT(IIO_EV_INFO_ENABLE),
-		.mask_shared_by_type = BIT(IIO_EV_INFO_VALUE) |
+		.mask_shared_by_type =
+			BIT(IIO_EV_INFO_SCALE) |
+			BIT(IIO_EV_INFO_VALUE) |
 			BIT(IIO_EV_INFO_TIMEOUT),
 	},
 	{
@@ -237,6 +241,7 @@ static const struct iio_event_spec adxl345_events[] = {
 		.dir = IIO_EV_DIR_DOUBLETAP,
 		.mask_shared_by_type =
 			BIT(IIO_EV_INFO_ENABLE) |
+			BIT(IIO_EV_INFO_SCALE) |
 			BIT(IIO_EV_INFO_VALUE) |
 			BIT(IIO_EV_INFO_RESET_TIMEOUT) |
 			BIT(IIO_EV_INFO_TAP2_MIN_DELAY),
@@ -276,6 +281,7 @@ static const struct iio_event_spec adxl345_fake_chan_events[] = {
 		.dir = IIO_EV_DIR_FALLING,
 		.mask_separate = BIT(IIO_EV_INFO_ENABLE),
 		.mask_shared_by_type =
+			BIT(IIO_EV_INFO_SCALE) |
 			BIT(IIO_EV_INFO_VALUE) |
 			BIT(IIO_EV_INFO_PERIOD),
 	},
@@ -285,6 +291,7 @@ static const struct iio_event_spec adxl345_fake_chan_events[] = {
 		.dir = IIO_EV_DIR_FALLING,
 		.mask_separate = BIT(IIO_EV_INFO_ENABLE),
 		.mask_shared_by_type =
+			BIT(IIO_EV_INFO_SCALE) |
 			BIT(IIO_EV_INFO_VALUE) |
 			BIT(IIO_EV_INFO_PERIOD),
 	},
@@ -1343,6 +1350,16 @@ static int adxl345_read_event_value(struct iio_dev *indio_dev,
 	unsigned int tap_threshold;
 	int ret;
 
+	/*
+	 * The event threshold LSB is fixed at 62.5 mg/LSB
+	 * 0.0625 * 9.80665 = 0.612915625 m/s^2
+	 */
+	if (info == IIO_EV_INFO_SCALE) {
+		*val = 0;
+		*val2 = 612915;
+		return IIO_VAL_INT_PLUS_MICRO;
+	}
+
 	switch (type) {
 	case IIO_EV_TYPE_MAG:
 		return adxl345_read_mag_value(st, dir, info,
@@ -1357,12 +1374,6 @@ static int adxl345_read_event_value(struct iio_dev *indio_dev,
 	case IIO_EV_TYPE_GESTURE:
 		switch (info) {
 		case IIO_EV_INFO_VALUE:
-			/*
-			 * The scale factor would be 62.5mg/LSB (i.e. 0xFF = 16g) but
-			 * not applied here. In context of this general purpose sensor,
-			 * what imports is rather signal intensity than the absolute
-			 * measured g value.
-			 */
 			ret = regmap_read(st->regmap, ADXL345_REG_THRESH_TAP,
 					  &tap_threshold);
 			if (ret)
@@ -1403,6 +1414,9 @@ static int adxl345_write_event_value(struct iio_dev *indio_dev,
 	if (ret)
 		return ret;
 
+	if (info == IIO_EV_INFO_SCALE)
+		return -EINVAL;
+
 	switch (type) {
 	case IIO_EV_TYPE_MAG:
 		ret = adxl345_write_mag_value(st, dir, info,
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v6 5/5] docs: iio: adxl345: update event attributes and scaling math
  2026-02-26 15:11 [PATCH v6 0/5] iio: accel: adxl345: Implement event scaling and ABI compliance Taha Ed-Dafili
                   ` (3 preceding siblings ...)
  2026-02-26 15:11 ` [PATCH v6 4/5] iio: accel: adxl345: Implement event scaling for ABI compliance Taha Ed-Dafili
@ 2026-02-26 15:11 ` Taha Ed-Dafili
  2026-02-28 16:14 ` [PATCH v6 0/5] iio: accel: adxl345: Implement event scaling and ABI compliance Jonathan Cameron
  2026-02-28 16:27 ` David Lechner
  6 siblings, 0 replies; 9+ messages in thread
From: Taha Ed-Dafili @ 2026-02-26 15:11 UTC (permalink / raw)
  To: linux-iio, jic23
  Cc: dlechner, rdunlap, skhan, nuno.sa, andy, corbet, lars,
	Michael.Hennerich, linux-doc, linux-kernel, Taha Ed-Dafili

Update the documentation to reflect the recent driver additions for
event scaling and the double tap threshold value, alongside correcting
existing technical errors in scale calculations.

Key changes:
- Fix the 62.5 g/LSB typo to 62.5 mg/LSB and add SI unit conversion.
- Correct decimal precision of in_accel_scale and
  in_accel_scale_available to match the actual SI unit (m/s^2)
  values reported by the driver.
- Document the newly generated event scale attributes in the ABI table
  (e.g., in_accel_mag_rising_scale, in_accel_gesture_singletap_scale).
- Document the newly exposed in_accel_gesture_doubletap_value attribute.
- Add a sysfs example showing how to read and interpret the newly
  implemented event scale factor.

Suggested-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Taha Ed-Dafili <0rayn.dev@gmail.com>
---
 Documentation/iio/adxl345.rst | 51 +++++++++++++++++++++++++----------
 1 file changed, 37 insertions(+), 14 deletions(-)

diff --git a/Documentation/iio/adxl345.rst b/Documentation/iio/adxl345.rst
index 0e8977345e9d..978f746a8198 100644
--- a/Documentation/iio/adxl345.rst
+++ b/Documentation/iio/adxl345.rst
@@ -13,7 +13,12 @@ This driver supports Analog Device's ADXL345/375 on SPI/I2C bus.
 * `ADXL375 <https://www.analog.com/ADXL375>`_
 
 The ADXL345 is a general-purpose, low-power, 3-axis accelerometer with selectable
-measurement ranges. The ADXL345 supports the ±2 g, ±4 g, ±8 g, and ±16 g ranges.
+measurement ranges. The ADXL345 supports the following ranges:
+
+- ±2g  (approx. ±19.61 m/s^2)
+- ±4g  (approx. ±39.23 m/s^2)
+- ±8g  (approx. ±78.45 m/s^2)
+- ±16g (approx. ±156.91 m/s^2)
 
 2. Device Attributes
 ====================
@@ -94,27 +99,41 @@ listed.
 +---------------------------------------------+---------------------------------------------+
 | in_accel_gesture_doubletap_reset_timeout    | Double tap window in [us]                   |
 +---------------------------------------------+---------------------------------------------+
+| in_accel_gesture_doubletap_scale            | Double tap gesture threshold scale.         |
++---------------------------------------------+---------------------------------------------+
 | in_accel_gesture_doubletap_tap2_min_delay   | Double tap latency in [us]                  |
 +---------------------------------------------+---------------------------------------------+
+| in_accel_gesture_doubletap_value            | Double tap threshold value                  |
++---------------------------------------------+---------------------------------------------+
+| in_accel_gesture_singletap_scale            | Single tap gesture threshold scale.         |
++---------------------------------------------+---------------------------------------------+
 | in_accel_gesture_singletap_timeout          | Single tap duration in [us]                 |
 +---------------------------------------------+---------------------------------------------+
-| in_accel_gesture_singletap_value            | Single tap threshold value in 62.5/LSB      |
+| in_accel_gesture_singletap_value            | Single tap threshold value                  |
 +---------------------------------------------+---------------------------------------------+
 | in_accel_mag_adaptive_falling_period        | AC coupled inactivity time in seconds       |
 +---------------------------------------------+---------------------------------------------+
-| in_accel_mag_adaptive_falling_value         | AC coupled inactivity threshold in 62.5/LSB |
+| in_accel_mag_adaptive_falling_scale         | AC coupled inactivity threshold scale.      |
++---------------------------------------------+---------------------------------------------+
+| in_accel_mag_adaptive_falling_value         | AC coupled inactivity threshold             |
 +---------------------------------------------+---------------------------------------------+
 | in_accel_mag_adaptive_rising_en             | Enable AC coupled activity on X axis        |
 +---------------------------------------------+---------------------------------------------+
-| in_accel_mag_adaptive_rising_value          | AC coupled activity threshold in 62.5/LSB   |
+| in_accel_mag_adaptive_rising_scale          | AC coupled activity threshold scale.        |
++---------------------------------------------+---------------------------------------------+
+| in_accel_mag_adaptive_rising_value          | AC coupled activity threshold               |
 +---------------------------------------------+---------------------------------------------+
 | in_accel_mag_falling_period                 | Inactivity time in seconds                  |
 +---------------------------------------------+---------------------------------------------+
-| in_accel_mag_falling_value                  | Inactivity threshold value in 62.5/LSB      |
+| in_accel_mag_falling_scale                  | DC coupled inactivity threshold scale.      |
++---------------------------------------------+---------------------------------------------+
+| in_accel_mag_falling_value                  | Inactivity threshold value                  |
 +---------------------------------------------+---------------------------------------------+
 | in_accel_mag_rising_en                      | Enable activity detection on X axis         |
 +---------------------------------------------+---------------------------------------------+
-| in_accel_mag_rising_value                   | Activity threshold value in 62.5/LSB        |
+| in_accel_mag_rising_scale                   | DC coupled activity threshold scale.        |
++---------------------------------------------+---------------------------------------------+
+| in_accel_mag_rising_value                   | Activity threshold value                    |
 +---------------------------------------------+---------------------------------------------+
 | in_accel_x&y&z_mag_adaptive_falling_en      | Enable AC coupled inactivity on all axes    |
 +---------------------------------------------+---------------------------------------------+
@@ -140,8 +159,8 @@ When changing the **g range** configuration, the driver attempts to estimate
 appropriate activity and inactivity thresholds by scaling the default values
 based on the ratio of the previous range to the new one. The resulting threshold
 will never be zero and will always fall between 1 and 255, corresponding to up
-to 62.5 g/LSB as specified in the datasheet. However, you can override these
-estimated thresholds by setting explicit values.
+to 62.5 mg/LSB (0.612915 m/s^2/LSB) as specified in the datasheet. However,
+you can override these estimated thresholds by setting explicit values.
 
 When **activity** and **inactivity** events are enabled, the driver
 automatically manages hysteresis behavior by setting the **link** and
@@ -270,13 +289,13 @@ Scale range configuration:
 .. code-block:: bash
 
         root:/sys/bus/iio/devices/iio:device0> cat ./in_accel_scale
-        0.478899
+        0.004789
         root:/sys/bus/iio/devices/iio:device0> cat ./in_accel_scale_available
-        0.478899 0.957798 1.915595 3.831190
+        0.004789 0.009578 0.019156 0.038312
 
-        root:/sys/bus/iio/devices/iio:device0> echo 1.915595 > ./in_accel_scale
+        root:/sys/bus/iio/devices/iio:device0> echo 0.019156 > ./in_accel_scale
         root:/sys/bus/iio/devices/iio:device0> cat ./in_accel_scale
-        1.915595
+        0.019156
 
 Set output data rate (ODR):
 
@@ -312,10 +331,14 @@ Configure one or several events:
 
         root:/sys/bus/iio/devices/iio:device0> echo 24 > ./buffer0/length
 
-        ## AC coupled activity, threshold [62.5/LSB]
+        ## Check the event scale factor (0.0625 * 9.80665)
+        root:/sys/bus/iio/devices/iio:device0> cat ./events/in_accel_gesture_doubletap_scale
+        0.612915
+
+        ## AC coupled activity, threshold [0.612915 m/s^2/LSB]
         root:/sys/bus/iio/devices/iio:device0> echo 6 > ./events/in_accel_mag_adaptive_rising_value
 
-        ## AC coupled inactivity, threshold, [62.5/LSB]
+        ## AC coupled inactivity, threshold, [0.612915 m/s^2/LSB]
         root:/sys/bus/iio/devices/iio:device0> echo 4 > ./events/in_accel_mag_adaptive_falling_value
 
         ## AC coupled inactivity, time [s]
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v6 0/5] iio: accel: adxl345: Implement event scaling and ABI compliance
  2026-02-26 15:11 [PATCH v6 0/5] iio: accel: adxl345: Implement event scaling and ABI compliance Taha Ed-Dafili
                   ` (4 preceding siblings ...)
  2026-02-26 15:11 ` [PATCH v6 5/5] docs: iio: adxl345: update event attributes and scaling math Taha Ed-Dafili
@ 2026-02-28 16:14 ` Jonathan Cameron
  2026-02-28 16:27 ` David Lechner
  6 siblings, 0 replies; 9+ messages in thread
From: Jonathan Cameron @ 2026-02-28 16:14 UTC (permalink / raw)
  To: Taha Ed-Dafili
  Cc: linux-iio, dlechner, rdunlap, skhan, nuno.sa, andy, corbet, lars,
	Michael.Hennerich, linux-doc, linux-kernel

On Thu, 26 Feb 2026 15:11:01 +0000
Taha Ed-Dafili <0rayn.dev@gmail.com> wrote:

> This series addresses ADXL345 driver non-compliance with the IIO ABI.
> 
> Currently, the driver exposes raw threshold values without a scale factor
> to convert them to SI units (m/s^2). It also hides the double tap
> threshold value because it shares a hardware register with single tap,
> which violates ABI expectations.
> 
> This series implements `IIO_EV_INFO_SCALE` in the IIO core and applies it
> to the ADXL345 driver. It also exposes the missing `IIO_EV_INFO_VALUE` for
> double tap, ensuring userspace can correctly interpret all events, and
> cleans up related documentation.
Series applied to the testing branch of iio.git. After that's had a few days
being poked at by the bots, I'll push it out as togreg which is the branch
linux-next picks up.

Thanks,

Jonathan

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v6 0/5] iio: accel: adxl345: Implement event scaling and ABI compliance
  2026-02-26 15:11 [PATCH v6 0/5] iio: accel: adxl345: Implement event scaling and ABI compliance Taha Ed-Dafili
                   ` (5 preceding siblings ...)
  2026-02-28 16:14 ` [PATCH v6 0/5] iio: accel: adxl345: Implement event scaling and ABI compliance Jonathan Cameron
@ 2026-02-28 16:27 ` David Lechner
  2026-03-01 12:05   ` Jonathan Cameron
  6 siblings, 1 reply; 9+ messages in thread
From: David Lechner @ 2026-02-28 16:27 UTC (permalink / raw)
  To: Taha Ed-Dafili, linux-iio, jic23
  Cc: rdunlap, skhan, nuno.sa, andy, corbet, lars, Michael.Hennerich,
	linux-doc, linux-kernel

On 2/26/26 9:11 AM, Taha Ed-Dafili wrote:
> This series addresses ADXL345 driver non-compliance with the IIO ABI.
> 
Reviewed-by: David Lechner <dlechner@baylibre.com>


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v6 0/5] iio: accel: adxl345: Implement event scaling and ABI compliance
  2026-02-28 16:27 ` David Lechner
@ 2026-03-01 12:05   ` Jonathan Cameron
  0 siblings, 0 replies; 9+ messages in thread
From: Jonathan Cameron @ 2026-03-01 12:05 UTC (permalink / raw)
  To: David Lechner
  Cc: Taha Ed-Dafili, linux-iio, rdunlap, skhan, nuno.sa, andy, corbet,
	lars, Michael.Hennerich, linux-doc, linux-kernel

On Sat, 28 Feb 2026 10:27:35 -0600
David Lechner <dlechner@baylibre.com> wrote:

> On 2/26/26 9:11 AM, Taha Ed-Dafili wrote:
> > This series addresses ADXL345 driver non-compliance with the IIO ABI.
> >   
> Reviewed-by: David Lechner <dlechner@baylibre.com>
> 

Updated to add your tag.

Thanks,

J

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-03-01 12:05 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-26 15:11 [PATCH v6 0/5] iio: accel: adxl345: Implement event scaling and ABI compliance Taha Ed-Dafili
2026-02-26 15:11 ` [PATCH v6 1/5] docs: iio: adxl345: grammar and formatting cleanups Taha Ed-Dafili
2026-02-26 15:11 ` [PATCH v6 2/5] iio: core: Add IIO_EV_INFO_SCALE to event info Taha Ed-Dafili
2026-02-26 15:11 ` [PATCH v6 3/5] iio: accel: adxl345: Expose IIO_EV_INFO_VALUE for double tap Taha Ed-Dafili
2026-02-26 15:11 ` [PATCH v6 4/5] iio: accel: adxl345: Implement event scaling for ABI compliance Taha Ed-Dafili
2026-02-26 15:11 ` [PATCH v6 5/5] docs: iio: adxl345: update event attributes and scaling math Taha Ed-Dafili
2026-02-28 16:14 ` [PATCH v6 0/5] iio: accel: adxl345: Implement event scaling and ABI compliance Jonathan Cameron
2026-02-28 16:27 ` David Lechner
2026-03-01 12:05   ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox