]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
hwmon: (max6639) Rely on subsystem locking
authorGuenter Roeck <linux@roeck-us.net>
Mon, 9 Jun 2025 18:08:07 +0000 (11:08 -0700)
committerGuenter Roeck <linux@roeck-us.net>
Wed, 15 Oct 2025 18:02:43 +0000 (11:02 -0700)
Attribute access is now serialized in the hardware monitoring core,
so locking in the driver code is no longer necessary. Drop it.

While at it, drop unnecessary include of hwmon-sysfs.c.

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

index a06346496e1d93788e64f941592d7378b9d00380..99140a2ca9955ebbf4d1d97f76c90270f3589881 100644 (file)
@@ -16,9 +16,7 @@
 #include <linux/jiffies.h>
 #include <linux/i2c.h>
 #include <linux/hwmon.h>
-#include <linux/hwmon-sysfs.h>
 #include <linux/err.h>
-#include <linux/mutex.h>
 #include <linux/regmap.h>
 #include <linux/util_macros.h>
 
@@ -75,7 +73,6 @@ static const unsigned int freq_table[] = { 20, 33, 50, 100, 5000, 8333, 12500,
  */
 struct max6639_data {
        struct regmap *regmap;
-       struct mutex update_lock;
 
        /* Register values initialized only once */
        u8 ppr[MAX6639_NUM_CHANNELS];   /* Pulses per rotation 0..3 for 1..4 ppr */
@@ -249,16 +246,11 @@ static int max6639_write_fan(struct device *dev, u32 attr, int channel,
                if (val <= 0 || val > 4)
                        return -EINVAL;
 
-               mutex_lock(&data->update_lock);
                /* Set Fan pulse per revolution */
                err = max6639_set_ppr(data, channel, val);
-               if (err < 0) {
-                       mutex_unlock(&data->update_lock);
+               if (err < 0)
                        return err;
-               }
                data->ppr[channel] = val;
-
-               mutex_unlock(&data->update_lock);
                return 0;
        default:
                return -EOPNOTSUPP;
@@ -320,21 +312,17 @@ static int max6639_write_pwm(struct device *dev, u32 attr, int channel,
        case hwmon_pwm_input:
                if (val < 0 || val > 255)
                        return -EINVAL;
-               err = regmap_write(data->regmap, MAX6639_REG_TARGTDUTY(channel),
-                                  val * 120 / 255);
-               return err;
+               return regmap_write(data->regmap, MAX6639_REG_TARGTDUTY(channel),
+                                   val * 120 / 255);
        case hwmon_pwm_freq:
                val = clamp_val(val, 0, 25000);
 
                i = find_closest(val, freq_table, ARRAY_SIZE(freq_table));
 
-               mutex_lock(&data->update_lock);
                err = regmap_update_bits(data->regmap, MAX6639_REG_FAN_CONFIG3(channel),
                                         MAX6639_FAN_CONFIG3_FREQ_MASK, i);
-               if (err < 0) {
-                       mutex_unlock(&data->update_lock);
+               if (err < 0)
                        return err;
-               }
 
                if (i >> 2)
                        err = regmap_set_bits(data->regmap, MAX6639_REG_GCONFIG,
@@ -343,7 +331,6 @@ static int max6639_write_pwm(struct device *dev, u32 attr, int channel,
                        err = regmap_clear_bits(data->regmap, MAX6639_REG_GCONFIG,
                                                MAX6639_GCONFIG_PWM_FREQ_HI);
 
-               mutex_unlock(&data->update_lock);
                return err;
        default:
                return -EOPNOTSUPP;
@@ -753,8 +740,6 @@ static int max6639_probe(struct i2c_client *client)
                }
        }
 
-       mutex_init(&data->update_lock);
-
        /* Initialize the max6639 chip */
        err = max6639_init_client(client, data);
        if (err < 0)