]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
hwmon: (ina2xx) Make it easier to add more devices
authorIan Ray <ian.ray@gehealthcare.com>
Fri, 20 Feb 2026 11:20:21 +0000 (13:20 +0200)
committerGuenter Roeck <linux@roeck-us.net>
Tue, 31 Mar 2026 02:45:04 +0000 (19:45 -0700)
* Make sysfs entries documentation easier to maintain.
* Use multi-line enum.
* Correct "has_power_average" comment.

Create a new "has_update_interval" member for chips which support
averaging.

Signed-off-by: Ian Ray <ian.ray@gehealthcare.com>
Reviewed-by: Bence Csókás <bence98@sch.bme.hu> # v2
Tested-by: Jens Almer <bagawk@gmail.com>
Link: https://lore.kernel.org/r/20260220112024.97446-3-ian.ray@gehealthcare.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Documentation/hwmon/ina2xx.rst
drivers/hwmon/ina2xx.c

index a3860aae444c08319a3ef90092ddd43fe5a91f89..a4ddf4bd2b0816b288e1a344ff5e62c3ce0d67d5 100644 (file)
@@ -124,8 +124,16 @@ power1_input               Power(uW) measurement channel
 shunt_resistor         Shunt resistance(uOhm) channel (not for ina260)
 ======================= ===============================================
 
-Additional sysfs entries for ina226, ina230, ina231, ina260, and sy24655
-------------------------------------------------------------------------
+Additional sysfs entries
+------------------------
+
+Additional entries are available for the following chips:
+
+  * ina226
+  * ina230
+  * ina231
+  * ina260
+  * sy24655
 
 ======================= ====================================================
 curr1_lcrit            Critical low current
index 69ac0468dee4fda162d13c5234e527040bb98d83..cd0d39ee7616cbc557c648074f31d487c9b8b820 100644 (file)
@@ -135,13 +135,19 @@ static const struct regmap_config ina2xx_regmap_config = {
        .writeable_reg = ina2xx_writeable_reg,
 };
 
-enum ina2xx_ids { ina219, ina226, ina260, sy24655 };
+enum ina2xx_ids {
+       ina219,
+       ina226,
+       ina260,
+       sy24655
+};
 
 struct ina2xx_config {
        u16 config_default;
        bool has_alerts;        /* chip supports alerts and limits */
        bool has_ishunt;        /* chip has internal shunt resistor */
-       bool has_power_average; /* chip has internal shunt resistor */
+       bool has_power_average; /* chip supports average power */
+       bool has_update_interval;
        int calibration_value;
        int shunt_div;
        int bus_voltage_shift;
@@ -171,6 +177,7 @@ static const struct ina2xx_config ina2xx_config[] = {
                .has_alerts = false,
                .has_ishunt = false,
                .has_power_average = false,
+               .has_update_interval = false,
        },
        [ina226] = {
                .config_default = INA226_CONFIG_DEFAULT,
@@ -182,6 +189,7 @@ static const struct ina2xx_config ina2xx_config[] = {
                .has_alerts = true,
                .has_ishunt = false,
                .has_power_average = false,
+               .has_update_interval = true,
        },
        [ina260] = {
                .config_default = INA260_CONFIG_DEFAULT,
@@ -192,6 +200,7 @@ static const struct ina2xx_config ina2xx_config[] = {
                .has_alerts = true,
                .has_ishunt = true,
                .has_power_average = false,
+               .has_update_interval = true,
        },
        [sy24655] = {
                .config_default = SY24655_CONFIG_DEFAULT,
@@ -203,6 +212,7 @@ static const struct ina2xx_config ina2xx_config[] = {
                .has_alerts = true,
                .has_ishunt = false,
                .has_power_average = true,
+               .has_update_interval = false,
        },
 };
 
@@ -706,7 +716,7 @@ static umode_t ina2xx_is_visible(const void *_data, enum hwmon_sensor_types type
        const struct ina2xx_data *data = _data;
        bool has_alerts = data->config->has_alerts;
        bool has_power_average = data->config->has_power_average;
-       enum ina2xx_ids chip = data->chip;
+       bool has_update_interval = data->config->has_update_interval;
 
        switch (type) {
        case hwmon_in:
@@ -768,7 +778,7 @@ static umode_t ina2xx_is_visible(const void *_data, enum hwmon_sensor_types type
        case hwmon_chip:
                switch (attr) {
                case hwmon_chip_update_interval:
-                       if (chip == ina226 || chip == ina260)
+                       if (has_update_interval)
                                return 0644;
                        break;
                default: