From: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
To: rafael@kernel.org, lenb@kernel.org
Cc: linux-acpi@vger.kernel.org,
Kaushlendra Kumar <kaushlendra.kumar@intel.com>
Subject: [PATCH] ACPI: video: Replace backlight_device_register() with devm variant
Date: Tue, 7 Oct 2025 08:37:30 +0530 [thread overview]
Message-ID: <20251007030730.3192901-1-kaushlendra.kumar@intel.com> (raw)
Replace deprecated backlight_device_register() with
devm_backlight_device_register() to use device-managed
resource allocation. This automatically handles backlight
device cleanup when the device is removed, eliminating the
need for manual backlight_device_unregister() calls.
Remove the manual cleanup code in acpi_video_dev_unregister_backlight()
as the managed version handles deregistration automatically.
Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
---
drivers/acpi/acpi_video.c | 19 +++++++------------
1 file changed, 7 insertions(+), 12 deletions(-)
diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
index 103f29661576..e56665977ed7 100644
--- a/drivers/acpi/acpi_video.c
+++ b/drivers/acpi/acpi_video.c
@@ -1741,16 +1741,15 @@ static void acpi_video_dev_register_backlight(struct acpi_video_device *device)
props.type = BACKLIGHT_FIRMWARE;
props.max_brightness =
device->brightness->count - ACPI_VIDEO_FIRST_LEVEL - 1;
- device->backlight = backlight_device_register(name,
- parent,
- device,
- &acpi_backlight_ops,
- &props);
+ device->backlight = devm_backlight_device_register(&pdev->dev,
+ name,
+ parent,
+ device,
+ &acpi_backlight_ops,
+ &props);
kfree(name);
- if (IS_ERR(device->backlight)) {
- device->backlight = NULL;
+ if (IS_ERR(device->backlight))
return;
- }
/*
* Save current brightness level in case we have to restore it
@@ -1841,10 +1840,6 @@ static int acpi_video_bus_register_backlight(struct acpi_video_bus *video)
static void acpi_video_dev_unregister_backlight(struct acpi_video_device *device)
{
- if (device->backlight) {
- backlight_device_unregister(device->backlight);
- device->backlight = NULL;
- }
if (device->brightness) {
kfree(device->brightness->levels);
kfree(device->brightness);
--
2.34.1
next reply other threads:[~2025-10-07 3:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-07 3:07 Kaushlendra Kumar [this message]
2025-10-10 10:18 ` [PATCH] ACPI: video: Replace backlight_device_register() with devm variant kernel test robot
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=20251007030730.3192901-1-kaushlendra.kumar@intel.com \
--to=kaushlendra.kumar@intel.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=rafael@kernel.org \
/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