Skip to content

Commit b8d27d2

Browse files
Ninad Malwadegroeck
authored andcommitted
hwmon: (ina3221) Fix shunt sum critical calculation
The shunt sum critical limit register value should be left shifted by one bit as its LSB-0 is a reserved bit. Fixes: 2057bdf ("hwmon: (ina3221) Add summation feature support") Signed-off-by: Ninad Malwade <[email protected]> Reviewed-by: Thierry Reding <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]>
1 parent 07e0619 commit b8d27d2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/hwmon/ina3221.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ static int ina3221_read_value(struct ina3221_data *ina, unsigned int reg,
228228
* Shunt Voltage Sum register has 14-bit value with 1-bit shift
229229
* Other Shunt Voltage registers have 12 bits with 3-bit shift
230230
*/
231-
if (reg == INA3221_SHUNT_SUM)
231+
if (reg == INA3221_SHUNT_SUM || reg == INA3221_CRIT_SUM)
232232
*val = sign_extend32(regval >> 1, 14);
233233
else
234234
*val = sign_extend32(regval >> 3, 12);
@@ -465,7 +465,7 @@ static int ina3221_write_curr(struct device *dev, u32 attr,
465465
* SHUNT_SUM: (1 / 40uV) << 1 = 1 / 20uV
466466
* SHUNT[1-3]: (1 / 40uV) << 3 = 1 / 5uV
467467
*/
468-
if (reg == INA3221_SHUNT_SUM)
468+
if (reg == INA3221_SHUNT_SUM || reg == INA3221_CRIT_SUM)
469469
regval = DIV_ROUND_CLOSEST(voltage_uv, 20) & 0xfffe;
470470
else
471471
regval = DIV_ROUND_CLOSEST(voltage_uv, 5) & 0xfff8;

0 commit comments

Comments
 (0)