]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
hwmon: (gpd-fan) Rely on subsystem locking
authorGuenter Roeck <linux@roeck-us.net>
Tue, 9 Sep 2025 12:59:24 +0000 (05:59 -0700)
committerGuenter Roeck <linux@roeck-us.net>
Fri, 17 Oct 2025 14:18:15 +0000 (07:18 -0700)
Attribute access is now serialized in the hardware monitoring core,
so locking in the driver code is no longer necessary. Drop it.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/gpd-fan.c

index 644dc3ca9df7da0174e513c47a820a6ff39eb0ef..57caae9a23ebfd414f2de7568bfbed4d5b40aa0b 100644 (file)
@@ -26,9 +26,6 @@
 static char *gpd_fan_board = "";
 module_param(gpd_fan_board, charp, 0444);
 
-// EC read/write locker, protecting a sequence of EC operations
-static DEFINE_MUTEX(gpd_fan_sequence_lock);
-
 enum gpd_board {
        win_mini,
        win4_6800u,
@@ -507,87 +504,60 @@ static int gpd_fan_hwmon_read(__always_unused struct device *dev,
 {
        int ret;
 
-       ret = mutex_lock_interruptible(&gpd_fan_sequence_lock);
-       if (ret)
-               return ret;
-
        if (type == hwmon_fan) {
                if (attr == hwmon_fan_input) {
                        ret = gpd_read_rpm();
 
                        if (ret < 0)
-                               goto OUT;
+                               return ret;
 
                        *val = ret;
-                       ret = 0;
-                       goto OUT;
+                       return 0;
                }
        } else if (type == hwmon_pwm) {
                switch (attr) {
                case hwmon_pwm_enable:
                        *val = gpd_driver_priv.pwm_enable;
-                       ret = 0;
-                       goto OUT;
+                       return 0;
                case hwmon_pwm_input:
                        ret = gpd_read_pwm();
 
                        if (ret < 0)
-                               goto OUT;
+                               return ret;
 
                        *val = ret;
-                       ret = 0;
-                       goto OUT;
+                       return 0;
                }
        }
 
-       ret = -EOPNOTSUPP;
-
-OUT:
-       mutex_unlock(&gpd_fan_sequence_lock);
-       return ret;
+       return -EOPNOTSUPP;
 }
 
 static int gpd_fan_hwmon_write(__always_unused struct device *dev,
                               enum hwmon_sensor_types type, u32 attr,
                               __always_unused int channel, long val)
 {
-       int ret;
-
-       ret = mutex_lock_interruptible(&gpd_fan_sequence_lock);
-       if (ret)
-               return ret;
-
        if (type == hwmon_pwm) {
                switch (attr) {
                case hwmon_pwm_enable:
-                       if (!in_range(val, 0, 3)) {
-                               ret = -EINVAL;
-                               goto OUT;
-                       }
+                       if (!in_range(val, 0, 3))
+                               return -EINVAL;
 
                        gpd_driver_priv.pwm_enable = val;
 
                        gpd_set_pwm_enable(gpd_driver_priv.pwm_enable);
-                       ret = 0;
-                       goto OUT;
+                       return 0;
                case hwmon_pwm_input:
-                       if (!in_range(val, 0, 256)) {
-                               ret = -ERANGE;
-                               goto OUT;
-                       }
+                       if (!in_range(val, 0, 256))
+                               return -EINVAL;
 
                        gpd_driver_priv.pwm_value = val;
 
-                       ret = gpd_write_pwm(val);
-                       goto OUT;
+                       return gpd_write_pwm(val);
                }
        }
 
-       ret = -EOPNOTSUPP;
-
-OUT:
-       mutex_unlock(&gpd_fan_sequence_lock);
-       return ret;
+       return -EOPNOTSUPP;
 }
 
 static const struct hwmon_ops gpd_fan_ops = {