Skip to content

Commit 8940560

Browse files
Rongronggg9pastaq
authored andcommitted
[FROM-UPSTREAM] platform/x86: lenovo-wmi-{capdata,other}: Fix HWMON channel visibility
The LWMI_SUPP_MAY_{GET,SET} macros are fundamentally broken. When I introduced them, I meant to check LWMI_SUPP_VALID *and* the corresponding bits for get/set capabilities. However, `supported & LWMI_SUPP_MAY_{GET,SET}' means *or*, so it accidentally passes the check when LWMI_SUPP_VALID is set. Fix them by only including the corresponding get/set bit without LWMI_SUPP_VALID. Meanwhile, rename them to LWMI_SUPP_{GET,SET} to make them less confusing. Fixes: 67d9a39ce85f ("platform/x86: lenovo-wmi-capdata: Wire up Fan Test Data") Signed-off-by: Rong Zhang <i@rong.moe> Signed-off-by: Derek J. Clark <derekjohn.clark@gmail.com>
1 parent 4a6a93a commit 8940560

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

drivers/platform/x86/lenovo/wmi-capdata.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
#include <linux/types.h>
1010

1111
#define LWMI_SUPP_VALID BIT(0)
12-
#define LWMI_SUPP_MAY_GET (LWMI_SUPP_VALID | BIT(1))
13-
#define LWMI_SUPP_MAY_SET (LWMI_SUPP_VALID | BIT(2))
12+
#define LWMI_SUPP_GET BIT(1)
13+
#define LWMI_SUPP_SET BIT(2)
1414

1515
#define LWMI_ATTR_DEV_ID_MASK GENMASK(31, 24)
1616
#define LWMI_ATTR_FEAT_ID_MASK GENMASK(23, 16)

drivers/platform/x86/lenovo/wmi-other.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ static umode_t lwmi_om_hwmon_is_visible(const void *drvdata, enum hwmon_sensor_t
216216

217217
switch (attr) {
218218
case hwmon_fan_target:
219-
if (!(priv->fan_info[channel].supported & LWMI_SUPP_MAY_SET))
219+
if (!(priv->fan_info[channel].supported & LWMI_SUPP_SET))
220220
return 0;
221221

222222
if (relax_fan_constraint ||
@@ -233,7 +233,7 @@ static umode_t lwmi_om_hwmon_is_visible(const void *drvdata, enum hwmon_sensor_t
233233
return 0;
234234
case hwmon_fan_div:
235235
case hwmon_fan_input:
236-
visible = priv->fan_info[channel].supported & LWMI_SUPP_MAY_GET;
236+
visible = priv->fan_info[channel].supported & LWMI_SUPP_GET;
237237
break;
238238
case hwmon_fan_min:
239239
visible = priv->fan_info[channel].min_rpm >= 0;

0 commit comments

Comments
 (0)