Skip to contentSkip to conversation

platform/x86: Use backlight helpers

PATCH In review Stephen Kitt 3 participants 10 messages Jun 7, 2022 – Jun 22, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover platform/x86: Use backlight helpers

backlight_properties.fb_blank is deprecated. The states it represents are handled by other properties; but instead of accessing those properties directly, drivers should use the helpers provided by backlight.h.

This will ultimately allow fb_blank to be removed.

Stephen Kitt (4):
platform/x86: acer-wmi: Use backlight helper platform/x86: apple-gmux: Use backlight helper platform/x86: compal-laptop: Use backlight helper platform/x86: thinkpad_acpi: Use backlight helper

 drivers/platform/x86/acer-wmi.c      | 7 +------
 drivers/platform/x86/apple-gmux.c    | 5 +----
 drivers/platform/x86/compal-laptop.c | 4 +---
 drivers/platform/x86/thinkpad_acpi.c | 5 +----
 4 files changed, 4 insertions(+), 17 deletions(-)

base-commit: f2906aa863381afb0015a9eb7fefad885d4e5a56

Signature · 1 line
2.30.2
#1 lore raw

PATCH 1/4 platform/x86: acer-wmi: Use backlight helper

Instead of retrieving the backlight brightness in struct backlight_properties manually, and then checking whether the backlight should be on at all, use backlight_get_brightness() which does all this and insulates this from future changes.

Cc "Lee, Chun-Yi" <[email protected]>
Cc Hans de Goede <[email protected]>
Cc Mark Gross <[email protected]>
---
 drivers/platform/x86/acer-wmi.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/platform/x86/acer-wmi.c +1 -6
