mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-16 02:14:58 +00:00
hwmon: (adt7x10) Use multi-byte regmap operations
Use multi-byte regmap operations where possible to reduce code size and the need for mutex protection. No functional changes. Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
parent
7b4882d9b8
commit
4ce612b16e
@ -170,21 +170,15 @@ static int adt7x10_temp_write(struct adt7x10_data *data, int index, long temp)
|
|||||||
|
|
||||||
static int adt7x10_hyst_read(struct adt7x10_data *data, int index, long *val)
|
static int adt7x10_hyst_read(struct adt7x10_data *data, int index, long *val)
|
||||||
{
|
{
|
||||||
int hyst, temp, ret;
|
unsigned int regs[2] = {ADT7X10_T_HYST, ADT7X10_REG_TEMP[index]};
|
||||||
|
int hyst, ret;
|
||||||
|
u16 regdata[2];
|
||||||
|
|
||||||
mutex_lock(&data->update_lock);
|
ret = regmap_multi_reg_read(data->regmap, regs, regdata, 2);
|
||||||
ret = regmap_read(data->regmap, ADT7X10_T_HYST, &hyst);
|
|
||||||
if (ret) {
|
|
||||||
mutex_unlock(&data->update_lock);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = regmap_read(data->regmap, ADT7X10_REG_TEMP[index], &temp);
|
|
||||||
mutex_unlock(&data->update_lock);
|
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
hyst = (hyst & ADT7X10_T_HYST_MASK) * 1000;
|
hyst = (regdata[0] & ADT7X10_T_HYST_MASK) * 1000;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* hysteresis is stored as a 4 bit offset in the device, convert it
|
* hysteresis is stored as a 4 bit offset in the device, convert it
|
||||||
@ -194,7 +188,7 @@ static int adt7x10_hyst_read(struct adt7x10_data *data, int index, long *val)
|
|||||||
if (index == adt7x10_t_alarm_low)
|
if (index == adt7x10_t_alarm_low)
|
||||||
hyst = -hyst;
|
hyst = -hyst;
|
||||||
|
|
||||||
*val = ADT7X10_REG_TO_TEMP(data, temp) - hyst;
|
*val = ADT7X10_REG_TO_TEMP(data, regdata[1]) - hyst;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user