* [PATCH 0/3] iio: proximity: sx93xx: reject fractional event values
@ 2026-12-04 16:31 Arnav Kapoor
2026-12-04 16:31 ` [PATCH 1/3] iio: proximity: sx9310: " Arnav Kapoor
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Arnav Kapoor @ 2026-12-04 16:31 UTC (permalink / raw)
To: Jonathan Cameron
Cc: David Lechner, Nuno Sá,
Andy Shevchenko, Andy Shevchenko, Gwendal Grignou, Stephen Boyd,
linux-iio, linux-kernel, Arnav Kapoor
sx9310, sx9324 and sx9360 ignore val2 in write_event_val(). All their
event values (threshold, period, hysteresis) are integers and read back
as IIO_VAL_INT, but writes are parsed as IIO_VAL_INT_PLUS_MICRO, so 1.5
is stored as 1 and -0.999999 is accepted as 0. Each patch returns
-EINVAL for a non-zero val2, once at the top of the callback, so it
covers every event value and not only the hysteresis.
This is the follow-up Jonathan suggested on v3 of the gain/threshold
series:
https://lore.kernel.org/all/20261128115534.558478-1-kapoorarnav43@gmail.com/
It applies on its own on the current iio testing and also merges
cleanly with v4 of that series.
Compile-tested only (W=1 for every patch, checkpatch --strict clean); I
don't have SX93xx hardware.
Arnav Kapoor (3):
iio: proximity: sx9310: reject fractional event values
iio: proximity: sx9324: reject fractional event values
iio: proximity: sx9360: reject fractional event values
drivers/iio/proximity/sx9310.c | 4 ++++
drivers/iio/proximity/sx9324.c | 4 ++++
drivers/iio/proximity/sx9360.c | 4 ++++
3 files changed, 12 insertions(+)
base-commit: fba506008a5b548ad2708bc2765a039cb00a47ab
--
2.53.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/3] iio: proximity: sx9310: reject fractional event values
2026-12-04 16:31 [PATCH 0/3] iio: proximity: sx93xx: reject fractional event values Arnav Kapoor
@ 2026-12-04 16:31 ` Arnav Kapoor
2026-12-04 17:31 ` Andy Shevchenko
2026-12-04 16:31 ` [PATCH 2/3] iio: proximity: sx9324: " Arnav Kapoor
` (2 subsequent siblings)
3 siblings, 1 reply; 6+ messages in thread
From: Arnav Kapoor @ 2026-12-04 16:31 UTC (permalink / raw)
To: Jonathan Cameron
Cc: David Lechner, Nuno Sá,
Andy Shevchenko, Andy Shevchenko, Gwendal Grignou, Stephen Boyd,
linux-iio, linux-kernel, Arnav Kapoor
sx9310_write_event_val() ignores val2. The threshold, period and hysteresis
are all integers and are read back as IIO_VAL_INT, but the core parses
writes as IIO_VAL_INT_PLUS_MICRO, so a write like 1.5 is silently stored
as 1 and -0.999999 is taken as 0.
Return -EINVAL when val2 is not zero.
Suggested-by: Jonathan Cameron <jic23@kernel.org>
Fixes: ad2b473e2ba3 ("iio: sx9310: Support setting proximity thresholds")
Signed-off-by: Arnav Kapoor <kapoorarnav43@gmail.com>
---
drivers/iio/proximity/sx9310.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c
index 0f7e46ec40a5..57a764075eb6 100644
--- a/drivers/iio/proximity/sx9310.c
+++ b/drivers/iio/proximity/sx9310.c
@@ -621,6 +621,10 @@ static int sx9310_write_event_val(struct iio_dev *indio_dev,
if (chan->type != IIO_PROXIMITY)
return -EINVAL;
+ /* All event values are integers */
+ if (val2)
+ return -EINVAL;
+
switch (info) {
case IIO_EV_INFO_VALUE:
return sx9310_write_thresh(data, chan, val);
--
2.53.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/3] iio: proximity: sx9324: reject fractional event values
2026-12-04 16:31 [PATCH 0/3] iio: proximity: sx93xx: reject fractional event values Arnav Kapoor
2026-12-04 16:31 ` [PATCH 1/3] iio: proximity: sx9310: " Arnav Kapoor
@ 2026-12-04 16:31 ` Arnav Kapoor
2026-12-04 16:31 ` [PATCH 3/3] iio: proximity: sx9360: " Arnav Kapoor
2026-12-04 17:31 ` [PATCH 0/3] iio: proximity: sx93xx: " Andy Shevchenko
3 siblings, 0 replies; 6+ messages in thread
From: Arnav Kapoor @ 2026-12-04 16:31 UTC (permalink / raw)
To: Jonathan Cameron
Cc: David Lechner, Nuno Sá,
Andy Shevchenko, Andy Shevchenko, Gwendal Grignou, Stephen Boyd,
linux-iio, linux-kernel, Arnav Kapoor
sx9324_write_event_val() ignores val2. The threshold, period and hysteresis
are all integers and are read back as IIO_VAL_INT, but the core parses
writes as IIO_VAL_INT_PLUS_MICRO, so a write like 1.5 is silently stored
as 1 and -0.999999 is taken as 0.
Return -EINVAL when val2 is not zero.
Suggested-by: Jonathan Cameron <jic23@kernel.org>
Fixes: 4c18a890dff8 ("iio:proximity:sx9324: Add SX9324 support")
Signed-off-by: Arnav Kapoor <kapoorarnav43@gmail.com>
---
drivers/iio/proximity/sx9324.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/iio/proximity/sx9324.c b/drivers/iio/proximity/sx9324.c
index 762c327063f9..b97fe1abde53 100644
--- a/drivers/iio/proximity/sx9324.c
+++ b/drivers/iio/proximity/sx9324.c
@@ -712,6 +712,10 @@ static int sx9324_write_event_val(struct iio_dev *indio_dev,
if (chan->type != IIO_PROXIMITY)
return -EINVAL;
+ /* All event values are integers */
+ if (val2)
+ return -EINVAL;
+
switch (info) {
case IIO_EV_INFO_VALUE:
return sx9324_write_thresh(data, chan, val);
--
2.53.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 3/3] iio: proximity: sx9360: reject fractional event values
2026-12-04 16:31 [PATCH 0/3] iio: proximity: sx93xx: reject fractional event values Arnav Kapoor
2026-12-04 16:31 ` [PATCH 1/3] iio: proximity: sx9310: " Arnav Kapoor
2026-12-04 16:31 ` [PATCH 2/3] iio: proximity: sx9324: " Arnav Kapoor
@ 2026-12-04 16:31 ` Arnav Kapoor
2026-12-04 17:31 ` [PATCH 0/3] iio: proximity: sx93xx: " Andy Shevchenko
3 siblings, 0 replies; 6+ messages in thread
From: Arnav Kapoor @ 2026-12-04 16:31 UTC (permalink / raw)
To: Jonathan Cameron
Cc: David Lechner, Nuno Sá,
Andy Shevchenko, Andy Shevchenko, Gwendal Grignou, Stephen Boyd,
linux-iio, linux-kernel, Arnav Kapoor
sx9360_write_event_val() ignores val2. The threshold, period and hysteresis
are all integers and are read back as IIO_VAL_INT, but the core parses
writes as IIO_VAL_INT_PLUS_MICRO, so a write like 1.5 is silently stored
as 1 and -0.999999 is taken as 0.
Return -EINVAL when val2 is not zero.
Suggested-by: Jonathan Cameron <jic23@kernel.org>
Fixes: 1cdb4c47f7f5 ("iio:proximity:sx9360: Add sx9360 support")
Signed-off-by: Arnav Kapoor <kapoorarnav43@gmail.com>
---
drivers/iio/proximity/sx9360.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/iio/proximity/sx9360.c b/drivers/iio/proximity/sx9360.c
index b50bdc293934..1fcf270ce5cf 100644
--- a/drivers/iio/proximity/sx9360.c
+++ b/drivers/iio/proximity/sx9360.c
@@ -599,6 +599,10 @@ static int sx9360_write_event_val(struct iio_dev *indio_dev,
if (chan->type != IIO_PROXIMITY)
return -EINVAL;
+ /* All event values are integers */
+ if (val2)
+ return -EINVAL;
+
switch (info) {
case IIO_EV_INFO_VALUE:
return sx9360_write_thresh(data, val);
--
2.53.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/3] iio: proximity: sx9310: reject fractional event values
2026-12-04 16:31 ` [PATCH 1/3] iio: proximity: sx9310: " Arnav Kapoor
@ 2026-12-04 17:31 ` Andy Shevchenko
0 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2026-12-04 17:31 UTC (permalink / raw)
To: Arnav Kapoor
Cc: Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, Gwendal Grignou, Stephen Boyd, linux-iio,
linux-kernel
On Fri, Dec 04, 2026 at 10:01:56PM +0530, Arnav Kapoor wrote:
> sx9310_write_event_val() ignores val2. The threshold, period and hysteresis
> are all integers and are read back as IIO_VAL_INT, but the core parses
> writes as IIO_VAL_INT_PLUS_MICRO, so a write like 1.5 is silently stored
> as 1 and -0.999999 is taken as 0.
> Return -EINVAL when val2 is not zero.
ERANGE is better.
...
> + /* All event values are integers */
> + if (val2)
if (val2 != 0)
slightly better as we operate on 0 as not anyhow special value (in opposite to
error codes).
> + return -EINVAL;
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/3] iio: proximity: sx93xx: reject fractional event values
2026-12-04 16:31 [PATCH 0/3] iio: proximity: sx93xx: reject fractional event values Arnav Kapoor
` (2 preceding siblings ...)
2026-12-04 16:31 ` [PATCH 3/3] iio: proximity: sx9360: " Arnav Kapoor
@ 2026-12-04 17:31 ` Andy Shevchenko
3 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2026-12-04 17:31 UTC (permalink / raw)
To: Arnav Kapoor
Cc: Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, Gwendal Grignou, Stephen Boyd, linux-iio,
linux-kernel
On Fri, Dec 04, 2026 at 10:01:55PM +0530, Arnav Kapoor wrote:
> sx9310, sx9324 and sx9360 ignore val2 in write_event_val(). All their
> event values (threshold, period, hysteresis) are integers and read back
> as IIO_VAL_INT, but writes are parsed as IIO_VAL_INT_PLUS_MICRO, so 1.5
> is stored as 1 and -0.999999 is accepted as 0. Each patch returns
> -EINVAL for a non-zero val2, once at the top of the callback, so it
> covers every event value and not only the hysteresis.
>
> This is the follow-up Jonathan suggested on v3 of the gain/threshold
> series:
> https://lore.kernel.org/all/20261128115534.558478-1-kapoorarnav43@gmail.com/
> It applies on its own on the current iio testing and also merges
> cleanly with v4 of that series.
The comment against patch 1 applies to the whole series.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-12-04 17:32 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-04 16:31 [PATCH 0/3] iio: proximity: sx93xx: reject fractional event values Arnav Kapoor
2026-12-04 16:31 ` [PATCH 1/3] iio: proximity: sx9310: " Arnav Kapoor
2026-12-04 17:31 ` Andy Shevchenko
2026-12-04 16:31 ` [PATCH 2/3] iio: proximity: sx9324: " Arnav Kapoor
2026-12-04 16:31 ` [PATCH 3/3] iio: proximity: sx9360: " Arnav Kapoor
2026-12-04 17:31 ` [PATCH 0/3] iio: proximity: sx93xx: " Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®