diff mbox

hwmon: (w83773g) Fix a precedence bug in get_fault()

Message ID 20171205143726.d3tziwhjboyfxmgi@mwanda (mailing list archive)
State Not Applicable
Headers show

Commit Message

Dan Carpenter Dec. 5, 2017, 2:37 p.m. UTC
Shift has higher precedence than mask but presumably we wanted to set
*val to 1 if BIT(2) was set or 0 if the bit was clear.

Fixes: de0a524e3e09 ("hwmon: Add W83773G driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

--
To unsubscribe from this list: send the line "unsubscribe linux-hwmon" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Guenter Roeck Dec. 5, 2017, 4:17 p.m. UTC | #1
On Tue, Dec 05, 2017 at 05:37:26PM +0300, Dan Carpenter wrote:
> Shift has higher precedence than mask but presumably we wanted to set
> *val to 1 if BIT(2) was set or 0 if the bit was clear.
> 
> Fixes: de0a524e3e09 ("hwmon: Add W83773G driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Hi Dan,

I already queued up the fix after my own builders reported the problem.

Thanks,
Guenter
--
To unsubscribe from this list: send the line "unsubscribe linux-hwmon" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/hwmon/w83773g.c b/drivers/hwmon/w83773g.c
index 0b97c285b049..e858093ac806 100644
--- a/drivers/hwmon/w83773g.c
+++ b/drivers/hwmon/w83773g.c
@@ -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;
 }