Skip to contentSkip to conversation

hwmon: (nct6775) mask out bank number in nct6775_wmi_read_value()

PATCH Applied Zev Weiss 3 participants 3 messages Nov 11, 2021 – Nov 14, 2021 Hardware monitoring

lore
Share & tools
lore

Zev Weiss

author
#0 lore raw

PATCH 1/1 hwmon: (nct6775) mask out bank number in nct6775_wmi_read_value()

The first call to nct6775_asuswmi_read() in nct6775_wmi_read_value() had been passing the full bank+register number instead of just the lower 8 bits. It didn't end up actually causing problems because the second argument of that function is a u8 anyway, but it seems preferable to be explicit about it at the call site (and consistent with the rest of the code).

Fixes 3fbbfc27f955 ("hwmon: (nct6775) Support access via Asus WMI")
---
 drivers/hwmon/nct6775.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/nct6775.c +1 -1
index 93dca471972e..57ce8633a725 100644
@@ -1527,7 +1527,7 @@ static u16 nct6775_wmi_read_value(struct nct6775_data *data, u16 reg)
 
 	nct6775_wmi_set_bank(data, reg);
 
-	err = nct6775_asuswmi_read(data->bank, reg, &tmp);
+	err = nct6775_asuswmi_read(data->bank, reg & 0xff, &tmp);
 	if (err)
 		return 0;
 
Signature · 1 line
2.33.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Zev Weiss

The first call to nct6775_asuswmi_read() in nct6775_wmi_read_value() had been passing the full bank+register number instead of just the lower 8 bits.

It didn't end up actually causing problems because the
second argument of that function is a u8 anyway,

It contradicts the existence of the Fixes tag below. What do you fix then?

Quoted 3 lines

but it seems
preferable to be explicit about it at the call site (and consistent with the rest of the code).

Yeah, in the current state it makes sense.

Later one may refactor this to drop that tons of ' & 0xff':s.

Quoted 21 lines
Fixes 3fbbfc27f955 ("hwmon: (nct6775) Support access via Asus WMI")
---
 drivers/hwmon/nct6775.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/nct6775.c +1 -1
index 93dca471972e..57ce8633a725 100644
@@ -1527,7 +1527,7 @@ static u16 nct6775_wmi_read_value(struct nct6775_data *data, u16 reg)
 
        nct6775_wmi_set_bank(data, reg);
 
-       err = nct6775_asuswmi_read(data->bank, reg, &tmp);
+       err = nct6775_asuswmi_read(data->bank, reg & 0xff, &tmp);
        if (err)
                return 0;
 

2.33.1

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer Applied
#2 lore raw
In reply to Zev Weiss
Quoted 10 lines · Zev Weiss

The first call to nct6775_asuswmi_read() in nct6775_wmi_read_value() had been passing the full bank+register number instead of just the lower 8 bits. It didn't end up actually causing problems because the second argument of that function is a u8 anyway, but it seems preferable to be explicit about it at the call site (and consistent with the rest of the code).

Fixes 3fbbfc27f955 ("hwmon: (nct6775) Support access via Asus WMI")

Applied.

Thanks,
Guenter

Quoted 17 lines
---
 drivers/hwmon/nct6775.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/nct6775.c +1 -1
index 93dca471972e..57ce8633a725 100644
@@ -1527,7 +1527,7 @@ static u16 nct6775_wmi_read_value(struct nct6775_data *data, u16 reg)
 
 	nct6775_wmi_set_bank(data, reg);
 
-	err = nct6775_asuswmi_read(data->bank, reg, &tmp);
+	err = nct6775_asuswmi_read(data->bank, reg & 0xff, &tmp);
 	if (err)
 		return 0;