• Guenter Roeck's avatar
    hwmon: (lm95241) Fix overflow problems, write conversion rate to chip · f48ccb26
    Guenter Roeck authored
    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: default avatarGuenter Roeck <linux@roeck-us.net>
    f48ccb26
lm95241.c 11.9 KB