Skip to content
  • Guenter Roeck's avatar
    9ad0df1a
    hwmon: (ina3221) Fix negative limits · 9ad0df1a
    Guenter Roeck authored
    
    
    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: default avatarAndrew F. Davis <afd@ti.com>
    Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
    9ad0df1a
    hwmon: (ina3221) Fix negative limits
    Guenter Roeck authored
    
    
    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: default avatarAndrew F. Davis <afd@ti.com>
    Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
Loading