From: sashiko-bot@kernel.org
To: "Emfox Zhou" <emfox@debian.org>
Cc: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH v10 1/6] HID: intel-thc-hid: intel-thc: expose the operations an IPTS port needs
Date: Fri, 27 Nov 2026 16:01:37 +0000 [thread overview]
Message-ID: <sashiko-outbox-237812@kernel.org> (raw)
In-Reply-To: <306c05c7d1ddc7f96fd6d3aafb5d6645d04406ed.1795794049.git.emfox@debian.org>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] HID: intel-thc: 100 Hz rounding in thc_spi_hz_from_div()
misses div8 gears
--
commit 7cfe4283a39cc31a3e9b305786a30873184104d6
Author: Emfox Zhou <emfox@debian.org>
HID: intel-thc-hid: intel-thc: expose the operations an IPTS port needs
This commit adds helper functions to check port support, control port
reset, and convert SPI base clock divisors into bus frequencies, and stops
warning in thc_interrupt_quiesce() when the port is already in the target
state.
> diff --git a/drivers/hid/intel-thc-hid/intel-thc/intel-thc-dev.c b/drivers/hid/intel-thc-hid/intel-thc/intel-thc-dev.c
> index 03d3b60b35cf1..d98c450c2b402 100644
> --- a/drivers/hid/intel-thc-hid/intel-thc/intel-thc-dev.c
> +++ b/drivers/hid/intel-thc-hid/intel-thc/intel-thc-dev.c
[ ... ]
> @@ -1207,6 +1267,37 @@ static bool thc_spi_needs_half_div(u8 freq_div, u32 spi_freq_val,
> spi_freq_val < THC_SPI_FREQUENCY_15M;
> }
>
> +/**
> + * thc_spi_hz_from_div - Turn a base clock divisor into a bus frequency
> + *
> + * @div: divisor, zero when the device did not provide one
> + * @div8: divide the result by eight as well
> + *
> + * A device that describes its bus timing as a divisor has to come back
> + * through here rather than through a copy of the base clock of its own: the
> + * gears thc_spi_read_config() programs are fractions of that clock, and a
> + * frequency computed from another base lands on the wrong one.
> + *
> + * Return: the frequency in Hz, or 0 for a divisor of zero
> + */
> +u32 thc_spi_hz_from_div(u8 div, bool div8)
> +{
> + u32 hz;
> +
> + if (!div)
> + return 0;
> +
> + hz = THC_SPI_BASE_HZ / div;
> + if (div8)
> + hz /= 8;
> +
> + /* Geared frequencies are compared rounded to 100 Hz: round the same
> + * way here, or divisor 3 lands just below the 41 MHz gear.
> + */
> + return DIV_ROUND_CLOSEST(hz, 100) * 100;
> +}
[Severity: Medium]
Does rounding to 100 Hz in thc_spi_hz_from_div() miss the low-frequency
gears when div8 is true?
Unlike the high-frequency gears, the div8 thresholds in frequency[] are
defined to 1 Hz precision:
drivers/hid/intel-thc-hid/intel-thc/intel-thc-dev.c:
#define THC_SPI_FREQUENCY_2M2 2232143
#define THC_SPI_FREQUENCY_2M6 2604167
#define THC_SPI_FREQUENCY_3M1 3125000
#define THC_SPI_FREQUENCY_3M9 3906250
#define THC_SPI_FREQUENCY_5M2 5208333
thc_get_spi_freq_div_val() requires spi_freq_val >= frequency[i] to select
gear i. With div8 = true, div = 7 yields 2232100 Hz, which falls below
THC_SPI_FREQUENCY_2M2 and causes thc_get_spi_freq_div_val() to fail with
THC_SPI_FRQ_RESERVED (-EINVAL in thc_spi_read_config() and
thc_spi_write_config()). Similarly, div = 3 with div8 = true yields
5208300 Hz, which misses THC_SPI_FREQUENCY_5M2 and demotes the clock to
THC_SPI_FREQUENCY_3M9.
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1795794049.git.emfox@debian.org?part=1
next prev parent reply other threads:[~2026-11-27 16:01 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 15:51 [PATCH v10 0/6] HID: intel-thc-hid: intel-ipts: support THC IPTS ports Emfox Zhou
2026-11-27 15:51 ` [PATCH v10 1/6] HID: intel-thc-hid: intel-thc: expose the operations an IPTS port needs Emfox Zhou
2026-11-27 16:01 ` sashiko-bot [this message]
2026-11-27 15:51 ` [PATCH v10 2/6] HID: intel-thc-hid: intel-ipts: bring up the port Emfox Zhou
2026-11-27 16:11 ` sashiko-bot
2026-11-27 15:51 ` [PATCH v10 3/6] HID: intel-thc-hid: intel-ipts: receive reports Emfox Zhou
2026-11-27 16:18 ` sashiko-bot
2026-11-27 15:51 ` [PATCH v10 4/6] HID: intel-thc-hid: intel-ipts: add the HID device Emfox Zhou
2026-11-27 16:06 ` sashiko-bot
2026-11-27 15:51 ` [PATCH v10 5/6] HID: intel-thc-hid: intel-ipts: handle system sleep Emfox Zhou
2026-11-27 15:51 ` [PATCH v10 6/6] HID: intel-thc-hid: intel-ipts: document the IPTS mode Emfox Zhou
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=sashiko-outbox-237812@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=emfox@debian.org \
--cc=linux-input@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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