Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>
Link: https://patch.msgid.link/20260207172327.80111-1-i@rong.moe
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

authored by

Rong Zhang and committed by
Ilpo Järvinen
5a5203a4 eeeb4c98

+4 -4
+2 -2
drivers/platform/x86/lenovo/wmi-capdata.h
··· 9 9 #include <linux/types.h> 10 10 11 11 #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) 14 14 15 15 #define LWMI_ATTR_DEV_ID_MASK GENMASK(31, 24) 16 16 #define LWMI_ATTR_FEAT_ID_MASK GENMASK(23, 16)
+2 -2
drivers/platform/x86/lenovo/wmi-other.c
··· 216 216 217 217 switch (attr) { 218 218 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)) 220 220 return 0; 221 221 222 222 if (relax_fan_constraint || ··· 233 233 return 0; 234 234 case hwmon_fan_div: 235 235 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; 237 237 break; 238 238 case hwmon_fan_min: 239 239 visible = priv->fan_info[channel].min_rpm >= 0;