hwmon: (lm95241) Fix overflow problems, write conversion rate to chip
authorGuenter Roeck <linux@roeck-us.net>
Mon, 4 Jul 2016 04:46:05 +0000 (21:46 -0700)
committerGuenter Roeck <linux@roeck-us.net>
Fri, 9 Sep 2016 04:34:14 +0000 (21:34 -0700)
commitf48ccb26e264b112afc087d562fa2d68e2e1174b
tree74deb39ffaeb6ec549501cc0d4f0910e42a7d056
parentc6935931c1894ff857616ff8549b61236a19148f
hwmon: (lm95241) Fix overflow problems, write conversion rate to chip

Writing the update_interval attribute could result in an overflow if
a number close to the maximum unsigned long was written. At the same
time, even though the chip supports setting the conversion rate,
the selected conversion rate was not actually written to the chip.

Fix the second problem by selecting valid (supported) conversion rates,
and writing the selected conversion rate to the chip. This also fixes the
first problem, since arbitrary conversion rates are now converted to
actually supported conversion rates.

Also, set the default chip conversion rate to 1 second. Previously, the
chip was configured for continuous conversion, but readings were only
retrieved every seond, which doesn't make much sense. If we only read a
value from the chip every second, we can as well save some power and only
convert in one-second intervals.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/lm95241.c