All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] iio: proximity: hx9023s: fix sampling frequency, resume and event value handling
@ 2026-11-23 16:52 Arnav Kapoor
  2026-11-23 16:52 ` [PATCH 1/5] iio: proximity: hx9023s: fix division by zero in set_samp_freq Arnav Kapoor
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Arnav Kapoor @ 2026-11-23 16:52 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: David Lechner, Nuno Sá, Andy Shevchenko, Andy Shevchenko,
	Yasin Lee, linux-iio, linux-kernel, Arnav Kapoor

Five fixes for the HX9023S capacitive proximity driver.

1: writing 67108864 (or any value for which val * 10^6 + val2 is a
   multiple of 2^32) to sampling_frequency divides by zero: div_u64()
   takes a u32 divisor. The check added in a318cfc08537 only catches 0.
2: reading sampling_frequency indexes the 32-entry period table with
   the PRF_CFG register value unchecked; the configuration file loaded
   by hx9023s_bin_load() can put any 8-bit value there.
3: resume re-enables the chip interrupts only when the trigger is
   enabled, so threshold events stop after the first suspend.
4: out-of-range threshold values are masked into the 10-bit field
   instead of being rejected (-32 becomes the largest threshold).
5: same for the 4-bit debounce fields (16 becomes 0).

Patch 2 assumes the whole PRF_CFG register is the period index, as the
driver already does; I don't have the datasheet to check whether it has
other fields.

Applies to both fixes-togreg and testing.
Compile-tested only (W=1 for every patch, checkpatch --strict clean); I
don't have HX9023S hardware. The divisor wrap in 1 was checked with a
userspace copy of the expression.

Arnav Kapoor (5):
  iio: proximity: hx9023s: fix division by zero in set_samp_freq
  iio: proximity: hx9023s: check the sampling frequency index
  iio: proximity: hx9023s: re-enable interrupts on resume for events
  iio: proximity: hx9023s: reject out-of-range threshold values
  iio: proximity: hx9023s: reject out-of-range debounce values

 drivers/iio/proximity/hx9023s.c | 35 ++++++++++++++++++++++++---------
 1 file changed, 26 insertions(+), 9 deletions(-)


base-commit: 793d80b04b6c4f7f896c273567f94eccd0fac54d
-- 
2.53.0


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

end of thread, other threads:[~2026-11-23 19:26 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23 16:52 [PATCH 0/5] iio: proximity: hx9023s: fix sampling frequency, resume and event value handling Arnav Kapoor
2026-11-23 16:52 ` [PATCH 1/5] iio: proximity: hx9023s: fix division by zero in set_samp_freq Arnav Kapoor
2026-11-23 19:14   ` Andy Shevchenko
2026-11-23 16:52 ` [PATCH 2/5] iio: proximity: hx9023s: check the sampling frequency index Arnav Kapoor
2026-11-23 19:15   ` Andy Shevchenko
2026-11-23 16:52 ` [PATCH 3/5] iio: proximity: hx9023s: re-enable interrupts on resume for events Arnav Kapoor
2026-11-23 16:52 ` [PATCH 4/5] iio: proximity: hx9023s: reject out-of-range threshold values Arnav Kapoor
2026-11-23 19:26   ` Andy Shevchenko
2026-11-23 16:52 ` [PATCH 5/5] iio: proximity: hx9023s: reject out-of-range debounce values Arnav Kapoor

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.