• Guenter Roeck's avatar
    hwmon: (adm1031) Fix writes to limit registers · a5931b2e
    Guenter Roeck authored
    commit 145e74a4 upstream.
    
    Upper limit for write operations to temperature limit registers
    was clamped to a fractional value. However, limit registers do
    not support fractional values. As a result, upper limits of 127.5
    degrees C or higher resulted in a rounded limit of 128 degrees C.
    Since limit registers are signed, this was stored as -128 degrees C.
    Clamp limits to (-55, +127) degrees C to solve the problem.
    
    Value on writes to auto_temp[12]_min and auto_temp[12]_max were not
    clamped at all, but masked. As a result, out-of-range writes resulted
    in a more or less arbitrary limit. Clamp those attributes to (0, 127)
    degrees C for more predictable results.
    
    Cc: Axel Lin <axel.lin@ingics.com>
    Reviewed-by: default avatarJean Delvare <jdelvare@suse.de>
    Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
    [bwh: Backported to 3.2:
     - Adjust context
     - Driver was using SENSORS_LIMIT(), which we can replace with clamp_val()]
    Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
    a5931b2e
adm1031.c 33.7 KB