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.

backlight: apple_bl: Convert to a platform driver

In all cases in which a struct acpi_driver is used for binding a driver
to an ACPI device object, a corresponding platform device is created by
the ACPI core and that device is regarded as a proper representation of
underlying hardware. Accordingly, a struct platform_driver should be
used by driver code to bind to that device. There are multiple reasons
why drivers should not bind directly to ACPI device objects [1].

Overall, it is better to bind drivers to platform devices than to their
ACPI companions, so convert the Apple Backlight ACPI 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.

Link: https://lore.kernel.org/all/2396510.ElGaqSPkdT@rafael.j.wysocki/ [1]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Daniel Thompson (RISCstar) <danielt@kernel.org>
Link: https://patch.msgid.link/5084777.GXAFRqVoOG@rafael.j.wysocki
Signed-off-by: Lee Jones <lee@kernel.org>

authored by

Rafael J. Wysocki and committed by
Lee Jones
04d8f3fd 797cc011

+11 -10
+11 -10
drivers/video/backlight/apple_bl.c
··· 24 24 #include <linux/pci.h> 25 25 #include <linux/acpi.h> 26 26 #include <linux/atomic.h> 27 + #include <linux/platform_device.h> 27 28 #include <acpi/video.h> 28 29 29 30 static struct backlight_device *apple_backlight_device; ··· 135 134 .set_brightness = nvidia_chipset_set_brightness, 136 135 }; 137 136 138 - static int apple_bl_add(struct acpi_device *dev) 137 + static int apple_bl_probe(struct platform_device *pdev) 139 138 { 140 139 struct backlight_properties props; 141 140 struct pci_dev *host; ··· 194 193 return 0; 195 194 } 196 195 197 - static void apple_bl_remove(struct acpi_device *dev) 196 + static void apple_bl_remove(struct platform_device *pdev) 198 197 { 199 198 backlight_device_unregister(apple_backlight_device); 200 199 ··· 207 206 {"", 0}, 208 207 }; 209 208 210 - static struct acpi_driver apple_bl_driver = { 211 - .name = "Apple backlight", 212 - .ids = apple_bl_ids, 213 - .ops = { 214 - .add = apple_bl_add, 215 - .remove = apple_bl_remove, 209 + static struct platform_driver apple_bl_driver = { 210 + .probe = apple_bl_probe, 211 + .remove = apple_bl_remove, 212 + .driver = { 213 + .name = "Apple backlight", 214 + .acpi_match_table = apple_bl_ids, 216 215 }, 217 216 }; 218 217 ··· 225 224 if (acpi_video_get_backlight_type() != acpi_backlight_vendor) 226 225 return -ENODEV; 227 226 228 - return acpi_bus_register_driver(&apple_bl_driver); 227 + return platform_driver_register(&apple_bl_driver); 229 228 } 230 229 231 230 static void __exit apple_bl_exit(void) 232 231 { 233 - acpi_bus_unregister_driver(&apple_bl_driver); 232 + platform_driver_unregister(&apple_bl_driver); 234 233 } 235 234 236 235 module_init(apple_bl_init);