hwmon: (tmp464) Rely on subsystem locking
Attribute access is now serialized in the hardware monitoring core, so locking in the driver is no longer necessary. Drop it. Signed-off-by: Guenter Roeck <linux@roeck-us.net>pull/1354/merge
parent
61e9b50ffa
commit
965e7381ff
|
|
@ -13,7 +13,6 @@
|
||||||
#include <linux/i2c.h>
|
#include <linux/i2c.h>
|
||||||
#include <linux/init.h>
|
#include <linux/init.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/mutex.h>
|
|
||||||
#include <linux/of.h>
|
#include <linux/of.h>
|
||||||
#include <linux/regmap.h>
|
#include <linux/regmap.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
|
|
@ -92,7 +91,6 @@ struct tmp464_channel {
|
||||||
|
|
||||||
struct tmp464_data {
|
struct tmp464_data {
|
||||||
struct regmap *regmap;
|
struct regmap *regmap;
|
||||||
struct mutex update_lock;
|
|
||||||
int channels;
|
int channels;
|
||||||
s16 config_orig;
|
s16 config_orig;
|
||||||
u16 open_reg;
|
u16 open_reg;
|
||||||
|
|
@ -172,19 +170,16 @@ static int tmp464_temp_read(struct device *dev, u32 attr, int channel, long *val
|
||||||
* complete. That means we have to cache the value internally
|
* complete. That means we have to cache the value internally
|
||||||
* for one measurement cycle and report the cached value.
|
* for one measurement cycle and report the cached value.
|
||||||
*/
|
*/
|
||||||
mutex_lock(&data->update_lock);
|
|
||||||
if (!data->valid || time_after(jiffies, data->last_updated +
|
if (!data->valid || time_after(jiffies, data->last_updated +
|
||||||
msecs_to_jiffies(data->update_interval))) {
|
msecs_to_jiffies(data->update_interval))) {
|
||||||
err = regmap_read(regmap, TMP464_REMOTE_OPEN_REG, ®val);
|
err = regmap_read(regmap, TMP464_REMOTE_OPEN_REG, ®val);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto unlock;
|
break;
|
||||||
data->open_reg = regval;
|
data->open_reg = regval;
|
||||||
data->last_updated = jiffies;
|
data->last_updated = jiffies;
|
||||||
data->valid = true;
|
data->valid = true;
|
||||||
}
|
}
|
||||||
*val = !!(data->open_reg & BIT(channel + 7));
|
*val = !!(data->open_reg & BIT(channel + 7));
|
||||||
unlock:
|
|
||||||
mutex_unlock(&data->update_lock);
|
|
||||||
break;
|
break;
|
||||||
case hwmon_temp_max_hyst:
|
case hwmon_temp_max_hyst:
|
||||||
regs[0] = TMP464_THERM_LIMIT[channel];
|
regs[0] = TMP464_THERM_LIMIT[channel];
|
||||||
|
|
@ -345,8 +340,6 @@ static int tmp464_write(struct device *dev, enum hwmon_sensor_types type,
|
||||||
struct tmp464_data *data = dev_get_drvdata(dev);
|
struct tmp464_data *data = dev_get_drvdata(dev);
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
mutex_lock(&data->update_lock);
|
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case hwmon_chip:
|
case hwmon_chip:
|
||||||
err = tmp464_chip_write(data, attr, channel, val);
|
err = tmp464_chip_write(data, attr, channel, val);
|
||||||
|
|
@ -359,8 +352,6 @@ static int tmp464_write(struct device *dev, enum hwmon_sensor_types type,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_unlock(&data->update_lock);
|
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -658,8 +649,6 @@ static int tmp464_probe(struct i2c_client *client)
|
||||||
if (!data)
|
if (!data)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
mutex_init(&data->update_lock);
|
|
||||||
|
|
||||||
data->channels = (int)(unsigned long)i2c_get_match_data(client);
|
data->channels = (int)(unsigned long)i2c_get_match_data(client);
|
||||||
|
|
||||||
data->regmap = devm_regmap_init_i2c(client, &tmp464_regmap_config);
|
data->regmap = devm_regmap_init_i2c(client, &tmp464_regmap_config);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue