Skip to content

Commit 98fd069

Browse files
cpackham-atlnzgroeck
authored andcommitted
hwmon: (ina238) Correctly clamp temperature
ina238_write_temp() was attempting to clamp the user input but was throwing away the result. Ensure that we clamp the value to the appropriate range before it is converted into a register value. Fixes: 0d9f596 ("hwmon: (ina238) Modify the calculation formula to adapt to different chips") Signed-off-by: Chris Packham <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]>
1 parent 1180c79 commit 98fd069

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/hwmon/ina238.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ static int ina238_write_temp(struct device *dev, u32 attr, long val)
572572
return -EOPNOTSUPP;
573573

574574
/* Signed */
575-
regval = clamp_val(val, -40000, 125000);
575+
val = clamp_val(val, -40000, 125000);
576576
regval = div_s64(val * 10000, data->config->temp_lsb) << data->config->temp_shift;
577577
regval = clamp_val(regval, S16_MIN, S16_MAX) & (0xffff << data->config->temp_shift);
578578

0 commit comments

Comments
 (0)