All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] backlight: ktd253: Initialize properties before device registration
@ 2026-11-19 23:07 Thorsten Blum
  2026-11-19 23:07 ` [PATCH 2/3] backlight: ktd2801: " Thorsten Blum
  2026-11-19 23:07 ` [PATCH 3/3] backlight: aat2870: " Thorsten Blum
  0 siblings, 2 replies; 4+ messages in thread
From: Thorsten Blum @ 2026-11-19 23:07 UTC (permalink / raw)
  To: Lee Jones, Daniel Thompson, Jingoo Han, Helge Deller,
	Linus Walleij, Duje Mihanović, Jin Park, Samuel Ortiz
  Cc: dri-devel, linux-fbdev, Thorsten Blum

The backlight API requires max_brightness to be supplied at device
registration and not to be modified afterwards. KTD253 currently sets it
after registering the device, allowing userspace to read a maximum
brightness of 0 before the configured value is applied.

Pass the initial brightness, maximum brightness, and power state to
devm_backlight_device_register() to set them before the sysfs attributes
become visible to userspace.

Fixes: 5317f37e48b9 ("backlight: Add Kinetic KTD253 backlight driver")
Signed-off-by: Thorsten Blum <blum@kernel.org>
---
 drivers/video/backlight/ktd253-backlight.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/drivers/video/backlight/ktd253-backlight.c b/drivers/video/backlight/ktd253-backlight.c
index 8091c7e085e8..5fc29c858a4b 100644
--- a/drivers/video/backlight/ktd253-backlight.c
+++ b/drivers/video/backlight/ktd253-backlight.c
@@ -141,6 +141,9 @@ static const struct backlight_ops ktd253_backlight_ops = {
 
 static int ktd253_backlight_probe(struct platform_device *pdev)
 {
+	struct backlight_properties props = {
+		.type = BACKLIGHT_RAW,
+	};
 	struct device *dev = &pdev->dev;
 	struct backlight_device *bl;
 	struct ktd253_backlight *ktd253;
@@ -179,21 +182,16 @@ static int ktd253_backlight_probe(struct platform_device *pdev)
 	/* Bring backlight to a known off state */
 	msleep(KTD253_T_OFF_MS);
 
+	props.max_brightness = max_brightness;
+	props.brightness = brightness;
+	props.power = brightness ? BACKLIGHT_POWER_ON : BACKLIGHT_POWER_OFF;
+
 	bl = devm_backlight_device_register(dev, dev_name(dev), dev, ktd253,
-					    &ktd253_backlight_ops, NULL);
+					    &ktd253_backlight_ops, &props);
 	if (IS_ERR(bl)) {
 		dev_err(dev, "failed to register backlight\n");
 		return PTR_ERR(bl);
 	}
-	bl->props.max_brightness = max_brightness;
-	/* When we just enable the GPIO line we set max brightness */
-	if (brightness) {
-		bl->props.brightness = brightness;
-		bl->props.power = BACKLIGHT_POWER_ON;
-	} else {
-		bl->props.brightness = 0;
-		bl->props.power = BACKLIGHT_POWER_OFF;
-	}
 
 	ktd253->bl = bl;
 	platform_set_drvdata(pdev, bl);

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

end of thread, other threads:[~2026-11-19 23:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19 23:07 [PATCH 1/3] backlight: ktd253: Initialize properties before device registration Thorsten Blum
2026-11-19 23:07 ` [PATCH 2/3] backlight: ktd2801: " Thorsten Blum
2026-11-19 23:07 ` [PATCH 3/3] backlight: aat2870: " Thorsten Blum
2026-11-19 23:17   ` sashiko-bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.