public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ACPI: video: Replace backlight_device_register() with devm variant
@ 2025-10-07  3:07 Kaushlendra Kumar
  2025-10-10 10:18 ` kernel test robot
  0 siblings, 1 reply; 2+ messages in thread
From: Kaushlendra Kumar @ 2025-10-07  3:07 UTC (permalink / raw)
  To: rafael, lenb; +Cc: linux-acpi, Kaushlendra Kumar

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


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

end of thread, other threads:[~2025-10-10 10:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-07  3:07 [PATCH] ACPI: video: Replace backlight_device_register() with devm variant Kaushlendra Kumar
2025-10-10 10:18 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox