]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
hwmon: Add update_interval_us chip attribute
authorFerdinand Schwenk <ferdinand.schwenk@advastore.com>
Tue, 9 Jun 2026 19:43:11 +0000 (21:43 +0200)
committerGuenter Roeck <linux@roeck-us.net>
Tue, 9 Jun 2026 20:48:19 +0000 (13:48 -0700)
Some hardware monitoring chips support update intervals below one
millisecond. The existing update_interval attribute uses millisecond
granularity, which causes sub-millisecond steps to round to the same
value and become inaccessible from userspace.

Introduce update_interval_us, a companion chip-level attribute that
expresses the same update interval in microseconds. Drivers
implementing this attribute should also implement update_interval for
compatibility with millisecond-based userspace interfaces.

Signed-off-by: Ferdinand Schwenk <ferdinand.schwenk@advastore.com>
Link: https://lore.kernel.org/r/20260609-hwmon-ina238-update-interval-us-v2-v3-2-016b55567950@advastore.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Documentation/ABI/testing/sysfs-class-hwmon
Documentation/hwmon/sysfs-interface.rst
drivers/hwmon/hwmon.c
include/linux/hwmon.h

index cfd0d0bab48398543835888f51ce97261924c6e3..b185bdfc7186a722e5d0bfae54c4c666fb5c59a8 100644 (file)
@@ -27,6 +27,20 @@ Description:
                Some devices have a variable update rate or interval.
                This attribute can be used to change it to the desired value.
 
+What:          /sys/class/hwmon/hwmonX/update_interval_us
+Description:
+               The interval at which the chip will update readings,
+               expressed in microseconds.
+               Unit: microsecond
+
+               RW
+
+               Some devices have a variable update rate or interval and
+               require finer-than-millisecond control.
+               This attribute can be used to change it to the desired value.
+               Drivers implementing this attribute should also implement
+               update_interval for millisecond-based userspace interfaces.
+
 What:          /sys/class/hwmon/hwmonX/inY_min
 Description:
                Voltage min value.
index f76e9f8cc1adae19cdfbd4a7e8761c4feb479a0b..94e1bbce172a3373a7ea26db90f982da0601f5ba 100644 (file)
@@ -106,6 +106,10 @@ Global attributes
 `update_interval`
                The interval at which the chip will update readings.
 
+`update_interval_us`
+               The interval at which the chip will update readings,
+               expressed in microseconds for finer resolution.
+
 
 ********
 Voltages
index 6812d1fd7c283a3282d16b5169b7a6aadbf3b4bc..29dc90a2c3fe7086b80d81e3972be5b3f3dbdac3 100644 (file)
@@ -573,6 +573,7 @@ static const char * const hwmon_chip_attrs[] = {
        [hwmon_chip_curr_reset_history] = "curr_reset_history",
        [hwmon_chip_power_reset_history] = "power_reset_history",
        [hwmon_chip_update_interval] = "update_interval",
+       [hwmon_chip_update_interval_us] = "update_interval_us",
        [hwmon_chip_alarms] = "alarms",
        [hwmon_chip_samples] = "samples",
        [hwmon_chip_curr_samples] = "curr_samples",
index f5330e7ae247cc1159e5808725a965d116a49450..dd713e193d0c3a7be354f311bf8f1b516911b9f7 100644 (file)
@@ -40,6 +40,7 @@ enum hwmon_chip_attributes {
        hwmon_chip_power_reset_history,
        hwmon_chip_register_tz,
        hwmon_chip_update_interval,
+       hwmon_chip_update_interval_us,
        hwmon_chip_alarms,
        hwmon_chip_samples,
        hwmon_chip_curr_samples,
@@ -56,6 +57,7 @@ enum hwmon_chip_attributes {
 #define HWMON_C_POWER_RESET_HISTORY    BIT(hwmon_chip_power_reset_history)
 #define HWMON_C_REGISTER_TZ            BIT(hwmon_chip_register_tz)
 #define HWMON_C_UPDATE_INTERVAL                BIT(hwmon_chip_update_interval)
+#define HWMON_C_UPDATE_INTERVAL_US     BIT(hwmon_chip_update_interval_us)
 #define HWMON_C_ALARMS                 BIT(hwmon_chip_alarms)
 #define HWMON_C_SAMPLES                        BIT(hwmon_chip_samples)
 #define HWMON_C_CURR_SAMPLES           BIT(hwmon_chip_curr_samples)