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

ptp: vmw: 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 PTP VMware 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: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/12883468.O9o76ZdvQC@rafael.j.wysocki
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Rafael J. Wysocki and committed by
Jakub Kicinski
6829f909 eb9744e2

+12 -11
+12 -11
drivers/ptp/ptp_vmw.c
··· 10 10 #include <linux/acpi.h> 11 11 #include <linux/kernel.h> 12 12 #include <linux/module.h> 13 + #include <linux/platform_device.h> 13 14 #include <linux/ptp_clock_kernel.h> 14 15 #include <asm/hypervisor.h> 15 16 #include <asm/vmware.h> ··· 84 83 * ACPI driver ops for VMware "precision clock" virtual device. 85 84 */ 86 85 87 - static int ptp_vmw_acpi_add(struct acpi_device *device) 86 + static int ptp_vmw_acpi_probe(struct platform_device *pdev) 88 87 { 89 88 ptp_vmw_clock = ptp_clock_register(&ptp_vmw_clock_info, NULL); 90 89 if (IS_ERR(ptp_vmw_clock)) { ··· 92 91 return PTR_ERR(ptp_vmw_clock); 93 92 } 94 93 95 - ptp_vmw_acpi_device = device; 94 + ptp_vmw_acpi_device = ACPI_COMPANION(&pdev->dev); 96 95 return 0; 97 96 } 98 97 99 - static void ptp_vmw_acpi_remove(struct acpi_device *device) 98 + static void ptp_vmw_acpi_remove(struct platform_device *pdev) 100 99 { 101 100 ptp_clock_unregister(ptp_vmw_clock); 102 101 } ··· 108 107 109 108 MODULE_DEVICE_TABLE(acpi, ptp_vmw_acpi_device_ids); 110 109 111 - static struct acpi_driver ptp_vmw_acpi_driver = { 112 - .name = "ptp_vmw", 113 - .ids = ptp_vmw_acpi_device_ids, 114 - .ops = { 115 - .add = ptp_vmw_acpi_add, 116 - .remove = ptp_vmw_acpi_remove 110 + static struct platform_driver ptp_vmw_acpi_driver = { 111 + .probe = ptp_vmw_acpi_probe, 112 + .remove = ptp_vmw_acpi_remove, 113 + .driver = { 114 + .name = "ptp_vmw_acpi", 115 + .acpi_match_table = ptp_vmw_acpi_device_ids, 117 116 }, 118 117 }; 119 118 ··· 121 120 { 122 121 if (x86_hyper_type != X86_HYPER_VMWARE) 123 122 return -1; 124 - return acpi_bus_register_driver(&ptp_vmw_acpi_driver); 123 + return platform_driver_register(&ptp_vmw_acpi_driver); 125 124 } 126 125 127 126 static void __exit ptp_vmw_exit(void) 128 127 { 129 - acpi_bus_unregister_driver(&ptp_vmw_acpi_driver); 128 + platform_driver_unregister(&ptp_vmw_acpi_driver); 130 129 } 131 130 132 131 module_init(ptp_vmw_init);