Skip to contentSkip to conversation

hwmon: (w83773g) Fix fault detection and reporting

PATCH In review Guenter Roeck 2 participants 2 messages Dec 4, 2017 Hardware monitoring

lore
Share & tools
lore

Guenter Roeck

author maintainer
#0 lore raw

PATCH 1/1 hwmon: (w83773g) Fix fault detection and reporting

Smatch reports:

drivers/hwmon/w83773g.c:105
get_fault() warn: shift has higher precedence than mask

Code analysis shows that the code is indeed wrong. Fix it, and while we are at it, drop unnecessary typecast.

Fixes 86a10c802362 ("hwmon: Add W83773G driver")
Cc Lei YU <[email protected]>
---
 drivers/hwmon/w83773g.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/w83773g.c +1 -1
index 0b97c285b049..e858093ac806 100644
@@ -102,7 +102,7 @@ static int get_fault(struct regmap *regmap, int index, long *val)
 	if (ret < 0)
 		return ret;
 
-	*val = (u8)regval & 0x04 >> 2;
+	*val = (regval & 0x04) >> 2;
 	return 0;
 }
 
Signature · 1 line
2.7.4
Reviewed-by on v1 1/1
#1 lore raw

Thanks for catching this.

Quoted 31 lines · Guenter Roeck

Smatch reports:

drivers/hwmon/w83773g.c:105
get_fault() warn: shift has higher precedence than mask

Code analysis shows that the code is indeed wrong. Fix it, and while we are at it, drop unnecessary typecast.

Fixes 86a10c802362 ("hwmon: Add W83773G driver")
Cc Lei YU <[email protected]>
---
 drivers/hwmon/w83773g.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/w83773g.c +1 -2
index 0b97c285b049..e858093ac806 100644
@@ -102,7 +102,7 @@ static int get_fault(struct regmap *regmap, int index, long *val)
        if (ret < 0)
                return ret;
 
-       *val = (u8)regval & 0x04 >> 2;
+       *val = (regval & 0x04) >> 2;
        return 0;
 }
 
--

2.7.4