diff options
author | Guenter Roeck <linux@roeck-us.net> | 2024-07-09 16:16:43 +0200 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2024-07-31 19:43:51 +0200 |
commit | 381cfd63050ba601326f89519dff3114f894f590 (patch) | |
tree | 7faba1a93d715150c4a0dbe9b2222dac921d532f /drivers/hwmon/adt7470.c | |
parent | Linux 6.11-rc1 (diff) | |
download | linux-381cfd63050ba601326f89519dff3114f894f590.tar.xz linux-381cfd63050ba601326f89519dff3114f894f590.zip |
hwmon: (adt7470) 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>
Diffstat (limited to 'drivers/hwmon/adt7470.c')
-rw-r--r-- | drivers/hwmon/adt7470.c | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/drivers/hwmon/adt7470.c b/drivers/hwmon/adt7470.c index 517248d2994e..dbee6926fa05 100644 --- a/drivers/hwmon/adt7470.c +++ b/drivers/hwmon/adt7470.c @@ -728,30 +728,22 @@ static const int adt7470_freq_map[] = { static int pwm1_freq_get(struct device *dev) { struct adt7470_data *data = dev_get_drvdata(dev); - unsigned int cfg_reg_1, cfg_reg_2; + unsigned int regs[2] = {ADT7470_REG_CFG, ADT7470_REG_CFG_2}; + u8 cfg_reg[2]; int index; int err; - mutex_lock(&data->lock); - err = regmap_read(data->regmap, ADT7470_REG_CFG, &cfg_reg_1); - if (err < 0) - goto out; - err = regmap_read(data->regmap, ADT7470_REG_CFG_2, &cfg_reg_2); - if (err < 0) - goto out; - mutex_unlock(&data->lock); + err = regmap_multi_reg_read(data->regmap, regs, cfg_reg, 2); + if (err) + return err; - index = (cfg_reg_2 & ADT7470_FREQ_MASK) >> ADT7470_FREQ_SHIFT; - if (!(cfg_reg_1 & ADT7470_CFG_LF)) + index = (cfg_reg[1] & ADT7470_FREQ_MASK) >> ADT7470_FREQ_SHIFT; + if (!(cfg_reg[0] & ADT7470_CFG_LF)) index += 8; if (index >= ARRAY_SIZE(adt7470_freq_map)) index = ARRAY_SIZE(adt7470_freq_map) - 1; return adt7470_freq_map[index]; - -out: - mutex_unlock(&data->lock); - return err; } static int adt7470_pwm_read(struct device *dev, u32 attr, int channel, long *val) |