summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2025-09-09 15:59:24 +0300
committerGuenter Roeck <linux@roeck-us.net>2025-10-17 17:18:15 +0300
commit0517a5c70c6ebdc1d8945c8c0126d501fa4a4616 (patch)
tree57b6b9e1c936793e9df9ec0316541a01c4e85175
parentca2363f8a294de31c78b05f7e97852eacdde02e6 (diff)
downloadlinux-0517a5c70c6ebdc1d8945c8c0126d501fa4a4616.tar.xz
hwmon: (gpd-fan) Rely on subsystem locking
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>
-rw-r--r--drivers/hwmon/gpd-fan.c56
1 files changed, 13 insertions, 43 deletions
diff --git a/drivers/hwmon/gpd-fan.c b/drivers/hwmon/gpd-fan.c
index 644dc3ca9df7..57caae9a23eb 100644
--- a/drivers/hwmon/gpd-fan.c
+++ b/drivers/hwmon/gpd-fan.c
@@ -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 = {