* [PATCH v2 1/4] docs: iio: adxl345: fix typos and grammar
2026-02-01 18:33 [PATCH v2 0/4] iio: accel: adxl345: Add event scaling and doc fixes Taha Ed-Dafili
@ 2026-02-01 18:33 ` Taha Ed-Dafili
2026-02-01 19:03 ` Randy Dunlap
2026-02-01 18:33 ` [PATCH v2 2/4] iio: core: Add IIO_EV_INFO_SCALE to event info Taha Ed-Dafili
` (2 subsequent siblings)
3 siblings, 1 reply; 13+ messages in thread
From: Taha Ed-Dafili @ 2026-02-01 18:33 UTC (permalink / raw)
To: jic23
Cc: me, skhan, linux-kernel-mentees-archive, rdunlap, dlechner,
nuno.sa, andy, corbet, lars, Michael.Hennerich, linux-iio,
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
Signed-off-by: Taha Ed-Dafili <0rayn.dev@gmail.com>
---
Documentation/iio/adxl345.rst | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/Documentation/iio/adxl345.rst b/Documentation/iio/adxl345.rst
index bb19d64f67c3..41d209a4dccf 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,7 +78,7 @@ 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
+to FIFO bypass mode, where event detection is disabled and only X, Y, and Z axes
measurements are available.
The table below lists the ADXL345-related device files located in the
@@ -90,11 +90,11 @@ 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] |
+---------------------------------------------+---------------------------------------------+
@@ -118,9 +118,9 @@ listed.
+---------------------------------------------+---------------------------------------------+
| in_accel_x_gesture_singletap_en | Enable single tap detection on X axis |
+---------------------------------------------+---------------------------------------------+
-| 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&y&z_mag_adaptive_falling_en | Enable AC coupled inactivity on all axes |
+---------------------------------------------+---------------------------------------------+
| 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] 13+ messages in thread* Re: [PATCH v2 1/4] docs: iio: adxl345: fix typos and grammar
2026-02-01 18:33 ` [PATCH v2 1/4] docs: iio: adxl345: fix typos and grammar Taha Ed-Dafili
@ 2026-02-01 19:03 ` Randy Dunlap
2026-02-02 15:30 ` Taha Ed-Dafili
0 siblings, 1 reply; 13+ messages in thread
From: Randy Dunlap @ 2026-02-01 19:03 UTC (permalink / raw)
To: Taha Ed-Dafili, jic23
Cc: me, skhan, linux-kernel-mentees-archive, dlechner, nuno.sa, andy,
corbet, lars, Michael.Hennerich, linux-iio, linux-doc,
linux-kernel
Hi,
I have one little nit here:
On 2/1/26 10:33 AM, Taha Ed-Dafili wrote:
> @@ -78,7 +78,7 @@ 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
> +to FIFO bypass mode, where event detection is disabled and only X, Y, and Z axes
As an adjective, I think that "axis" is still correct here.
> measurements are available.
--
~Randy
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 1/4] docs: iio: adxl345: fix typos and grammar
2026-02-01 19:03 ` Randy Dunlap
@ 2026-02-02 15:30 ` Taha Ed-Dafili
0 siblings, 0 replies; 13+ messages in thread
From: Taha Ed-Dafili @ 2026-02-02 15:30 UTC (permalink / raw)
To: rdunlap
Cc: 0rayn.dev, Michael.Hennerich, andy, corbet, dlechner, jic23, lars,
linux-doc, linux-iio, linux-kernel-mentees-archive, linux-kernel,
me, nuno.sa, skhan
Thanks for the catch, Randy.
That makes sense; I'll revert that change in v3.
Best, Taha
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v2 2/4] iio: core: Add IIO_EV_INFO_SCALE to event info
2026-02-01 18:33 [PATCH v2 0/4] iio: accel: adxl345: Add event scaling and doc fixes Taha Ed-Dafili
2026-02-01 18:33 ` [PATCH v2 1/4] docs: iio: adxl345: fix typos and grammar Taha Ed-Dafili
@ 2026-02-01 18:33 ` Taha Ed-Dafili
2026-02-01 19:06 ` David Lechner
2026-02-01 18:33 ` [PATCH v2 3/4] iio: accel: adxl345: Implement event scaling for ABI compliance Taha Ed-Dafili
2026-02-01 18:33 ` [PATCH v2 4/4] docs: iio: adxl345: update math and examples for scaling Taha Ed-Dafili
3 siblings, 1 reply; 13+ messages in thread
From: Taha Ed-Dafili @ 2026-02-01 18:33 UTC (permalink / raw)
To: jic23
Cc: me, skhan, linux-kernel-mentees-archive, rdunlap, dlechner,
nuno.sa, andy, corbet, lars, Michael.Hennerich, linux-iio,
linux-doc, linux-kernel, Taha Ed-Dafili
While implementing event scaling for the ADXL345 to match
the IIO ABI documentation, I noticed that IIO_EV_INFO_SCALE
was missing from the internal enum iio_event_info.
Add the constant and the "scale" sysfs string
to allow drivers to expose these attributes correctly.
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 06295cfc2da8..5096baf233f0 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] 13+ messages in thread* Re: [PATCH v2 2/4] iio: core: Add IIO_EV_INFO_SCALE to event info
2026-02-01 18:33 ` [PATCH v2 2/4] iio: core: Add IIO_EV_INFO_SCALE to event info Taha Ed-Dafili
@ 2026-02-01 19:06 ` David Lechner
2026-02-02 15:19 ` Taha Ed-Dafili
0 siblings, 1 reply; 13+ messages in thread
From: David Lechner @ 2026-02-01 19:06 UTC (permalink / raw)
To: Taha Ed-Dafili, jic23
Cc: me, skhan, linux-kernel-mentees-archive, rdunlap, nuno.sa, andy,
corbet, lars, Michael.Hennerich, linux-iio, linux-doc,
linux-kernel
On 2/1/26 12:33 PM, Taha Ed-Dafili wrote:
> While implementing event scaling for the ADXL345 to match
> the IIO ABI documentation, I noticed that IIO_EV_INFO_SCALE
> was missing from the internal enum iio_event_info.
>
> Add the constant and the "scale" sysfs string
> to allow drivers to expose these attributes correctly.
I think this could be worded better. The enum member isn't really "missing".
Are there actually any users of these attributes that have implemented
it manually? Or is this something just in the docs but not actually ever
used? I didn't look very hard, but I didn't find any drivers with these
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 06295cfc2da8..5096baf233f0 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
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH v2 2/4] iio: core: Add IIO_EV_INFO_SCALE to event info
2026-02-01 19:06 ` David Lechner
@ 2026-02-02 15:19 ` Taha Ed-Dafili
2026-02-02 15:31 ` David Lechner
0 siblings, 1 reply; 13+ messages in thread
From: Taha Ed-Dafili @ 2026-02-02 15:19 UTC (permalink / raw)
To: dlechner
Cc: 0rayn.dev, Michael.Hennerich, andy, corbet, jic23, lars,
linux-doc, linux-iio, linux-kernel-mentees-archive, linux-kernel,
me, nuno.sa, rdunlap, skhan
Hi David,
Thanks for the feedback. You're right—"missing" was poor wording; I’ll
rephrase to "implement support in the core" for v3 to reflect that this
is an infrastructure addition.
Regarding existing users, the current lack of IIO_EV_INFO_SCALE in the core
forces developers into manual workarounds to stay ABI-compliant. For
instance, in drivers/iio/accel/mma8452.c, the developer used
IIO_CONST_ATTR_NAMED to create a manual in_accel_scale and linked it via
.event_attrs. This approach is static and bypasses the standard event_spec
infrastructure.
My goal with adding IIO_EV_INFO_SCALE is to provide a standard path to
report these scales dynamically through read_event_value(), ensuring ABI
compliance without manual sysfs boilerplate.
Does this core infrastructure approach seem like the right architectural
path, or would you prefer I stick to a driver-level attribute for the
ADXL345? Regardless of the path chosen, I will address your other comments
in the next version: I'll fix the "in scale" typo and add the new scale
entries to the adxl345 documentation table.
Thanks,
Taha
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 2/4] iio: core: Add IIO_EV_INFO_SCALE to event info
2026-02-02 15:19 ` Taha Ed-Dafili
@ 2026-02-02 15:31 ` David Lechner
2026-02-07 16:18 ` Jonathan Cameron
0 siblings, 1 reply; 13+ messages in thread
From: David Lechner @ 2026-02-02 15:31 UTC (permalink / raw)
To: Taha Ed-Dafili
Cc: Michael.Hennerich, andy, corbet, jic23, lars, linux-doc,
linux-iio, linux-kernel-mentees-archive, linux-kernel, me,
nuno.sa, rdunlap, skhan
On 2/2/26 9:19 AM, Taha Ed-Dafili wrote:
> Hi David,
>
> Thanks for the feedback. You're right—"missing" was poor wording; I’ll
> rephrase to "implement support in the core" for v3 to reflect that this
> is an infrastructure addition.
>
> Regarding existing users, the current lack of IIO_EV_INFO_SCALE in the core
> forces developers into manual workarounds to stay ABI-compliant. For
> instance, in drivers/iio/accel/mma8452.c, the developer used
> IIO_CONST_ATTR_NAMED to create a manual in_accel_scale and linked it via
> .event_attrs. This approach is static and bypasses the standard event_spec
> infrastructure.
OK, so it looks like there is just one existing user of any events/*_scale
attribute then. That would explain why there isn't a IIO_EV_INFO_SCALE.
It just isn't very common.
>
> My goal with adding IIO_EV_INFO_SCALE is to provide a standard path to
> report these scales dynamically through read_event_value(), ensuring ABI
> compliance without manual sysfs boilerplate.
>
> Does this core infrastructure approach seem like the right architectural
> path, or would you prefer I stick to a driver-level attribute for the
> ADXL345? Regardless of the path chosen, I will address your other comments
> in the next version: I'll fix the "in scale" typo and add the new scale
> entries to the adxl345 documentation table.
If we think there will be more users of this and we want to make it more
discoverable, then adding IIO_EV_INFO_SCALE seems useful.
I would wait until Jonathan weighs in with his opinion before taking action
though.
>
> Thanks,
> Taha
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 2/4] iio: core: Add IIO_EV_INFO_SCALE to event info
2026-02-02 15:31 ` David Lechner
@ 2026-02-07 16:18 ` Jonathan Cameron
0 siblings, 0 replies; 13+ messages in thread
From: Jonathan Cameron @ 2026-02-07 16:18 UTC (permalink / raw)
To: David Lechner
Cc: Taha Ed-Dafili, Michael.Hennerich, andy, corbet, lars, linux-doc,
linux-iio, linux-kernel-mentees-archive, linux-kernel, me,
nuno.sa, rdunlap, skhan
On Mon, 2 Feb 2026 09:31:45 -0600
David Lechner <dlechner@baylibre.com> wrote:
> On 2/2/26 9:19 AM, Taha Ed-Dafili wrote:
> > Hi David,
> >
> > Thanks for the feedback. You're right—"missing" was poor wording; I’ll
> > rephrase to "implement support in the core" for v3 to reflect that this
> > is an infrastructure addition.
> >
> > Regarding existing users, the current lack of IIO_EV_INFO_SCALE in the core
> > forces developers into manual workarounds to stay ABI-compliant. For
> > instance, in drivers/iio/accel/mma8452.c, the developer used
> > IIO_CONST_ATTR_NAMED to create a manual in_accel_scale and linked it via
> > .event_attrs. This approach is static and bypasses the standard event_spec
> > infrastructure.
>
> OK, so it looks like there is just one existing user of any events/*_scale
> attribute then. That would explain why there isn't a IIO_EV_INFO_SCALE.
> It just isn't very common.
>
> >
> > My goal with adding IIO_EV_INFO_SCALE is to provide a standard path to
> > report these scales dynamically through read_event_value(), ensuring ABI
> > compliance without manual sysfs boilerplate.
> >
> > Does this core infrastructure approach seem like the right architectural
> > path, or would you prefer I stick to a driver-level attribute for the
> > ADXL345? Regardless of the path chosen, I will address your other comments
> > in the next version: I'll fix the "in scale" typo and add the new scale
> > entries to the adxl345 documentation table.
>
> If we think there will be more users of this and we want to make it more
> discoverable, then adding IIO_EV_INFO_SCALE seems useful.
>
> I would wait until Jonathan weighs in with his opinion before taking action
> though.
I agree. Makes sense to add this.
Jonathan
>
> >
> > Thanks,
> > Taha
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v2 3/4] iio: accel: adxl345: Implement event scaling for ABI compliance
2026-02-01 18:33 [PATCH v2 0/4] iio: accel: adxl345: Add event scaling and doc fixes Taha Ed-Dafili
2026-02-01 18:33 ` [PATCH v2 1/4] docs: iio: adxl345: fix typos and grammar Taha Ed-Dafili
2026-02-01 18:33 ` [PATCH v2 2/4] iio: core: Add IIO_EV_INFO_SCALE to event info Taha Ed-Dafili
@ 2026-02-01 18:33 ` Taha Ed-Dafili
2026-02-01 18:33 ` [PATCH v2 4/4] docs: iio: adxl345: update math and examples for scaling Taha Ed-Dafili
3 siblings, 0 replies; 13+ messages in thread
From: Taha Ed-Dafili @ 2026-02-01 18:33 UTC (permalink / raw)
To: jic23
Cc: me, skhan, linux-kernel-mentees-archive, rdunlap, dlechner,
nuno.sa, andy, corbet, lars, Michael.Hennerich, linux-iio,
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.
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, 22 insertions(+), 6 deletions(-)
diff --git a/drivers/iio/accel/adxl345_core.c b/drivers/iio/accel/adxl345_core.c
index 78e3f799ecc1..dfe3169ffc5f 100644
--- a/drivers/iio/accel/adxl345_core.c
+++ b/drivers/iio/accel/adxl345_core.c
@@ -212,7 +212,8 @@ static const struct iio_event_spec adxl345_events[] = {
.type = IIO_EV_TYPE_MAG,
.dir = IIO_EV_DIR_RISING,
.mask_shared_by_type =
- BIT(IIO_EV_INFO_ENABLE) |
+ 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,15 +230,19 @@ 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_VALUE) |
+ BIT(IIO_EV_INFO_SCALE) |
BIT(IIO_EV_INFO_TIMEOUT),
},
{
/* double tap */
.type = IIO_EV_TYPE_GESTURE,
.dir = IIO_EV_DIR_DOUBLETAP,
- .mask_shared_by_type = BIT(IIO_EV_INFO_ENABLE) |
- BIT(IIO_EV_INFO_RESET_TIMEOUT) |
+ .mask_shared_by_type =
+ BIT(IIO_EV_INFO_ENABLE) |
+ BIT(IIO_EV_INFO_RESET_TIMEOUT) |
+ BIT(IIO_EV_INFO_SCALE) |
BIT(IIO_EV_INFO_TAP2_MIN_DELAY),
},
};
@@ -274,7 +280,8 @@ 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_VALUE) |
+ BIT(IIO_EV_INFO_VALUE) |
+ BIT(IIO_EV_INFO_SCALE) |
BIT(IIO_EV_INFO_PERIOD),
},
{
@@ -283,7 +290,8 @@ 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_VALUE) |
+ BIT(IIO_EV_INFO_VALUE) |
+ BIT(IIO_EV_INFO_SCALE) |
BIT(IIO_EV_INFO_PERIOD),
},
};
@@ -1367,6 +1375,14 @@ static int adxl345_read_event_value(struct iio_dev *indio_dev,
return ret;
*val = sign_extend32(tap_threshold, 7);
return IIO_VAL_INT;
+ case IIO_EV_INFO_SCALE:
+ /*
+ * The event threshold LSB is fixed at 62.5 mg/LSB
+ * 0.0625 * 9.80665 = 0.612915625 m/s^2
+ */
+ *val = 0;
+ *val2 = 612915;
+ return IIO_VAL_INT_PLUS_MICRO;
case IIO_EV_INFO_TIMEOUT:
*val = st->tap_duration_us;
*val2 = MICRO;
--
2.47.3
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH v2 4/4] docs: iio: adxl345: update math and examples for scaling
2026-02-01 18:33 [PATCH v2 0/4] iio: accel: adxl345: Add event scaling and doc fixes Taha Ed-Dafili
` (2 preceding siblings ...)
2026-02-01 18:33 ` [PATCH v2 3/4] iio: accel: adxl345: Implement event scaling for ABI compliance Taha Ed-Dafili
@ 2026-02-01 18:33 ` Taha Ed-Dafili
2026-02-01 19:13 ` David Lechner
2026-02-07 16:20 ` Jonathan Cameron
3 siblings, 2 replies; 13+ messages in thread
From: Taha Ed-Dafili @ 2026-02-01 18:33 UTC (permalink / raw)
To: jic23
Cc: me, skhan, linux-kernel-mentees-archive, rdunlap, dlechner,
nuno.sa, andy, corbet, lars, Michael.Hennerich, linux-iio,
linux-doc, linux-kernel, Taha Ed-Dafili
Update the documentation to reflect the addition of event scaling
and correct existing technical errors inscale values.
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 actual SI unit (m/s^2)
values reported by the driver.
- Add 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 | 41 +++++++++++++++++++++++------------
1 file changed, 27 insertions(+), 14 deletions(-)
diff --git a/Documentation/iio/adxl345.rst b/Documentation/iio/adxl345.rst
index 41d209a4dccf..2f51a2a4fbd0 100644
--- a/Documentation/iio/adxl345.rst
+++ b/Documentation/iio/adxl345.rst
@@ -13,7 +13,11 @@ 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
====================
@@ -98,23 +102,28 @@ listed.
+---------------------------------------------+---------------------------------------------+
| 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 |
+| | 0.612915 m/s^2/LSB |
+---------------------------------------------+---------------------------------------------+
| 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_value | Inactivity threshold value in |
+| | 0.612915 m/s^2/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_falling_value | AC coupled inactivity threshold in 62.5/LSB |
+| in_accel_mag_adaptive_falling_value | AC coupled inactivity threshold in |
+| | 0.612915 m/s^2/LSB |
+---------------------------------------------+---------------------------------------------+
-| in_accel_mag_adaptive_rising_value | AC coupled activity threshold in 62.5/LSB |
+| in_accel_mag_adaptive_rising_value | AC coupled activity threshold in |
+| | 0.612915 m/s^2/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_mag_rising_value | Activity threshold value in |
+| | 0.612915 m/s^2/LSB |
+---------------------------------------------+---------------------------------------------+
| in_accel_x_gesture_singletap_en | Enable single tap detection on X axis |
+---------------------------------------------+---------------------------------------------+
@@ -140,8 +149,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 +279,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 +321,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_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] 13+ messages in thread* Re: [PATCH v2 4/4] docs: iio: adxl345: update math and examples for scaling
2026-02-01 18:33 ` [PATCH v2 4/4] docs: iio: adxl345: update math and examples for scaling Taha Ed-Dafili
@ 2026-02-01 19:13 ` David Lechner
2026-02-07 16:20 ` Jonathan Cameron
1 sibling, 0 replies; 13+ messages in thread
From: David Lechner @ 2026-02-01 19:13 UTC (permalink / raw)
To: Taha Ed-Dafili, jic23
Cc: me, skhan, linux-kernel-mentees-archive, rdunlap, nuno.sa, andy,
corbet, lars, Michael.Hennerich, linux-iio, linux-doc,
linux-kernel
On 2/1/26 12:33 PM, Taha Ed-Dafili wrote:
> Update the documentation to reflect the addition of event scaling
> and correct existing technical errors inscale values.
s/inscale/in scale/
>
> 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 actual SI unit (m/s^2)
> values reported by the driver.
> - Add 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 | 41 +++++++++++++++++++++++------------
> 1 file changed, 27 insertions(+), 14 deletions(-)
>
> diff --git a/Documentation/iio/adxl345.rst b/Documentation/iio/adxl345.rst
> index 41d209a4dccf..2f51a2a4fbd0 100644
> --- a/Documentation/iio/adxl345.rst
> +++ b/Documentation/iio/adxl345.rst
> @@ -13,7 +13,11 @@ 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
> ====================
> @@ -98,23 +102,28 @@ listed.
> +---------------------------------------------+---------------------------------------------+
> | 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 |
> +| | 0.612915 m/s^2/LSB |
> +---------------------------------------------+---------------------------------------------+
> | 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_value | Inactivity threshold value in |
> +| | 0.612915 m/s^2/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_falling_value | AC coupled inactivity threshold in 62.5/LSB |
> +| in_accel_mag_adaptive_falling_value | AC coupled inactivity threshold in |
> +| | 0.612915 m/s^2/LSB |
> +---------------------------------------------+---------------------------------------------+
> -| in_accel_mag_adaptive_rising_value | AC coupled activity threshold in 62.5/LSB |
> +| in_accel_mag_adaptive_rising_value | AC coupled activity threshold in |
> +| | 0.612915 m/s^2/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_mag_rising_value | Activity threshold value in |
> +| | 0.612915 m/s^2/LSB |
> +---------------------------------------------+---------------------------------------------+
> | in_accel_x_gesture_singletap_en | Enable single tap detection on X axis |
> +---------------------------------------------+---------------------------------------------+
Why not also adding the new in_accel_*_scale attributes to the table?
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 4/4] docs: iio: adxl345: update math and examples for scaling
2026-02-01 18:33 ` [PATCH v2 4/4] docs: iio: adxl345: update math and examples for scaling Taha Ed-Dafili
2026-02-01 19:13 ` David Lechner
@ 2026-02-07 16:20 ` Jonathan Cameron
1 sibling, 0 replies; 13+ messages in thread
From: Jonathan Cameron @ 2026-02-07 16:20 UTC (permalink / raw)
To: Taha Ed-Dafili
Cc: me, skhan, linux-kernel-mentees-archive, rdunlap, dlechner,
nuno.sa, andy, corbet, lars, Michael.Hennerich, linux-iio,
linux-doc, linux-kernel
On Sun, 1 Feb 2026 13:33:13 -0500
Taha Ed-Dafili <0rayn.dev@gmail.com> wrote:
> Update the documentation to reflect the addition of event scaling
> and correct existing technical errors inscale values.
Trivial but please wrap commit messages to 75 chars.
>
> 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 actual SI unit (m/s^2)
> values reported by the driver.
> - Add 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>
As David suggested, better to just document the scale attribute and not
add it to all the others.
Jonathan
^ permalink raw reply [flat|nested] 13+ messages in thread