Skip to content

Commit 04d8f3f

Browse files
rafaeljwlag-linaro
authored andcommitted
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/[email protected]/ [1] Signed-off-by: Rafael J. Wysocki <[email protected]> Reviewed-by: Daniel Thompson (RISCstar) <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Lee Jones <[email protected]>
1 parent 797cc01 commit 04d8f3f

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

drivers/video/backlight/apple_bl.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <linux/pci.h>
2525
#include <linux/acpi.h>
2626
#include <linux/atomic.h>
27+
#include <linux/platform_device.h>
2728
#include <acpi/video.h>
2829

2930
static struct backlight_device *apple_backlight_device;
@@ -134,7 +135,7 @@ static const struct hw_data nvidia_chipset_data = {
134135
.set_brightness = nvidia_chipset_set_brightness,
135136
};
136137

137-
static int apple_bl_add(struct acpi_device *dev)
138+
static int apple_bl_probe(struct platform_device *pdev)
138139
{
139140
struct backlight_properties props;
140141
struct pci_dev *host;
@@ -193,7 +194,7 @@ static int apple_bl_add(struct acpi_device *dev)
193194
return 0;
194195
}
195196

196-
static void apple_bl_remove(struct acpi_device *dev)
197+
static void apple_bl_remove(struct platform_device *pdev)
197198
{
198199
backlight_device_unregister(apple_backlight_device);
199200

@@ -206,12 +207,12 @@ static const struct acpi_device_id apple_bl_ids[] = {
206207
{"", 0},
207208
};
208209

209-
static struct acpi_driver apple_bl_driver = {
210-
.name = "Apple backlight",
211-
.ids = apple_bl_ids,
212-
.ops = {
213-
.add = apple_bl_add,
214-
.remove = apple_bl_remove,
210+
static struct platform_driver apple_bl_driver = {
211+
.probe = apple_bl_probe,
212+
.remove = apple_bl_remove,
213+
.driver = {
214+
.name = "Apple backlight",
215+
.acpi_match_table = apple_bl_ids,
215216
},
216217
};
217218

@@ -224,12 +225,12 @@ static int __init apple_bl_init(void)
224225
if (acpi_video_get_backlight_type() != acpi_backlight_vendor)
225226
return -ENODEV;
226227

227-
return acpi_bus_register_driver(&apple_bl_driver);
228+
return platform_driver_register(&apple_bl_driver);
228229
}
229230

230231
static void __exit apple_bl_exit(void)
231232
{
232-
acpi_bus_unregister_driver(&apple_bl_driver);
233+
platform_driver_unregister(&apple_bl_driver);
233234
}
234235

235236
module_init(apple_bl_init);

0 commit comments

Comments
 (0)