aboutsummaryrefslogtreecommitdiff
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorGuenter Roeck2019-08-08 14:30:23 -0700
committerGuenter Roeck2019-09-03 12:47:17 -0700
commit040b106ff8d6dcef5704f96ea84edfe28addb4a0 (patch)
tree01ef84a75502ee0f3c74f53e38aa31cb48ad2cba /drivers/hwmon
parent7db0db3f6cced88af881520dd993c5b0044a7760 (diff)
hwmon: (lm75) Move updating the sample interval to its own function
We'll need per-chip handling for updating the sample interval. To prepare for it, separate the code implementing it into its own function. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/lm75.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c
index 6474b8f21981..644da2620a26 100644
--- a/drivers/hwmon/lm75.c
+++ b/drivers/hwmon/lm75.c
@@ -388,27 +388,32 @@ static int lm75_write_temp(struct device *dev, u32 attr, long temp)
return regmap_write(data->regmap, reg, (u16)temp);
}
-static int lm75_write_chip(struct device *dev, u32 attr, long val)
+static int lm75_update_interval(struct device *dev, long val)
{
struct lm75_data *data = dev_get_drvdata(dev);
u8 index;
s32 err;
- switch (attr) {
- case hwmon_chip_update_interval:
- index = find_closest(val, data->params->sample_times,
- (int)data->params->num_sample_times);
+ index = find_closest(val, data->params->sample_times,
+ (int)data->params->num_sample_times);
- err = lm75_write_config(data,
- lm75_sample_set_masks[index],
- LM75_SAMPLE_CLEAR_MASK);
- if (err)
- return err;
- data->sample_time = data->params->sample_times[index];
+ err = lm75_write_config(data, lm75_sample_set_masks[index],
+ LM75_SAMPLE_CLEAR_MASK);
+ if (err)
+ return err;
- if (data->params->resolutions)
- data->resolution = data->params->resolutions[index];
- break;
+ data->sample_time = data->params->sample_times[index];
+ if (data->params->resolutions)
+ data->resolution = data->params->resolutions[index];
+
+ return 0;
+}
+
+static int lm75_write_chip(struct device *dev, u32 attr, long val)
+{
+ switch (attr) {
+ case hwmon_chip_update_interval:
+ return lm75_update_interval(dev, val);
default:
return -EINVAL;
}