Commit a6d80df4 authored by Tim Harvey's avatar Tim Harvey Committed by Guenter Roeck

hwmon: (gsc-hwmon) fix fan pwm temperature scaling

The GSC fan pwm temperature register is in centidegrees celcius but the
Linux hwmon convention is to use milidegrees celcius. Fix the scaling.

Fixes: 3bce5377 ("hwmon: Add Gateworks System Controller support")
Signed-off-by: default avatarTim Harvey <tharvey@gateworks.com>
Link: https://lore.kernel.org/r/20230606153004.1448086-1-tharvey@gateworks.comSigned-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent 0babf89c
...@@ -82,8 +82,8 @@ static ssize_t pwm_auto_point_temp_store(struct device *dev, ...@@ -82,8 +82,8 @@ static ssize_t pwm_auto_point_temp_store(struct device *dev,
if (kstrtol(buf, 10, &temp)) if (kstrtol(buf, 10, &temp))
return -EINVAL; return -EINVAL;
temp = clamp_val(temp, 0, 10000); temp = clamp_val(temp, 0, 100000);
temp = DIV_ROUND_CLOSEST(temp, 10); temp = DIV_ROUND_CLOSEST(temp, 100);
regs[0] = temp & 0xff; regs[0] = temp & 0xff;
regs[1] = (temp >> 8) & 0xff; regs[1] = (temp >> 8) & 0xff;
...@@ -100,7 +100,7 @@ static ssize_t pwm_auto_point_pwm_show(struct device *dev, ...@@ -100,7 +100,7 @@ static ssize_t pwm_auto_point_pwm_show(struct device *dev,
{ {
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
return sprintf(buf, "%d\n", 255 * (50 + (attr->index * 10)) / 100); return sprintf(buf, "%d\n", 255 * (50 + (attr->index * 10)));
} }
static SENSOR_DEVICE_ATTR_RO(pwm1_auto_point1_pwm, pwm_auto_point_pwm, 0); static SENSOR_DEVICE_ATTR_RO(pwm1_auto_point1_pwm, pwm_auto_point_pwm, 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment