Skip to contentSkip to conversation

platform/x86: asus-wmi: fix unclear usage of bd->props.power

PATCH In review Denis Benato 3 participants 4 messages Aug 19 – Sep 2

Subsystems (2)
lore
Share & tools
lore

Denis Benato

author maintainer
#0 lore raw

PATCH 1/1 platform/x86: asus-wmi: fix unclear usage of bd->props.power

The bd->props.power is checked in parts of the driver correctly comparing with BACKLIGHT_POWER_ON, while in others with a raw usage of bd->props.power and !bd->props.power, moreover in certain checks the logic has been inverted due to BACKLIGHT_POWER_ON being defined as 0: fix both the wrong usage and the inconsistencies by using proper comparisons.

Fixes 130d29c5627c ("platform/x86: asus-wmi: adjust screenpad power/brightness handling")
---
 drivers/platform/x86/asus-wmi.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/platform/x86/asus-wmi.c +9 -3
index 8610663b8269..3600dddd8f36 100644
@@ -4500,7 +4500,8 @@ static int update_screenpad_bl_status(struct backlight_device *bd)
 	u32 ctrl_param = bd->props.brightness;
 	int err = 0;
 
-	if (bd->props.power) {
+	switch (bd->props.power) {
+	case BACKLIGHT_POWER_ON:
 		err = asus_wmi_set_devstate(ASUS_WMI_DEVID_SCREENPAD_POWER, 1, NULL);
 		if (err < 0)
 			return err;
@@ -4508,12 +4509,17 @@ static int update_screenpad_bl_status(struct backlight_device *bd)
 		err = asus_wmi_set_devstate(ASUS_WMI_DEVID_SCREENPAD_LIGHT, ctrl_param, NULL);
 		if (err < 0)
 			return err;
-	}
+		break;
 
-	if (!bd->props.power) {
+	case BACKLIGHT_POWER_OFF:
 		err = asus_wmi_set_devstate(ASUS_WMI_DEVID_SCREENPAD_POWER, 0, NULL);
 		if (err < 0)
 			return err;
+		break;
+
+	default:
+		pr_warn("Invalid screenpad backlight power state: %d\n", bd->props.power);
+		return -EINVAL;
 	}
 
 	return err;
Signature · 1 line
2.47.3
author maintainer
#1 lore raw
Quoted 5 lines · Denis Benato

The bd->props.power is checked in parts of the driver correctly comparing with BACKLIGHT_POWER_ON, while in others with a raw usage of bd->props.power and !bd->props.power, moreover in certain checks the logic has been inverted due to BACKLIGHT_POWER_ON being defined as 0: fix both the wrong usage and the inconsistencies by using proper comparisons.

Can someone having the regression please try this out please?

Quoted 42 lines
Fixes 130d29c5627c ("platform/x86: asus-wmi: adjust screenpad power/brightness handling")
---
 drivers/platform/x86/asus-wmi.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/platform/x86/asus-wmi.c +9 -3
index 8610663b8269..3600dddd8f36 100644
@@ -4500,7 +4500,8 @@ static int update_screenpad_bl_status(struct backlight_device *bd)
 	u32 ctrl_param = bd->props.brightness;
 	int err = 0;
 
-	if (bd->props.power) {
+	switch (bd->props.power) {
+	case BACKLIGHT_POWER_ON:
 		err = asus_wmi_set_devstate(ASUS_WMI_DEVID_SCREENPAD_POWER, 1, NULL);
 		if (err < 0)
 			return err;
@@ -4508,12 +4509,17 @@ static int update_screenpad_bl_status(struct backlight_device *bd)
 		err = asus_wmi_set_devstate(ASUS_WMI_DEVID_SCREENPAD_LIGHT, ctrl_param, NULL);
 		if (err < 0)
 			return err;
-	}
+		break;
 
-	if (!bd->props.power) {
+	case BACKLIGHT_POWER_OFF:
 		err = asus_wmi_set_devstate(ASUS_WMI_DEVID_SCREENPAD_POWER, 0, NULL);
 		if (err < 0)
 			return err;
+		break;
+
+	default:
+		pr_warn("Invalid screenpad backlight power state: %d\n", bd->props.power);
+		return -EINVAL;
 	}
 
 	return err;
#2 lore raw

Hi,

I have applied your small patch, based on the diff you gave me, and the ASUS ScreenPad display has started working.

I'm not sure what commit I was supposed to patch though, so I guessed 9bd6ec. I had to patch it manually because the line numbers weren't matching, and you sent me the output of git diff directly instead of the contents of a git patch file.

The custom compiled kernel created couldn't handle the brightness correctly, only the power:

On KDE Plasma, changing the brightness is possible, but the maximum brightness was set to be darker than usual.

On both brightnessctl and sysfs, writing to the brightness value would change both brightness and actual_brightness, but no changes would appear on the backlight.

Booting to a disk image of pre-6.12.90 linux with XFCE has the same exact issues, but then after booting back to my normal 6.12.90 system, the maximum brightness came back to what it used to be.

I hope this heisenbug only happened because i simply patched the wrong commit.

Quoted 48 lines · Denis Benato
Quoted 5 lines · Denis Benato

The bd->props.power is checked in parts of the driver correctly comparing with BACKLIGHT_POWER_ON, while in others with a raw usage of bd->props.power and !bd->props.power, moreover in certain checks the logic has been inverted due to BACKLIGHT_POWER_ON being defined as 0: fix both the wrong usage and the inconsistencies by using proper comparisons.

Can someone having the regression please try this out please?

Quoted 41 lines
Fixes 130d29c5627c ("platform/x86: asus-wmi: adjust screenpad power/brightness handling")
---
  drivers/platform/x86/asus-wmi.c | 12 +++++++++---
  1 file changed, 9 insertions(+), 3 deletions(-)
drivers/platform/x86/asus-wmi.c +9 -3
index 8610663b8269..3600dddd8f36 100644
@@ -4500,7 +4500,8 @@ static int update_screenpad_bl_status(struct backlight_device *bd)
  	u32 ctrl_param = bd->props.brightness;
  	int err = 0;
 
-	if (bd->props.power) {
+	switch (bd->props.power) {
+	case BACKLIGHT_POWER_ON:
  		err = asus_wmi_set_devstate(ASUS_WMI_DEVID_SCREENPAD_POWER, 1, NULL);
  		if (err < 0)
  			return err;
@@ -4508,12 +4509,17 @@ static int update_screenpad_bl_status(struct backlight_device *bd)
  		err = asus_wmi_set_devstate(ASUS_WMI_DEVID_SCREENPAD_LIGHT, ctrl_param, NULL);
  		if (err < 0)
  			return err;
-	}
+		break;
 
-	if (!bd->props.power) {
+	case BACKLIGHT_POWER_OFF:
  		err = asus_wmi_set_devstate(ASUS_WMI_DEVID_SCREENPAD_POWER, 0, NULL);
  		if (err < 0)
  			return err;
+		break;
+
+	default:
+		pr_warn("Invalid screenpad backlight power state: %d\n", bd->props.power);
+		return -EINVAL;
  	}
 
Quoted 1 line

drivers/platform/x86/asus-wmi.c static int update_screenpad_bl_status(struct backlight_device *bd) · line 4525

Quoted 1 line
drivers/platform/x86/asus-wmi.c +0 -0
  	return err;

Regards,

Ponali

#3 lore raw

Il 25 agosto 2026 13:38:01 CEST, Ponali <[email protected]> ha scritto:

Quoted 9 lines

Hi,

I have applied your small patch, based on the diff you gave me, and the ASUS ScreenPad display has started working.

I'm not sure what commit I was supposed to patch though, so I guessed 9bd6ec. I had to patch it manually because the line numbers weren't matching, and you sent me the output of git diff directly instead of the contents of a git patch file.

Unsure, I don't think that was the output of git diff because I had a .patch file made with format-patch... Anyway... Unimportant.

Sorry for the delay: got dragged by other things.

Quoted 7 lines

The custom compiled kernel created couldn't handle the brightness correctly, only the power:

On KDE Plasma, changing the brightness is possible, but the maximum brightness was set to be darker than usual.

On both brightnessctl and sysfs, writing to the brightness value would change both brightness and actual_brightness, but no changes would appear on the backlight.

Can you please elaborate? I don't know the hardware well.... And I'm not understanding very well: actual_brightness changes but doesn't reflect on the hardware?

Quoted 3 lines

Booting to a disk image of pre-6.12.90 linux with XFCE has the same exact issues, but then after booting back to my normal 6.12.90 system, the maximum brightness came back to what it used to be.

So I solved the regression, but something else is not working?

Maximum brightness as in physical sense or sysfs?

Quoted 4 lines

I hope this heisenbug only happened because i simply patched the wrong commit.

I work on top of the review-for-Ilpo branch of PD/x86...

Quoted 54 lines · Denis Benato
Quoted 38 lines · Denis Benato
Quoted 5 lines

The bd->props.power is checked in parts of the driver correctly comparing with BACKLIGHT_POWER_ON, while in others with a raw usage of bd->props.power and !bd->props.power, moreover in certain checks the logic has been inverted due to BACKLIGHT_POWER_ON being defined as 0: fix both the wrong usage and the inconsistencies by using proper comparisons.

Can someone having the regression please try this out please?

Quoted 31 lines
Fixes 130d29c5627c ("platform/x86: asus-wmi: adjust screenpad power/brightness handling")
---
  drivers/platform/x86/asus-wmi.c | 12 +++++++++---
  1 file changed, 9 insertions(+), 3 deletions(-)
drivers/platform/x86/asus-wmi.c +4 -1
index 8610663b8269..3600dddd8f36 100644
@@ -4500,7 +4500,8 @@ static int update_screenpad_bl_status(struct backlight_device *bd)
  	u32 ctrl_param = bd->props.brightness;
  	int err = 0;
  -	if (bd->props.power) {
+	switch (bd->props.power) {
+	case BACKLIGHT_POWER_ON:
  		err = asus_wmi_set_devstate(ASUS_WMI_DEVID_SCREENPAD_POWER, 1, NULL);
  		if (err < 0)
  			return err;
@@ -4508,12 +4509,17 @@ static int update_screenpad_bl_status(struct backlight_device *bd)
  		err = asus_wmi_set_devstate(ASUS_WMI_DEVID_SCREENPAD_LIGHT, ctrl_param, NULL);
  		if (err < 0)
  			return err;
-	}
+		break;
  -	if (!bd->props.power) {
+	case BACKLIGHT_POWER_OFF:
  		err = asus_wmi_set_devstate(ASUS_WMI_DEVID_SCREENPAD_POWER, 0, NULL);
  		if (err < 0)
Quoted 8 lines

drivers/platform/x86/asus-wmi.c static int update_screenpad_bl_status(struct backlight_device *bd) · line 4525

Quoted 8 lines
drivers/platform/x86/asus-wmi.c +5 -0
  			return err;
+		break;
+
+	default:
+		pr_warn("Invalid screenpad backlight power state: %d\n", bd->props.power);
+		return -EINVAL;
  	}
    	return err;

Regards,

Ponali