mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] platform/x86: lenovo-wmi-{capdata,other}: Fix HWMON channel visibility
@ 2026-02-07 17:23 Rong Zhang
  2026-02-10 15:23 ` Ilpo Järvinen
  0 siblings, 1 reply; 2+ messages in thread
From: Rong Zhang @ 2026-02-07 17:23 UTC (permalink / raw)
  To: Mark Pearson, Derek J. Clark, Armin Wolf, Hans de Goede,
	Ilpo Järvinen
  Cc: Rong Zhang, Guenter Roeck, platform-driver-x86, linux-kernel,
	linux-hwmon

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>
---
 drivers/platform/x86/lenovo/wmi-capdata.h | 4 ++--
 drivers/platform/x86/lenovo/wmi-other.c   | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/x86/lenovo/wmi-capdata.h b/drivers/platform/x86/lenovo/wmi-capdata.h
index 59ca3b3e5760b..8c1df3efcc553 100644
--- a/drivers/platform/x86/lenovo/wmi-capdata.h
+++ b/drivers/platform/x86/lenovo/wmi-capdata.h
@@ -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)
diff --git a/drivers/platform/x86/lenovo/wmi-other.c b/drivers/platform/x86/lenovo/wmi-other.c
index 2a9ede27e13d4..6040f45aa2b0d 100644
--- a/drivers/platform/x86/lenovo/wmi-other.c
+++ b/drivers/platform/x86/lenovo/wmi-other.c
@@ -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;

base-commit: eeeb4c9874bb7ad11d322156443b1d3ebfaaa1cf
-- 
2.51.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] platform/x86: lenovo-wmi-{capdata,other}: Fix HWMON channel visibility
  2026-02-07 17:23 [PATCH] platform/x86: lenovo-wmi-{capdata,other}: Fix HWMON channel visibility Rong Zhang
@ 2026-02-10 15:23 ` Ilpo Järvinen
  0 siblings, 0 replies; 2+ messages in thread
From: Ilpo Järvinen @ 2026-02-10 15:23 UTC (permalink / raw)
  To: Mark Pearson, Derek J. Clark, Armin Wolf, Hans de Goede, Rong Zhang
  Cc: Guenter Roeck, platform-driver-x86, linux-kernel, linux-hwmon

On Sun, 08 Feb 2026 01:23:27 +0800, Rong Zhang wrote:

> 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.
> 
> [...]


Thank you for your contribution, it has been applied to my local
review-ilpo-next branch. Note it will show up in the public
platform-drivers-x86/review-ilpo-next branch only once I've pushed my
local branch there, which might take a while.

The list of commits applied:
[1/1] platform/x86: lenovo-wmi-{capdata,other}: Fix HWMON channel visibility
      commit: 5a5203a45b063a594e89a2aeaf9e4923893a5b4c

--
 i.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-02-10 15:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-07 17:23 [PATCH] platform/x86: lenovo-wmi-{capdata,other}: Fix HWMON channel visibility Rong Zhang
2026-02-10 15:23 ` Ilpo Järvinen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®