]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
hwmon: (asus-ec-sensors) fix EC read intervals
authorEugene Shalygin <eugene.shalygin@gmail.com>
Sun, 12 Jul 2026 11:05:03 +0000 (13:05 +0200)
committerGuenter Roeck <linux@roeck-us.net>
Sun, 19 Jul 2026 14:15:04 +0000 (07:15 -0700)
Take INITIAL_JIFFIES into account when setting up next update time.

Fixes: d0ddfd241e57 ("hwmon: (asus-ec-sensors) add driver for ASUS EC")
Signed-off-by: Eugene Shalygin <eugene.shalygin@gmail.com>
Link: https://lore.kernel.org/r/20260712110650.1240071-2-eugene.shalygin@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/asus-ec-sensors.c

index 4de6045d1b68a2c95d704416d1964edb3982f5aa..f8756c564aa1d0dfe92c8d4b887014193e1b2361 100644 (file)
@@ -1009,7 +1009,7 @@ struct ec_sensors_data {
        /* sorted list of unique register banks */
        u8 banks[ASUS_EC_MAX_BANK + 1];
        /* in jiffies */
-       unsigned long last_updated;
+       u64 next_update;
        struct lock_data lock_data;
        /* number of board EC sensors */
        u8 nr_sensors;
@@ -1278,13 +1278,12 @@ static int get_cached_value_or_update(const struct device *dev,
                                      int sensor_index,
                                      struct ec_sensors_data *state, s32 *value)
 {
-       if (time_after(jiffies, state->last_updated + HZ)) {
+       if (time_after64(get_jiffies_64(), state->next_update)) {
                if (update_ec_sensors(dev, state)) {
                        dev_err(dev, "update_ec_sensors() failure\n");
                        return -EIO;
                }
-
-               state->last_updated = jiffies;
+               state->next_update = get_jiffies_64() + HZ;
        }
 
        *value = state->sensors[sensor_index].cached_value;
@@ -1402,6 +1401,7 @@ static int asus_ec_probe(struct platform_device *pdev)
        if (!ec_data)
                return -ENOMEM;
 
+       ec_data->next_update = INITIAL_JIFFIES;
        dev_set_drvdata(dev, ec_data);
        ec_data->board_info = pboard_info;