hwmon: (ina238) Drop pointless power attribute check on attribute writes
authorGuenter Roeck <linux@roeck-us.net>
Mon, 1 Sep 2025 18:01:53 +0000 (11:01 -0700)
committerGuenter Roeck <linux@roeck-us.net>
Sun, 7 Sep 2025 23:34:07 +0000 (16:34 -0700)
There is only a single writeable power attribute, and it is very unlikely
that the chips supported by this driver will ever require another one.
That means checking for that attribute during runtime is unnecessary.
Drop the check. Rename the write function from ina238_write_power() to
ina238_write_power_max() to reflect that a single attribute is written.

No functional change intended.

Reviewed-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Tested-by: Chris Packham <chris.packham@alliedtelesis.co.nz> # INA780
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/ina238.c

index 22e2b86..23195de 100644 (file)
@@ -503,14 +503,11 @@ static int ina238_read_power(struct device *dev, u32 attr, long *val)
        return 0;
 }
 
-static int ina238_write_power(struct device *dev, u32 attr, long val)
+static int ina238_write_power_max(struct device *dev, long val)
 {
        struct ina238_data *data = dev_get_drvdata(dev);
        long regval;
 
-       if (attr != hwmon_power_max)
-               return -EOPNOTSUPP;
-
        /*
         * Unsigned postive values. Compared against the 24-bit power register,
         * lower 8-bits are truncated. Same conversion to/from uW as POWER
@@ -628,7 +625,7 @@ static int ina238_write(struct device *dev, enum hwmon_sensor_types type,
                err = ina238_write_in(dev, attr, channel, val);
                break;
        case hwmon_power:
-               err = ina238_write_power(dev, attr, val);
+               err = ina238_write_power_max(dev, val);
                break;
        case hwmon_temp:
                err = ina238_write_temp(dev, attr, val);