Skip to contentSkip to conversation

backlight: aat2870: Use backlight helper

PATCH RESEND Applied Stephen Kitt 5 participants 8 messages Jan 6, 2023 – Jan 19, 2023

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

PATCH RESEND 1/4 backlight: aat2870: 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.

---
 drivers/video/backlight/aat2870_bl.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/video/backlight/aat2870_bl.c +1 -6
index a7af9adafad6..1cbb303e9c88 100644
@@ -59,7 +59,7 @@ static int aat2870_bl_update_status(struct backlight_device *bd)
 	struct aat2870_bl_driver_data *aat2870_bl = bl_get_data(bd);
 	struct aat2870_data *aat2870 =
 			dev_get_drvdata(aat2870_bl->pdev->dev.parent);
-	int brightness = bd->props.brightness;
+	int brightness = backlight_get_brightness(bd);
 	int ret;
 
 	if ((brightness < 0) || (bd->props.max_brightness < brightness)) {
@@ -70,11 +70,6 @@ static int aat2870_bl_update_status(struct backlight_device *bd)
 	dev_dbg(&bd->dev, "brightness=%d, power=%d, state=%d\n",
 		 bd->props.brightness, bd->props.power, bd->props.state);
 
-	if ((bd->props.power != FB_BLANK_UNBLANK) ||
-			(bd->props.state & BL_CORE_FBBLANK) ||
-			(bd->props.state & BL_CORE_SUSPENDED))
-		brightness = 0;
-
 	ret = aat2870->write(aat2870, AAT2870_BLM,
 			     (u8)aat2870_brightness(aat2870_bl, brightness));
 	if (ret < 0)
Signature · 1 line
2.30.2
#1 lore raw
Quoted 6 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.

Lee/Daniel, will you pick these up, or should I smash them all into drm-misc-next for 6.3?

Stephen, I see to be missing 3/4 here, but maybe it'll show up. -Daniel

Quoted 32 lines
---
 drivers/video/backlight/aat2870_bl.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/video/backlight/aat2870_bl.c +1 -6
index a7af9adafad6..1cbb303e9c88 100644
@@ -59,7 +59,7 @@ static int aat2870_bl_update_status(struct backlight_device *bd)
 	struct aat2870_bl_driver_data *aat2870_bl = bl_get_data(bd);
 	struct aat2870_data *aat2870 =
 			dev_get_drvdata(aat2870_bl->pdev->dev.parent);
-	int brightness = bd->props.brightness;
+	int brightness = backlight_get_brightness(bd);
 	int ret;
 
 	if ((brightness < 0) || (bd->props.max_brightness < brightness)) {
@@ -70,11 +70,6 @@ static int aat2870_bl_update_status(struct backlight_device *bd)
 	dev_dbg(&bd->dev, "brightness=%d, power=%d, state=%d\n",
 		 bd->props.brightness, bd->props.power, bd->props.state);
 
-	if ((bd->props.power != FB_BLANK_UNBLANK) ||
-			(bd->props.state & BL_CORE_FBBLANK) ||
-			(bd->props.state & BL_CORE_SUSPENDED))
-		brightness = 0;
-
 	ret = aat2870->write(aat2870, AAT2870_BLM,
 			     (u8)aat2870_brightness(aat2870_bl, brightness));
 	if (ret < 0)
Signature · 1 line
2.30.2
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
#2 lore raw

Hi Daniel,

Quoted 6 lines · Daniel Vetter
Quoted 5 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.

Quoted 6 lines
Quoted 1 line

Lee/Daniel, will you pick these up, or should I smash them all into drm-misc-next for 6.3?

Stephen, I see to be missing 3/4 here, but maybe it'll show up.

It seems to have been delayed in transit, it showed up some time after all the others on the mailing lists. If you haven’t got it yet I can resend it!

Regards,

Stephen

#3 lore raw
In reply to Daniel Vetter
Quoted 10 lines · Daniel Vetter
Quoted 6 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.

Lee/Daniel, will you pick these up, or should I smash them all into drm-misc-next for 6.3?

Outside of holiday, Lee usually hoovers up the backlight patches (and negotiates about who merges what).

Daniel.

Quoted 37 lines
Quoted 30 lines
---
 drivers/video/backlight/aat2870_bl.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/video/backlight/aat2870_bl.c +1 -7
index a7af9adafad6..1cbb303e9c88 100644
@@ -59,7 +59,7 @@ static int aat2870_bl_update_status(struct backlight_device *bd)
 	struct aat2870_bl_driver_data *aat2870_bl = bl_get_data(bd);
 	struct aat2870_data *aat2870 =
 			dev_get_drvdata(aat2870_bl->pdev->dev.parent);
-	int brightness = bd->props.brightness;
+	int brightness = backlight_get_brightness(bd);
 	int ret;
 
 	if ((brightness < 0) || (bd->props.max_brightness < brightness)) {
@@ -70,11 +70,6 @@ static int aat2870_bl_update_status(struct backlight_device *bd)
 	dev_dbg(&bd->dev, "brightness=%d, power=%d, state=%d\n",
 		 bd->props.brightness, bd->props.power, bd->props.state);
 
-	if ((bd->props.power != FB_BLANK_UNBLANK) ||
-			(bd->props.state & BL_CORE_FBBLANK) ||
-			(bd->props.state & BL_CORE_SUSPENDED))
-		brightness = 0;
-
 	ret = aat2870->write(aat2870, AAT2870_BLM,
 			     (u8)aat2870_brightness(aat2870_bl, brightness));
 	if (ret < 0)
--
Quoted 2 lines

2.30.2

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

maintainer
#4 lore raw
Quoted 7 lines · Daniel Thompson
Quoted 6 lines · Daniel Vetter
Quoted 5 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.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Lee/Daniel, will you pick these up, or should I smash them all into drm-misc-next for 6.3?

Outside of holiday, Lee usually hoovers up the backlight patches (and negotiates about who merges what).

Right, I'll collect these into the Backlight tree if there aren't any build deps involved. If there are, we'll need to devise a strategy that will likely involve immutable branches.

Signature · 1 line
Lee Jones [李琼斯]
Reviewed-by on v1 1/4
#5 lore raw
In reply to Stephen Kitt

Hi Stephen,

Quoted 6 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.

Nice cleanup.

Quoted 31 lines
---
 drivers/video/backlight/aat2870_bl.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/video/backlight/aat2870_bl.c +1 -6
index a7af9adafad6..1cbb303e9c88 100644
@@ -59,7 +59,7 @@ static int aat2870_bl_update_status(struct backlight_device *bd)
 	struct aat2870_bl_driver_data *aat2870_bl = bl_get_data(bd);
 	struct aat2870_data *aat2870 =
 			dev_get_drvdata(aat2870_bl->pdev->dev.parent);
-	int brightness = bd->props.brightness;
+	int brightness = backlight_get_brightness(bd);
 	int ret;
 
 	if ((brightness < 0) || (bd->props.max_brightness < brightness)) {
@@ -70,11 +70,6 @@ static int aat2870_bl_update_status(struct backlight_device *bd)
 	dev_dbg(&bd->dev, "brightness=%d, power=%d, state=%d\n",
 		 bd->props.brightness, bd->props.power, bd->props.state);
 
-	if ((bd->props.power != FB_BLANK_UNBLANK) ||
-			(bd->props.state & BL_CORE_FBBLANK) ||
-			(bd->props.state & BL_CORE_SUSPENDED))
-		brightness = 0;
-
 	ret = aat2870->write(aat2870, AAT2870_BLM,
 			     (u8)aat2870_brightness(aat2870_bl, brightness));
 	if (ret < 0)
Signature · 1 line
2.30.2
Reviewed-by on v1 1/4
#6 lore raw
In reply to Stephen Kitt
Quoted 6 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.

This RESEND seems to have dropped the Reviewed-By tags provided the last time is was circulated:
https://lore.kernel.org/all/[email protected]/

There's only four patches so I guess I can add them again so the tools can pick them up.

Daniel.

maintainer Applied
#7 lore raw
In reply to Stephen Kitt
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.

---
 drivers/video/backlight/aat2870_bl.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

Applied, thanks

Signature · 1 line
Lee Jones [李琼斯]