summaryrefslogtreecommitdiff
path: root/drivers/hwmon/max31790.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/max31790.c')
-rw-r--r--drivers/hwmon/max31790.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/hwmon/max31790.c b/drivers/hwmon/max31790.c
index 3dc95196b229..7aa1aa63bf1b 100644
--- a/drivers/hwmon/max31790.c
+++ b/drivers/hwmon/max31790.c
@@ -49,6 +49,9 @@
#define NR_CHANNEL 6
+#define PWM_INPUT_SCALE 255
+#define MAX31790_REG_PWMOUT_SCALE 511
+
/*
* Client data (each client gets its own)
*/
@@ -343,10 +346,13 @@ static int max31790_write_pwm(struct device *dev, u32 attr, int channel,
err = -EINVAL;
break;
}
+
+ val = DIV_ROUND_CLOSEST(val * MAX31790_REG_PWMOUT_SCALE,
+ PWM_INPUT_SCALE);
data->valid = false;
err = i2c_smbus_write_word_swapped(client,
MAX31790_REG_PWMOUT(channel),
- val << 8);
+ val << 7);
break;
case hwmon_pwm_enable:
fan_config = data->fan_config[channel];