Skip to contentSkip to conversation

video/backlight: Use backlight helpers

PATCH In review Stephen Kitt 2 participants 9 messages Jun 7, 2022 – Jun 8, 2022

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

cover video/backlight: Use backlight helpers

This started with work on the removal of backlight_properties' deprecated fb_blank field, much of which can be taken care of by using helper functions provided by backlight.h instead of directly accessing fields in backlight_properties. This patch series doesn't involve fb_blank, but it still seems useful to use helper functions where appropriate.

Stephen Kitt (4):
backlight: aat2870: Use backlight helper
backlight: arcxcnn: Use backlight helper
backlight: ipaq_micro: Use backlight helper
backlight: tosa: Use backlight helper

 drivers/video/backlight/aat2870_bl.c    | 7 +------
 drivers/video/backlight/arcxcnn_bl.c    | 5 +----
 drivers/video/backlight/ipaq_micro_bl.c | 7 +------
 drivers/video/backlight/tosa_bl.c       | 7 +------
 4 files changed, 4 insertions(+), 22 deletions(-)

base-commit: f2906aa863381afb0015a9eb7fefad885d4e5a56

Signature · 1 line
2.30.2
#1 lore raw

PATCH 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
Reviewed-by on v1 1/4
#2 lore raw

Re: [PATCH 1/4] backlight: aat2870: Use backlight helper

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

Daniel.

#3 lore raw

PATCH 2/4 backlight: arcxcnn: 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/video/backlight/arcxcnn_bl.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/video/backlight/arcxcnn_bl.c +1 -4
index 7b1c0a0e6cad..a706899eb7ac 100644
@@ -130,12 +130,9 @@ static int arcxcnn_set_brightness(struct arcxcnn *lp, u32 brightness)
 static int arcxcnn_bl_update_status(struct backlight_device *bl)
 {
 	struct arcxcnn *lp = bl_get_data(bl);
-	u32 brightness = bl->props.brightness;
+	u32 brightness = backlight_get_brightness(bl);
 	int ret;
 
-	if (bl->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK))
-		brightness = 0;
-
 	ret = arcxcnn_set_brightness(lp, brightness);
 	if (ret)
 		return ret;
Signature · 1 line
2.30.2
Reviewed-by on v1 2/4
#4 lore raw

Re: [PATCH 2/4] backlight: arcxcnn: Use backlight helper

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

Daniel.

#5 lore raw

PATCH 3/4 backlight: ipaq_micro: 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/video/backlight/ipaq_micro_bl.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/video/backlight/ipaq_micro_bl.c +1 -6
index 85b16cc82878..f595b8c8cbb2 100644
@@ -16,17 +16,12 @@
 static int micro_bl_update_status(struct backlight_device *bd)
 {
 	struct ipaq_micro *micro = dev_get_drvdata(&bd->dev);
-	int intensity = bd->props.brightness;
+	int intensity = backlight_get_brightness(bd);
 	struct ipaq_micro_msg msg = {
 		.id = MSG_BACKLIGHT,
 		.tx_len = 3,
 	};
 
-	if (bd->props.power != FB_BLANK_UNBLANK)
-		intensity = 0;
-	if (bd->props.state & (BL_CORE_FBBLANK | BL_CORE_SUSPENDED))
-		intensity = 0;
-
 	/*
 	 * Message format:
 	 * Byte 0: backlight instance (usually 1)
Signature · 1 line
2.30.2
Reviewed-by on v1 3/4
#6 lore raw

Re: [PATCH 3/4] backlight: ipaq_micro: Use backlight helper

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

Daniel.

#7 lore raw

PATCH 4/4 backlight: tosa: 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/video/backlight/tosa_bl.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/video/backlight/tosa_bl.c +1 -6
index 6df6fcd132e3..5bbb769f9746 100644
@@ -50,13 +50,8 @@ static void tosa_bl_set_backlight(struct tosa_bl_data *data, int brightness)
 
 static int tosa_bl_update_status(struct backlight_device *dev)
 {
-	struct backlight_properties *props = &dev->props;
 	struct tosa_bl_data *data = bl_get_data(dev);
-	int power = max(props->power, props->fb_blank);
-	int brightness = props->brightness;
-
-	if (power)
-		brightness = 0;
+	int brightness = backlight_get_brightness(dev);
 
 	tosa_bl_set_backlight(data, brightness);
 
Signature · 1 line
2.30.2
Reviewed-by on v1 4/4
#8 lore raw

Re: [PATCH 4/4] backlight: tosa: Use backlight helper

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

... and, wowzer, the code before your change wasn't much fun to read!

drivers/video/backlight/tosa_bl.c static void tosa_bl_set_backlight(struct tosa_bl_data *data, int brightness) · line 56

Quoted 12 lines

static int tosa_bl_update_status(struct backlight_device *dev) {

drivers/video/backlight/tosa_bl.c +1 -6
-	struct backlight_properties *props = &dev->props;
 	struct tosa_bl_data *data = bl_get_data(dev);
-	int power = max(props->power, props->fb_blank);
-	int brightness = props->brightness;
-
-	if (power)
-		brightness = 0;
+	int brightness = backlight_get_brightness(dev);
 
 	tosa_bl_set_backlight(data, brightness);

Daniel.