]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ACPI: video: Rearrange probe and remove code
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 21 May 2026 14:08:51 +0000 (16:08 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 25 May 2026 14:43:52 +0000 (16:43 +0200)
Rearrange some ACPI video bus probe and remove code so that it is more
clear that the probe and removal are carried in reverse orders, which
will also facilitate subsequent changes.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://patch.msgid.link/2276683.Mh6RI2rZIc@rafael.j.wysocki
drivers/acpi/acpi_video.c

index bdc3f4933abf24f0a424616caaec13e7737e6ccb..ca2bee96794677f259240823c85bcbca11b663b7 100644 (file)
@@ -2002,6 +2002,9 @@ static int acpi_video_bus_probe(struct auxiliary_device *aux_dev,
        if (!video)
                return -ENOMEM;
 
+       video->device = device;
+       device->driver_data = video;
+
        /*
         * A hack to fix the duplicate name "VID" problem on T61 and the
         * duplicate name "VGA" problem on Pa 3553.
@@ -2016,9 +2019,6 @@ static int acpi_video_bus_probe(struct auxiliary_device *aux_dev,
 
        auxiliary_set_drvdata(aux_dev, video);
 
-       video->device = device;
-       device->driver_data = video;
-
        acpi_video_bus_find_cap(video);
        error = acpi_video_bus_check(video);
        if (error)
@@ -2041,10 +2041,6 @@ static int acpi_video_bus_probe(struct auxiliary_device *aux_dev,
                acpi_device_bid(device), str_yes_no(video->flags.multihead),
                str_yes_no(video->flags.rom), str_yes_no(video->flags.post));
 
-       mutex_lock(&video_list_lock);
-       list_add_tail(&video->entry, &video_bus_head);
-       mutex_unlock(&video_list_lock);
-
        /*
         * If backlight-type auto-detection is used then a native backlight may
         * show up later and this may change the result from video to native.
@@ -2060,6 +2056,10 @@ static int acpi_video_bus_probe(struct auxiliary_device *aux_dev,
            !auto_detect)
                acpi_video_bus_register_backlight(video);
 
+       mutex_lock(&video_list_lock);
+       list_add_tail(&video->entry, &video_bus_head);
+       mutex_unlock(&video_list_lock);
+
        error = acpi_video_bus_add_notify_handler(video, dev);
        if (error)
                goto err_del;
@@ -2096,15 +2096,15 @@ static void acpi_video_bus_remove(struct auxiliary_device *aux_dev)
        acpi_dev_remove_notify_handler(device, ACPI_DEVICE_NOTIFY,
                                       acpi_video_bus_notify);
 
+       acpi_video_bus_remove_notify_handler(video);
+
        mutex_lock(&video_list_lock);
        list_del(&video->entry);
        mutex_unlock(&video_list_lock);
-
-       acpi_video_bus_remove_notify_handler(video);
        acpi_video_bus_unregister_backlight(video);
        acpi_video_bus_put_devices(video);
-
        kfree(video->attached_array);
+
        kfree(video);
        device->driver_data = NULL;
 }