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.

platform/x86: asus-wireless: 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 Asus wireless ACPI driver to a platform
one.

After this change, the subordinate input and LED devices will be
registered under the platform device used for driver binding instead of
its ACPI companion.

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: Denis Benato <denis.benato@linux.dev>
Link: https://patch.msgid.link/13959361.uLZWGnKmhe@rafael.j.wysocki
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

authored by

Rafael J. Wysocki and committed by
Ilpo Järvinen
f7e64802 4f52c972

+21 -18
+21 -18
drivers/platform/x86/asus-wireless.c
··· 12 12 #include <linux/acpi.h> 13 13 #include <linux/input.h> 14 14 #include <linux/pci_ids.h> 15 + #include <linux/platform_device.h> 15 16 #include <linux/leds.h> 16 17 17 18 struct hswc_params { ··· 125 124 input_sync(data->idev); 126 125 } 127 126 128 - static int asus_wireless_add(struct acpi_device *adev) 127 + static int asus_wireless_probe(struct platform_device *pdev) 129 128 { 129 + struct acpi_device *adev = ACPI_COMPANION(&pdev->dev); 130 130 struct asus_wireless_data *data; 131 131 const struct acpi_device_id *id; 132 132 int err; 133 133 134 - data = devm_kzalloc(&adev->dev, sizeof(*data), GFP_KERNEL); 134 + data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); 135 135 if (!data) 136 136 return -ENOMEM; 137 - adev->driver_data = data; 137 + 138 + platform_set_drvdata(pdev, data); 139 + 138 140 data->adev = adev; 139 141 140 - data->idev = devm_input_allocate_device(&adev->dev); 142 + data->idev = devm_input_allocate_device(&pdev->dev); 141 143 if (!data->idev) 142 144 return -ENOMEM; 143 145 data->idev->name = "Asus Wireless Radio Control"; ··· 169 165 data->led.flags = LED_CORE_SUSPENDRESUME; 170 166 data->led.max_brightness = 1; 171 167 data->led.default_trigger = "rfkill-none"; 172 - err = devm_led_classdev_register(&adev->dev, &data->led); 168 + err = devm_led_classdev_register(&pdev->dev, &data->led); 173 169 if (err) 174 170 goto err; 175 171 176 172 err = acpi_dev_install_notify_handler(adev, ACPI_DEVICE_NOTIFY, 177 173 asus_wireless_notify, data); 178 174 if (err) { 179 - devm_led_classdev_unregister(&adev->dev, &data->led); 175 + devm_led_classdev_unregister(&pdev->dev, &data->led); 180 176 goto err; 181 177 } 182 178 return 0; ··· 186 182 return err; 187 183 } 188 184 189 - static void asus_wireless_remove(struct acpi_device *adev) 185 + static void asus_wireless_remove(struct platform_device *pdev) 190 186 { 191 - struct asus_wireless_data *data = acpi_driver_data(adev); 187 + struct asus_wireless_data *data = platform_get_drvdata(pdev); 192 188 193 - acpi_dev_remove_notify_handler(adev, ACPI_DEVICE_NOTIFY, 189 + acpi_dev_remove_notify_handler(data->adev, ACPI_DEVICE_NOTIFY, 194 190 asus_wireless_notify); 195 191 if (data->wq) { 196 - devm_led_classdev_unregister(&adev->dev, &data->led); 192 + devm_led_classdev_unregister(&pdev->dev, &data->led); 197 193 destroy_workqueue(data->wq); 198 194 } 199 195 } 200 196 201 - static struct acpi_driver asus_wireless_driver = { 202 - .name = "Asus Wireless Radio Control Driver", 203 - .class = "hotkey", 204 - .ids = device_ids, 205 - .ops = { 206 - .add = asus_wireless_add, 207 - .remove = asus_wireless_remove, 197 + static struct platform_driver asus_wireless_driver = { 198 + .probe = asus_wireless_probe, 199 + .remove = asus_wireless_remove, 200 + .driver = { 201 + .name = "Asus Wireless Radio Control Driver", 202 + .acpi_match_table = device_ids, 208 203 }, 209 204 }; 210 - module_acpi_driver(asus_wireless_driver); 205 + module_platform_driver(asus_wireless_driver); 211 206 212 207 MODULE_DESCRIPTION("Asus Wireless Radio Control Driver"); 213 208 MODULE_AUTHOR("João Paulo Rechi Vita <jprvita@gmail.com>");