hwmon: (lochnagar-hwmon) 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
parent
00148a0a23
commit
bf9a27c86e
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
#include <linux/hwmon.h>
|
#include <linux/hwmon.h>
|
||||||
#include <linux/hwmon-sysfs.h>
|
|
||||||
#include <linux/math64.h>
|
#include <linux/math64.h>
|
||||||
#include <linux/mfd/lochnagar.h>
|
#include <linux/mfd/lochnagar.h>
|
||||||
#include <linux/mfd/lochnagar2_regs.h>
|
#include <linux/mfd/lochnagar2_regs.h>
|
||||||
|
|
@ -42,9 +41,6 @@ struct lochnagar_hwmon {
|
||||||
struct regmap *regmap;
|
struct regmap *regmap;
|
||||||
|
|
||||||
long power_nsamples[ARRAY_SIZE(lochnagar_chan_names)];
|
long power_nsamples[ARRAY_SIZE(lochnagar_chan_names)];
|
||||||
|
|
||||||
/* Lock to ensure only a single sensor is read at a time */
|
|
||||||
struct mutex sensor_lock;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum lochnagar_measure_mode {
|
enum lochnagar_measure_mode {
|
||||||
|
|
@ -178,26 +174,20 @@ static int read_sensor(struct device *dev, int chan,
|
||||||
u32 data;
|
u32 data;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
mutex_lock(&priv->sensor_lock);
|
|
||||||
|
|
||||||
ret = do_measurement(regmap, chan, mode, nsamples);
|
ret = do_measurement(regmap, chan, mode, nsamples);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(dev, "Failed to perform measurement: %d\n", ret);
|
dev_err(dev, "Failed to perform measurement: %d\n", ret);
|
||||||
goto error;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = request_data(regmap, chan, &data);
|
ret = request_data(regmap, chan, &data);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(dev, "Failed to read measurement: %d\n", ret);
|
dev_err(dev, "Failed to read measurement: %d\n", ret);
|
||||||
goto error;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
*val = float_to_long(data, precision);
|
*val = float_to_long(data, precision);
|
||||||
|
return 0;
|
||||||
error:
|
|
||||||
mutex_unlock(&priv->sensor_lock);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int read_power(struct device *dev, int chan, long *val)
|
static int read_power(struct device *dev, int chan, long *val)
|
||||||
|
|
@ -378,8 +368,6 @@ static int lochnagar_hwmon_probe(struct platform_device *pdev)
|
||||||
if (!priv)
|
if (!priv)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
mutex_init(&priv->sensor_lock);
|
|
||||||
|
|
||||||
priv->regmap = dev_get_regmap(dev->parent, NULL);
|
priv->regmap = dev_get_regmap(dev->parent, NULL);
|
||||||
if (!priv->regmap) {
|
if (!priv->regmap) {
|
||||||
dev_err(dev, "No register map found\n");
|
dev_err(dev, "No register map found\n");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue