hwmon: (tmp401) Use multi-byte regmap operations
Use multi-byte regmap operations where possible to reduce code size and the need for mutex protection. No functional change. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
parent
381cfd6305
commit
a0a16d960f
@ -308,7 +308,9 @@ static int tmp401_temp_read(struct device *dev, u32 attr, int channel, long *val
|
|||||||
{
|
{
|
||||||
struct tmp401_data *data = dev_get_drvdata(dev);
|
struct tmp401_data *data = dev_get_drvdata(dev);
|
||||||
struct regmap *regmap = data->regmap;
|
struct regmap *regmap = data->regmap;
|
||||||
|
unsigned int regs[2] = { TMP401_TEMP_MSB[3][channel], TMP401_TEMP_CRIT_HYST };
|
||||||
unsigned int regval;
|
unsigned int regval;
|
||||||
|
u16 regvals[2];
|
||||||
int reg, ret;
|
int reg, ret;
|
||||||
|
|
||||||
switch (attr) {
|
switch (attr) {
|
||||||
@ -325,20 +327,11 @@ static int tmp401_temp_read(struct device *dev, u32 attr, int channel, long *val
|
|||||||
*val = tmp401_register_to_temp(regval, data->extended_range);
|
*val = tmp401_register_to_temp(regval, data->extended_range);
|
||||||
break;
|
break;
|
||||||
case hwmon_temp_crit_hyst:
|
case hwmon_temp_crit_hyst:
|
||||||
mutex_lock(&data->update_lock);
|
ret = regmap_multi_reg_read(regmap, regs, regvals, 2);
|
||||||
reg = TMP401_TEMP_MSB[3][channel];
|
|
||||||
ret = regmap_read(regmap, reg, ®val);
|
|
||||||
if (ret < 0)
|
|
||||||
goto unlock;
|
|
||||||
*val = tmp401_register_to_temp(regval, data->extended_range);
|
|
||||||
ret = regmap_read(regmap, TMP401_TEMP_CRIT_HYST, ®val);
|
|
||||||
if (ret < 0)
|
|
||||||
goto unlock;
|
|
||||||
*val -= regval * 1000;
|
|
||||||
unlock:
|
|
||||||
mutex_unlock(&data->update_lock);
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
*val = tmp401_register_to_temp(regvals[0], data->extended_range) -
|
||||||
|
(regvals[1] * 1000);
|
||||||
break;
|
break;
|
||||||
case hwmon_temp_fault:
|
case hwmon_temp_fault:
|
||||||
case hwmon_temp_min_alarm:
|
case hwmon_temp_min_alarm:
|
||||||
|
Loading…
Reference in New Issue
Block a user