]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commit
hwmon: (ina3221) Fix negative limits
authorGuenter Roeck <linux@roeck-us.net>
Sat, 25 Jun 2016 02:41:57 +0000 (19:41 -0700)
committerGuenter Roeck <linux@roeck-us.net>
Tue, 28 Jun 2016 01:58:04 +0000 (18:58 -0700)
commit9ad0df1adac20d694fbb8e7cb7bac04e0645a927
tree49f518ce469dd8fc3636d65ffccd28899741c098
parent51b8c2cd92f1b59657a13339dffcca79c76126d1
hwmon: (ina3221) Fix negative limits

The result of an integer divide by an unsigned is undefined.
This causes unexpected results when writing negative values
into the limit registers.

Maintain the shunt_resistors variables as signed integer to avoid
the problem. Also, for simplicity and ease of use, clamp shunt
resistor value on writes instead of rejecting bad values.

Cc: Andrew F. Davis <afd@ti.com>
Acked-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/ina3221.c