Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ACPI: video: Convert the driver to a platform one

While binding drivers directly to struct acpi_device objects allows
basic functionality to be provided, at least in the majority of cases,
there are some problems with it, related to general consistency, sysfs
layout, power management operation ordering, and code cleanliness.

Overall, it is better to bind drivers to platform devices than to their
ACPI companions, so convert the ACPI video driver to a platform one.

While this is not expected to alter functionality, it changes sysfs
layout and so it will be visible to user space.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
Link: https://patch.msgid.link/1957556.tdWV9SEqCh@rafael.j.wysocki

+23 -24
+23 -24
drivers/acpi/acpi_video.c
··· 21 21 #include <linux/sort.h> 22 22 #include <linux/pci.h> 23 23 #include <linux/pci_ids.h> 24 + #include <linux/platform_device.h> 24 25 #include <linux/slab.h> 25 26 #include <linux/dmi.h> 26 27 #include <linux/suspend.h> ··· 77 76 static DEFINE_MUTEX(register_count_mutex); 78 77 static DEFINE_MUTEX(video_list_lock); 79 78 static LIST_HEAD(video_bus_head); 80 - static int acpi_video_bus_add(struct acpi_device *device); 81 - static void acpi_video_bus_remove(struct acpi_device *device); 79 + static int acpi_video_bus_probe(struct platform_device *pdev); 80 + static void acpi_video_bus_remove(struct platform_device *pdev); 82 81 static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data); 83 82 84 83 /* ··· 99 98 }; 100 99 MODULE_DEVICE_TABLE(acpi, video_device_ids); 101 100 102 - static struct acpi_driver acpi_video_bus = { 103 - .name = "video", 104 - .class = ACPI_VIDEO_CLASS, 105 - .ids = video_device_ids, 106 - .ops = { 107 - .add = acpi_video_bus_add, 108 - .remove = acpi_video_bus_remove, 109 - }, 101 + static struct platform_driver acpi_video_bus = { 102 + .probe = acpi_video_bus_probe, 103 + .remove = acpi_video_bus_remove, 104 + .driver = { 105 + .name = "acpi-video", 106 + .acpi_match_table = video_device_ids, 107 + }, 110 108 }; 111 109 112 110 struct acpi_video_bus_flags { ··· 1888 1888 device->flags.notify = 1; 1889 1889 } 1890 1890 1891 - static int acpi_video_bus_add_notify_handler(struct acpi_video_bus *video) 1891 + static int acpi_video_bus_add_notify_handler(struct acpi_video_bus *video, 1892 + struct platform_device *pdev) 1892 1893 { 1893 1894 struct input_dev *input; 1894 1895 struct acpi_video_device *dev; ··· 1912 1911 input->phys = video->phys; 1913 1912 input->id.bustype = BUS_HOST; 1914 1913 input->id.product = 0x06; 1915 - input->dev.parent = &video->device->dev; 1914 + input->dev.parent = &pdev->dev; 1916 1915 input->evbit[0] = BIT(EV_KEY); 1917 1916 set_bit(KEY_SWITCHVIDEOMODE, input->keybit); 1918 1917 set_bit(KEY_VIDEO_NEXT, input->keybit); ··· 1984 1983 1985 1984 static int instance; 1986 1985 1987 - static int acpi_video_bus_add(struct acpi_device *device) 1986 + static int acpi_video_bus_probe(struct platform_device *pdev) 1988 1987 { 1988 + struct acpi_device *device = ACPI_COMPANION(&pdev->dev); 1989 1989 struct acpi_video_bus *video; 1990 1990 bool auto_detect; 1991 1991 int error; ··· 2022 2020 device->pnp.bus_id[3] = '0' + instance; 2023 2021 instance++; 2024 2022 } 2023 + 2024 + platform_set_drvdata(pdev, video); 2025 2025 2026 2026 video->device = device; 2027 2027 strscpy(acpi_device_name(device), ACPI_VIDEO_BUS_NAME); ··· 2072 2068 !auto_detect) 2073 2069 acpi_video_bus_register_backlight(video); 2074 2070 2075 - error = acpi_video_bus_add_notify_handler(video); 2071 + error = acpi_video_bus_add_notify_handler(video, pdev); 2076 2072 if (error) 2077 2073 goto err_del; 2078 2074 ··· 2100 2096 return error; 2101 2097 } 2102 2098 2103 - static void acpi_video_bus_remove(struct acpi_device *device) 2099 + static void acpi_video_bus_remove(struct platform_device *pdev) 2104 2100 { 2105 - struct acpi_video_bus *video = NULL; 2106 - 2107 - 2108 - if (!device || !acpi_driver_data(device)) 2109 - return; 2110 - 2111 - video = acpi_driver_data(device); 2101 + struct acpi_video_bus *video = platform_get_drvdata(pdev); 2102 + struct acpi_device *device = ACPI_COMPANION(&pdev->dev); 2112 2103 2113 2104 acpi_dev_remove_notify_handler(device, ACPI_DEVICE_NOTIFY, 2114 2105 acpi_video_bus_notify); ··· 2166 2167 2167 2168 dmi_check_system(video_dmi_table); 2168 2169 2169 - ret = acpi_bus_register_driver(&acpi_video_bus); 2170 + ret = platform_driver_register(&acpi_video_bus); 2170 2171 if (ret) 2171 2172 goto leave; 2172 2173 ··· 2186 2187 { 2187 2188 mutex_lock(&register_count_mutex); 2188 2189 if (register_count) { 2189 - acpi_bus_unregister_driver(&acpi_video_bus); 2190 + platform_driver_unregister(&acpi_video_bus); 2190 2191 register_count = 0; 2191 2192 may_report_brightness_keys = false; 2192 2193 }