index 9c6943e401a6..e0230ea0cb7e 100644
@@ -1615,12 +1615,7 @@ static int read_brightness(struct backlight_device *bd)
 
 static int update_bl_status(struct backlight_device *bd)
 {
-	int intensity = bd->props.brightness;
-
-	if (bd->props.power != FB_BLANK_UNBLANK)
-		intensity = 0;
-	if (bd->props.fb_blank != FB_BLANK_UNBLANK)
-		intensity = 0;
+	int intensity = backlight_get_brightness(bd);
 
 	set_u32(intensity, ACER_CAP_BRIGHTNESS);
 
Signature · 1 line
2.30.2
Reviewed-by on v1 1/4
#2 lore raw

Re: [PATCH 1/4] platform/x86: acer-wmi: Use backlight helper

Quoted 10 lines · Stephen Kitt

Instead of retrieving the backlight brightness in struct backlight_properties manually, and then checking whether the backlight should be on at all, use backlight_get_brightness() which does all this and insulates this from future changes.

Cc "Lee, Chun-Yi" <[email protected]>
Cc Hans de Goede <[email protected]>
Cc Mark Gross <[email protected]>

Daniel.

#3 lore raw

PATCH 2/4 platform/x86: apple-gmux: Use backlight helper

In reply to Stephen Kitt

Instead of retrieving the backlight brightness in struct backlight_properties manually, and then checking whether the backlight should be on at all, use backlight_get_brightness() which does all this and insulates this from future changes.

---
 drivers/platform/x86/apple-gmux.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/platform/x86/apple-gmux.c +1 -4
index 57553f9b4d1d..ffe98a18440b 100644
@@ -291,10 +291,7 @@ static int gmux_get_brightness(struct backlight_device *bd)
 static int gmux_update_status(struct backlight_device *bd)
 {
 	struct apple_gmux_data *gmux_data = bl_get_data(bd);
-	u32 brightness = bd->props.brightness;
-
-	if (bd->props.state & BL_CORE_SUSPENDED)
-		return 0;
+	u32 brightness = backlight_get_brightness(bd);
 
 	gmux_write32(gmux_data, GMUX_PORT_BRIGHTNESS, brightness);
 
Signature · 1 line
2.30.2
Reviewed-by on v1 2/4
#4 lore raw

Re: [PATCH 2/4] platform/x86: apple-gmux: Use backlight helper

Quoted 9 lines · Stephen Kitt

Instead of retrieving the backlight brightness in struct backlight_properties manually, and then checking whether the backlight should be on at all, use backlight_get_brightness() which does all this and insulates this from future changes.

Daniel.

#5 lore raw

PATCH 3/4 platform/x86: compal-laptop: Use backlight helper

In reply to Stephen Kitt

Instead of manually checking the power state in struct backlight_properties, use backlight_is_blank().

Cc Cezary Jackiewicz <[email protected]>
Cc Hans de Goede <[email protected]>
Cc Mark Gross <[email protected]>
---
 drivers/platform/x86/compal-laptop.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/platform/x86/compal-laptop.c +1 -3
index ab610376fdad..0942f50bd793 100644
@@ -324,9 +324,7 @@ static int bl_update_status(struct backlight_device *b)
 	if (ret)
 		return ret;
 
-	set_backlight_state((b->props.power == FB_BLANK_UNBLANK)
-		&&    !(b->props.state & BL_CORE_SUSPENDED)
-		&&    !(b->props.state & BL_CORE_FBBLANK));
+	set_backlight_state(!backlight_is_blank(b));
 	return 0;
 }
 
Signature · 1 line
2.30.2
Reviewed-by on v1 3/4
#6 lore raw

Re: [PATCH 3/4] platform/x86: compal-laptop: Use backlight helper

Quoted 8 lines · Stephen Kitt

Instead of manually checking the power state in struct backlight_properties, use backlight_is_blank().

Cc Cezary Jackiewicz <[email protected]>
Cc Hans de Goede <[email protected]>
Cc Mark Gross <[email protected]>

Daniel.

#7 lore raw

PATCH 4/4 platform/x86: thinkpad_acpi: Use backlight helper

In reply to Stephen Kitt

Instead of retrieving the backlight brightness in struct backlight_properties manually, and then checking whether the backlight should be on at all, use backlight_get_brightness() which does all this and insulates this from future changes.

Cc Henrique de Moraes Holschuh <[email protected]>
Cc Hans de Goede <[email protected]>
Cc Mark Gross <[email protected]>
---
 drivers/platform/x86/thinkpad_acpi.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/platform/x86/thinkpad_acpi.c +1 -4
index e6cb4a14cdd4..a9337bd1d125 100644
@@ -6796,10 +6796,7 @@ static int brightness_set(unsigned int value)
 
 static int brightness_update_status(struct backlight_device *bd)
 {
-	unsigned int level =
-		(bd->props.fb_blank == FB_BLANK_UNBLANK &&
-		 bd->props.power == FB_BLANK_UNBLANK) ?
-				bd->props.brightness : 0;
+	int level = backlight_get_brightness(bd);
 
 	dbg_printk(TPACPI_DBG_BRGHT,
 			"backlight: attempt to set level to %d\n",
Signature · 1 line
2.30.2
Reviewed-by on v1 4/4
#8 lore raw

Re: [PATCH 4/4] platform/x86: thinkpad_acpi: Use backlight helper

Quoted 11 lines · Stephen Kitt

Instead of retrieving the backlight brightness in struct backlight_properties manually, and then checking whether the backlight should be on at all, use backlight_get_brightness() which does all this and insulates this from future changes.

Cc Henrique de Moraes Holschuh <[email protected]>
Cc Hans de Goede <[email protected]>
Cc Mark Gross <[email protected]>

Daniel.

#9 lore raw
In reply to Stephen Kitt

Hi,

Quoted 13 lines · Stephen Kitt

backlight_properties.fb_blank is deprecated. The states it represents are handled by other properties; but instead of accessing those properties directly, drivers should use the helpers provided by backlight.h.

This will ultimately allow fb_blank to be removed.

Stephen Kitt (4):
platform/x86: acer-wmi: Use backlight helper platform/x86: apple-gmux: Use backlight helper platform/x86: compal-laptop: Use backlight helper platform/x86: thinkpad_acpi: Use backlight helper

Quoted 5 lines
 drivers/platform/x86/acer-wmi.c      | 7 +------
 drivers/platform/x86/apple-gmux.c    | 5 +----
 drivers/platform/x86/compal-laptop.c | 4 +---
 drivers/platform/x86/thinkpad_acpi.c | 5 +----
 4 files changed, 4 insertions(+), 17 deletions(-)

Thank you for your patch-series, I've applied the series to my review-hans branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans

Note it will show up in my review-hans branch once I've pushed my local branch there, which might take a while.

Once I've run some tests on this branch the patches there will be added to the platform-drivers-x86/for-next branch and eventually will be included in the pdx86 pull-request to Linus for the next merge-window.

Regards,

Hans