mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Arnav Kapoor <kapoorarnav43@gmail.com>
Cc: "David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	"Andy Shevchenko" <andriy.shevchenko@intel.com>,
	"Yasin Lee" <yasin.lee.x@gmail.com>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 0/6] iio: proximity: hx9023s: fix sampling frequency, resume and event value handling
Date: Sat, 28 Nov 2026 03:39:58 +0000	[thread overview]
Message-ID: <20261128033958.19377fdd@jic23-hlaptop> (raw)
In-Reply-To: <20261126213710.1047676-1-kapoorarnav43@gmail.com>

On Fri, 27 Nov 2026 03:06:45 +0530
Arnav Kapoor <kapoorarnav43@gmail.com> wrote:

> Five fixes for the HX9023S capacitive proximity driver, and one cleanup.

I took a look as well and these seem fine to me (subject to the various
things Andy raised).  I would definitely like Yasin's input though
if possible.  This is a complex part and driver, so whilst these seem
unlikely to cause problems testing would be even better!

Jonathan

> 
> 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).
> 6: cleanup, no functional change: get_samp_freq() doesn't need a
>    64-bit division either.
> 
> Changes in v2:
> - 1: use val == 0 && val2 == 0 for consistency (Andy)
> - 1: reject 1 kHz and above (a period below the smallest table entry)
>   and use a plain 32-bit division instead of div64_u64() (Andy)
> - 4: check val >= BIT(15), keep the threshold with & ~GENMASK(4, 0)
>   and add a comment on why the low bits are dropped (Andy)
> - 6: new, drop the div_u64() in get_samp_freq() as well (Andy, on v1
>   2/5); last in the series as it isn't a fix
> - Rebase on the current fixes-togreg
> 
> v1: https://lore.kernel.org/all/20261123165255.239490-1-kapoorarnav43@gmail.com/
> 
> 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 checks in 1 and 4 were tested with a
> userspace copy on 32-bit and 64-bit: all 32 table periods are still
> accepted, and the threshold check matches the v1 one for every value.
> 
> Arnav Kapoor (6):
>   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
>   iio: proximity: hx9023s: use plain division in get_samp_freq
> 
>  drivers/iio/proximity/hx9023s.c | 47 +++++++++++++++++++++++++--------
>  1 file changed, 36 insertions(+), 11 deletions(-)
> 
> 
> base-commit: 69bf7489f01ffa3c3269d09eb8a0668b1bdfa053


      parent reply	other threads:[~2026-11-28  3:40 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26 21:36 Arnav Kapoor
2026-11-26 21:36 ` [PATCH v2 1/6] iio: proximity: hx9023s: fix division by zero in set_samp_freq Arnav Kapoor
2026-11-27 11:17   ` Andy Shevchenko
2026-11-26 21:36 ` [PATCH v2 2/6] iio: proximity: hx9023s: check the sampling frequency index Arnav Kapoor
2026-11-26 21:36 ` [PATCH v2 3/6] iio: proximity: hx9023s: re-enable interrupts on resume for events Arnav Kapoor
2026-11-26 21:36 ` [PATCH v2 4/6] iio: proximity: hx9023s: reject out-of-range threshold values Arnav Kapoor
2026-11-27 11:21   ` Andy Shevchenko
2026-11-26 21:36 ` [PATCH v2 5/6] iio: proximity: hx9023s: reject out-of-range debounce values Arnav Kapoor
2026-11-26 21:36 ` [PATCH v2 6/6] iio: proximity: hx9023s: use plain division in get_samp_freq Arnav Kapoor
2026-11-28  3:39 ` Jonathan Cameron [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261128033958.19377fdd@jic23-hlaptop \
    --to=jic23@kernel.org \
    --cc=andriy.shevchenko@intel.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=kapoorarnav43@gmail.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=yasin.lee.x@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®