From a07eb5f6f942f26460feb1e92b9c58198f69d4e8 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Mon, 9 Jun 2025 11:08:07 -0700 Subject: [PATCH] hwmon: (max6639) 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. While at it, drop unnecessary include of hwmon-sysfs.c. Signed-off-by: Guenter Roeck --- drivers/hwmon/max6639.c | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/drivers/hwmon/max6639.c b/drivers/hwmon/max6639.c index a06346496e1d9..99140a2ca9955 100644 --- a/drivers/hwmon/max6639.c +++ b/drivers/hwmon/max6639.c @@ -16,9 +16,7 @@ #include #include #include -#include #include -#include #include #include @@ -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) -- 2.47.3