]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
platform/x86: lenovo-wmi-{capdata,other}: Fix HWMON channel visibility
authorRong Zhang <i@rong.moe>
Sat, 7 Feb 2026 17:23:27 +0000 (01:23 +0800)
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Tue, 10 Feb 2026 15:22:40 +0000 (17:22 +0200)
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>
drivers/platform/x86/lenovo/wmi-capdata.h
drivers/platform/x86/lenovo/wmi-other.c

index 59ca3b3e5760be9c4268d19a13922e0bf3ff0889..8c1df3efcc5533db9c8d7da736792e4b6a47c54c 100644 (file)
@@ -9,8 +9,8 @@
 #include <linux/types.h>
 
 #define LWMI_SUPP_VALID                BIT(0)
-#define LWMI_SUPP_MAY_GET      (LWMI_SUPP_VALID | BIT(1))
-#define LWMI_SUPP_MAY_SET      (LWMI_SUPP_VALID | BIT(2))
+#define LWMI_SUPP_GET          BIT(1)
+#define LWMI_SUPP_SET          BIT(2)
 
 #define LWMI_ATTR_DEV_ID_MASK  GENMASK(31, 24)
 #define LWMI_ATTR_FEAT_ID_MASK GENMASK(23, 16)
index 2a9ede27e13d4a71326a9a9c69f66e004d72b875..6040f45aa2b0d63696af8520ca9653d52cb4cc1e 100644 (file)
@@ -216,7 +216,7 @@ static umode_t lwmi_om_hwmon_is_visible(const void *drvdata, enum hwmon_sensor_t
 
                switch (attr) {
                case hwmon_fan_target:
-                       if (!(priv->fan_info[channel].supported & LWMI_SUPP_MAY_SET))
+                       if (!(priv->fan_info[channel].supported & LWMI_SUPP_SET))
                                return 0;
 
                        if (relax_fan_constraint ||
@@ -233,7 +233,7 @@ static umode_t lwmi_om_hwmon_is_visible(const void *drvdata, enum hwmon_sensor_t
                        return 0;
                case hwmon_fan_div:
                case hwmon_fan_input:
-                       visible = priv->fan_info[channel].supported & LWMI_SUPP_MAY_GET;
+                       visible = priv->fan_info[channel].supported & LWMI_SUPP_GET;
                        break;
                case hwmon_fan_min:
                        visible = priv->fan_info[channel].min_rpm >= 0;