* [PATCH] hwmon: (sht4x) Convert update_interval to jiffies in pending data check
@ 2026-11-01 1:47 Guenter Roeck
2026-11-01 1:51 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Guenter Roeck @ 2026-11-01 1:47 UTC (permalink / raw)
To: linux-hwmon; +Cc: Guenter Roeck, Sashiko
In sht4x_read_values(), the check for whether a pending post-heater
measurement is still fresh compares get_jiffies_64() against
data->heating_complete + data->update_interval. However,
data->heating_complete is stored in jiffies whereas data->update_interval
is stored in milliseconds.
Whenever HZ != 1000, adding data->update_interval directly without
msecs_to_jiffies() mixes incompatible time units. For example, with the
default 2000 ms update_interval, the validity window is inflated to 8
seconds at HZ=250 and 20 seconds at HZ=100 instead of 2 seconds. A read
within that extended window skips triggering a fresh measurement and
instead returns and caches the stale post-heating measurement left in the
sensor's output buffer.
Convert data->update_interval to jiffies using msecs_to_jiffies() when
computing the pending measurement expiration deadline, matching the
next_update calculation right below it.
Reported-by: Sashiko <sashiko-bot@kernel.org>
Fixes: 0eed6fc3d2b9 ("hwmon: (sht4x): add heater support")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
drivers/hwmon/sht4x.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/hwmon/sht4x.c b/drivers/hwmon/sht4x.c
index 8372b4fc902e..020a523bf863 100644
--- a/drivers/hwmon/sht4x.c
+++ b/drivers/hwmon/sht4x.c
@@ -111,7 +111,9 @@ static int sht4x_read_values(struct sht4x_data *data)
}
if (data->data_pending &&
- time_before64(get_jiffies_64(), data->heating_complete + data->update_interval)) {
+ time_before64(get_jiffies_64(),
+ data->heating_complete +
+ msecs_to_jiffies(data->update_interval))) {
data->data_pending = false;
} else {
next_update = data->last_updated +
--
2.45.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] hwmon: (sht4x) Convert update_interval to jiffies in pending data check
2026-11-01 1:47 [PATCH] hwmon: (sht4x) Convert update_interval to jiffies in pending data check Guenter Roeck
@ 2026-11-01 1:51 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-01 1:51 UTC (permalink / raw)
To: Guenter Roeck, linux-hwmon
> In sht4x_read_values(), the check for whether a pending post-heater
> measurement is still fresh compares get_jiffies_64() against
> data->heating_complete + data->update_interval. However,
> data->heating_complete is stored in jiffies whereas data->update_interval
> is stored in milliseconds.
>
> Whenever HZ != 1000, adding data->update_interval directly without
> msecs_to_jiffies() mixes incompatible time units. For example, with the
> default 2000 ms update_interval, the validity window is inflated to 8
> seconds at HZ=250 and 20 seconds at HZ=100 instead of 2 seconds. A read
> within that extended window skips triggering a fresh measurement and
> instead returns and caches the stale post-heating measurement left in the
> sensor's output buffer.
>
> Convert data->update_interval to jiffies using msecs_to_jiffies() when
> computing the pending measurement expiration deadline, matching the
> next_update calculation right below it.
>
> Reported-by: Sashiko <sashiko-bot@kernel.org>
> Fixes: 0eed6fc3d2b9 ("hwmon: (sht4x): add heater support")
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261101014756.1921506-1-linux@roeck-us.net?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-01 1:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-01 1:47 [PATCH] hwmon: (sht4x) Convert update_interval to jiffies in pending data check Guenter Roeck
2026-11-01 1:51 ` sashiko-bot
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.