aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/gl518sm.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/drivers/hwmon/gl518sm.c b/drivers/hwmon/gl518sm.c
index 535ad8776a68..c5255118bc16 100644
--- a/drivers/hwmon/gl518sm.c
+++ b/drivers/hwmon/gl518sm.c
@@ -107,7 +107,6 @@ static inline u8 FAN_TO_REG(long rpm, int div)
107#define VDD_TO_REG(val) (SENSORS_LIMIT((((val)*4+47)/95),0,255)) 107#define VDD_TO_REG(val) (SENSORS_LIMIT((((val)*4+47)/95),0,255))
108#define VDD_FROM_REG(val) (((val)*95+2)/4) 108#define VDD_FROM_REG(val) (((val)*95+2)/4)
109 109
110#define DIV_TO_REG(val) ((val)==4?2:(val)==2?1:(val)==1?0:3)
111#define DIV_FROM_REG(val) (1 << (val)) 110#define DIV_FROM_REG(val) (1 << (val))
112 111
113#define BEEP_MASK_TO_REG(val) ((val) & 0x7f & data->alarm_mask) 112#define BEEP_MASK_TO_REG(val) ((val) & 0x7f & data->alarm_mask)
@@ -302,9 +301,20 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
302 int regvalue; 301 int regvalue;
303 unsigned long val = simple_strtoul(buf, NULL, 10); 302 unsigned long val = simple_strtoul(buf, NULL, 10);
304 303
304 switch (val) {
305 case 1: val = 0; break;
306 case 2: val = 1; break;
307 case 4: val = 2; break;
308 case 8: val = 3; break;
309 default:
310 dev_err(dev, "Invalid fan clock divider %lu, choose one "
311 "of 1, 2, 4 or 8\n", val);
312 return -EINVAL;
313 }
314
305 mutex_lock(&data->update_lock); 315 mutex_lock(&data->update_lock);
306 regvalue = gl518_read_value(client, GL518_REG_MISC); 316 regvalue = gl518_read_value(client, GL518_REG_MISC);
307 data->fan_div[nr] = DIV_TO_REG(val); 317 data->fan_div[nr] = val;
308 regvalue = (regvalue & ~(0xc0 >> (2 * nr))) 318 regvalue = (regvalue & ~(0xc0 >> (2 * nr)))
309 | (data->fan_div[nr] << (6 - 2 * nr)); 319 | (data->fan_div[nr] << (6 - 2 * nr));
310 gl518_write_value(client, GL518_REG_MISC, regvalue); 320 gl518_write_value(client, GL518_REG_MISC, regvalue);