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.

sonypi: Convert ACPI driver to a platform one

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 sonypi 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: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://patch.msgid.link/2277493.Mh6RI2rZIc@rafael.j.wysocki
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Rafael J. Wysocki and committed by
Greg Kroah-Hartman
7e488b0a 2d7ce8eb

+13 -12
+13 -12
drivers/char/sonypi.c
··· 1115 1115 } 1116 1116 1117 1117 #ifdef CONFIG_ACPI 1118 - static int sonypi_acpi_add(struct acpi_device *device) 1118 + static int sonypi_acpi_probe(struct platform_device *pdev) 1119 1119 { 1120 + struct acpi_device *device = ACPI_COMPANION(&pdev->dev); 1121 + 1120 1122 sonypi_acpi_device = device; 1121 1123 strcpy(acpi_device_name(device), "Sony laptop hotkeys"); 1122 1124 strcpy(acpi_device_class(device), "sony/hotkey"); 1123 1125 return 0; 1124 1126 } 1125 1127 1126 - static void sonypi_acpi_remove(struct acpi_device *device) 1128 + static void sonypi_acpi_remove(struct platform_device *pdev) 1127 1129 { 1128 1130 sonypi_acpi_device = NULL; 1129 1131 } ··· 1135 1133 {"", 0}, 1136 1134 }; 1137 1135 1138 - static struct acpi_driver sonypi_acpi_driver = { 1139 - .name = "sonypi", 1140 - .class = "hkey", 1141 - .ids = sonypi_device_ids, 1142 - .ops = { 1143 - .add = sonypi_acpi_add, 1144 - .remove = sonypi_acpi_remove, 1136 + static struct platform_driver sonypi_acpi_driver = { 1137 + .probe = sonypi_acpi_probe, 1138 + .remove = sonypi_acpi_remove, 1139 + .driver = { 1140 + .name = "sonypi_acpi", 1141 + .acpi_match_table = sonypi_device_ids, 1145 1142 }, 1146 1143 }; 1147 1144 #endif ··· 1519 1518 goto err_free_device; 1520 1519 1521 1520 #ifdef CONFIG_ACPI 1522 - if (acpi_bus_register_driver(&sonypi_acpi_driver) >= 0) 1523 - acpi_driver_registered = 1; 1521 + error = platform_driver_register(&sonypi_acpi_driver); 1522 + acpi_driver_registered = !error; 1524 1523 #endif 1525 1524 1526 1525 return 0; ··· 1536 1535 { 1537 1536 #ifdef CONFIG_ACPI 1538 1537 if (acpi_driver_registered) 1539 - acpi_bus_unregister_driver(&sonypi_acpi_driver); 1538 + platform_driver_unregister(&sonypi_acpi_driver); 1540 1539 #endif 1541 1540 platform_device_unregister(sonypi_platform_device); 1542 1541 platform_driver_unregister(&sonypi_driver);