hwmon: (lm95245) 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>
pull/1354/merge
Guenter Roeck 2025-06-07 21:10:12 -07:00
parent 8ee6dc15e2
commit b37a3b983a
1 changed files with 2 additions and 14 deletions

View File

@ -13,7 +13,6 @@
#include <linux/hwmon.h> #include <linux/hwmon.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/mutex.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/slab.h> #include <linux/slab.h>
@ -86,7 +85,6 @@ static const unsigned short normal_i2c[] = {
/* Client data (each client gets its own) */ /* Client data (each client gets its own) */
struct lm95245_data { struct lm95245_data {
struct regmap *regmap; struct regmap *regmap;
struct mutex update_lock;
int interval; /* in msecs */ int interval; /* in msecs */
}; };
@ -279,20 +277,16 @@ static int lm95245_write_temp(struct device *dev, u32 attr, int channel,
ret = regmap_write(regmap, reg, val); ret = regmap_write(regmap, reg, val);
return ret; return ret;
case hwmon_temp_crit_hyst: case hwmon_temp_crit_hyst:
mutex_lock(&data->update_lock);
ret = regmap_read(regmap, LM95245_REG_RW_LOCAL_OS_TCRIT_LIMIT, ret = regmap_read(regmap, LM95245_REG_RW_LOCAL_OS_TCRIT_LIMIT,
&regval); &regval);
if (ret < 0) { if (ret < 0)
mutex_unlock(&data->update_lock);
return ret; return ret;
}
/* Clamp to reasonable range to prevent overflow */ /* Clamp to reasonable range to prevent overflow */
val = clamp_val(val, -1000000, 1000000); val = clamp_val(val, -1000000, 1000000);
val = regval - val / 1000; val = regval - val / 1000;
val = clamp_val(val, 0, 31); val = clamp_val(val, 0, 31);
ret = regmap_write(regmap, LM95245_REG_RW_COMMON_HYSTERESIS, ret = regmap_write(regmap, LM95245_REG_RW_COMMON_HYSTERESIS,
val); val);
mutex_unlock(&data->update_lock);
return ret; return ret;
case hwmon_temp_offset: case hwmon_temp_offset:
val = clamp_val(val, -128000, 127875); val = clamp_val(val, -128000, 127875);
@ -332,14 +326,10 @@ static int lm95245_write_chip(struct device *dev, u32 attr, int channel,
long val) long val)
{ {
struct lm95245_data *data = dev_get_drvdata(dev); struct lm95245_data *data = dev_get_drvdata(dev);
int ret;
switch (attr) { switch (attr) {
case hwmon_chip_update_interval: case hwmon_chip_update_interval:
mutex_lock(&data->update_lock); return lm95245_set_conversion_rate(data, val);
ret = lm95245_set_conversion_rate(data, val);
mutex_unlock(&data->update_lock);
return ret;
default: default:
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
@ -542,8 +532,6 @@ static int lm95245_probe(struct i2c_client *client)
if (IS_ERR(data->regmap)) if (IS_ERR(data->regmap))
return PTR_ERR(data->regmap); return PTR_ERR(data->regmap);
mutex_init(&data->update_lock);
/* Initialize the LM95245 chip */ /* Initialize the LM95245 chip */
ret = lm95245_init_client(data); ret = lm95245_init_client(data);
if (ret < 0) if (ret < 0)