From: Thorsten Blum <blum@kernel.org>
To: "Lee Jones" <lee@kernel.org>,
"Daniel Thompson" <danielt@kernel.org>,
"Jingoo Han" <jingoohan1@gmail.com>,
"Helge Deller" <deller@gmx.de>,
"Linus Walleij" <linusw@kernel.org>,
"Duje Mihanović" <duje@dujemihanovic.xyz>,
"Jin Park" <jinyoungp@nvidia.com>,
"Samuel Ortiz" <sameo@linux.intel.com>
Cc: dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org,
Thorsten Blum <blum@kernel.org>
Subject: [PATCH 3/3] backlight: aat2870: Initialize properties before device registration
Date: Fri, 20 Nov 2026 00:07:36 +0100 [thread overview]
Message-ID: <20261119230733.790573-6-blum@kernel.org> (raw)
In-Reply-To: <20261119230733.790573-4-blum@kernel.org>
The backlight API requires max_brightness to be supplied at device
registration and not to be modified afterwards. AAT2870 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 and the maximum brightness to
devm_backlight_device_register() to set them before the sysfs attributes
become visible to userspace.
Fixes: 4b0d711be39f ("backlight: Add AAT2870 backlight driver")
Signed-off-by: Thorsten Blum <blum@kernel.org>
---
drivers/video/backlight/aat2870_bl.c | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/drivers/video/backlight/aat2870_bl.c b/drivers/video/backlight/aat2870_bl.c
index 5af36d3784f1..fa854827e558 100644
--- a/drivers/video/backlight/aat2870_bl.c
+++ b/drivers/video/backlight/aat2870_bl.c
@@ -99,7 +99,11 @@ static int aat2870_bl_probe(struct platform_device *pdev)
struct aat2870_bl_platform_data *pdata = dev_get_platdata(&pdev->dev);
struct aat2870_bl_driver_data *aat2870_bl;
struct backlight_device *bd;
- struct backlight_properties props;
+ struct backlight_properties props = {
+ .type = BACKLIGHT_RAW,
+ .max_brightness = 255,
+ .power = BACKLIGHT_POWER_ON,
+ };
int ret = 0;
if (!pdata) {
@@ -120,9 +124,10 @@ static int aat2870_bl_probe(struct platform_device *pdev)
goto out;
}
- memset(&props, 0, sizeof(struct backlight_properties));
+ if (pdata->max_brightness > 0)
+ props.max_brightness = pdata->max_brightness;
+ props.brightness = props.max_brightness;
- props.type = BACKLIGHT_RAW;
bd = devm_backlight_device_register(&pdev->dev, "aat2870-backlight",
&pdev->dev, aat2870_bl, &aat2870_bl_ops,
&props);
@@ -148,14 +153,7 @@ static int aat2870_bl_probe(struct platform_device *pdev)
else
aat2870_bl->max_current = AAT2870_CURRENT_27_9;
- if (pdata->max_brightness > 0)
- bd->props.max_brightness = pdata->max_brightness;
- else
- bd->props.max_brightness = 255;
-
aat2870_bl->brightness = 0;
- bd->props.power = BACKLIGHT_POWER_ON;
- bd->props.brightness = bd->props.max_brightness;
ret = aat2870_bl_update_status(bd);
if (ret < 0) {
prev parent reply other threads:[~2026-11-19 23:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Thorsten Blum [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261119230733.790573-6-blum@kernel.org \
--to=blum@kernel.org \
--cc=danielt@kernel.org \
--cc=deller@gmx.de \
--cc=dri-devel@lists.freedesktop.org \
--cc=duje@dujemihanovic.xyz \
--cc=jingoohan1@gmail.com \
--cc=jinyoungp@nvidia.com \
--cc=lee@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-fbdev@vger.kernel.org \
--cc=sameo@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox