]> git.baikalelectronics.ru Git - 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)
commitc43ee5c76736ee0295f21f58e8d33a9de6d6e920
tree49f518ce469dd8fc3636d65ffccd28899741c098
parent0b77bc072ba7b3f151711b68846d2e638da2f400
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