public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] ptp: vmw: Convert to a platform driver
@ 2026-03-14 11:43 Rafael J. Wysocki
  2026-03-17 16:32 ` Simon Horman
  2026-03-18  3:20 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2026-03-14 11:43 UTC (permalink / raw)
  To: netdev
  Cc: LKML, Linux ACPI, Richard Cochran, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni

From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>

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>
---
 drivers/ptp/ptp_vmw.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/drivers/ptp/ptp_vmw.c b/drivers/ptp/ptp_vmw.c
index 20ab05c4daa8..8510121d79d1 100644
--- a/drivers/ptp/ptp_vmw.c
+++ b/drivers/ptp/ptp_vmw.c
@@ -10,6 +10,7 @@
 #include <linux/acpi.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/platform_device.h>
 #include <linux/ptp_clock_kernel.h>
 #include <asm/hypervisor.h>
 #include <asm/vmware.h>
@@ -83,7 +84,7 @@ static struct ptp_clock_info ptp_vmw_clock_info = {
  * ACPI driver ops for VMware "precision clock" virtual device.
  */
 
-static int ptp_vmw_acpi_add(struct acpi_device *device)
+static int ptp_vmw_acpi_probe(struct platform_device *pdev)
 {
 	ptp_vmw_clock = ptp_clock_register(&ptp_vmw_clock_info, NULL);
 	if (IS_ERR(ptp_vmw_clock)) {
@@ -91,11 +92,11 @@ static int ptp_vmw_acpi_add(struct acpi_device *device)
 		return PTR_ERR(ptp_vmw_clock);
 	}
 
-	ptp_vmw_acpi_device = device;
+	ptp_vmw_acpi_device = ACPI_COMPANION(&pdev->dev);
 	return 0;
 }
 
-static void ptp_vmw_acpi_remove(struct acpi_device *device)
+static void ptp_vmw_acpi_remove(struct platform_device *pdev)
 {
 	ptp_clock_unregister(ptp_vmw_clock);
 }
@@ -107,12 +108,12 @@ static const struct acpi_device_id ptp_vmw_acpi_device_ids[] = {
 
 MODULE_DEVICE_TABLE(acpi, ptp_vmw_acpi_device_ids);
 
-static struct acpi_driver ptp_vmw_acpi_driver = {
-	.name = "ptp_vmw",
-	.ids = ptp_vmw_acpi_device_ids,
-	.ops = {
-		.add = ptp_vmw_acpi_add,
-		.remove	= ptp_vmw_acpi_remove
+static struct platform_driver ptp_vmw_acpi_driver = {
+	.probe = ptp_vmw_acpi_probe,
+	.remove = ptp_vmw_acpi_remove,
+	.driver = {
+		.name = "ptp_vmw_acpi",
+		.acpi_match_table = ptp_vmw_acpi_device_ids,
 	},
 };
 
@@ -120,12 +121,12 @@ static int __init ptp_vmw_init(void)
 {
 	if (x86_hyper_type != X86_HYPER_VMWARE)
 		return -1;
-	return acpi_bus_register_driver(&ptp_vmw_acpi_driver);
+	return platform_driver_register(&ptp_vmw_acpi_driver);
 }
 
 static void __exit ptp_vmw_exit(void)
 {
-	acpi_bus_unregister_driver(&ptp_vmw_acpi_driver);
+	platform_driver_unregister(&ptp_vmw_acpi_driver);
 }
 
 module_init(ptp_vmw_init);
-- 
2.51.0





^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] ptp: vmw: Convert to a platform driver
  2026-03-14 11:43 [PATCH v1] ptp: vmw: Convert to a platform driver Rafael J. Wysocki
@ 2026-03-17 16:32 ` Simon Horman
  2026-03-18  3:20 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2026-03-17 16:32 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: netdev, LKML, Linux ACPI, Richard Cochran, Andrew Lunn,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni

On Sat, Mar 14, 2026 at 12:43:33PM +0100, Rafael J. Wysocki wrote:
> From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
> 
> 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>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] ptp: vmw: Convert to a platform driver
  2026-03-14 11:43 [PATCH v1] ptp: vmw: Convert to a platform driver Rafael J. Wysocki
  2026-03-17 16:32 ` Simon Horman
@ 2026-03-18  3:20 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-03-18  3:20 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: netdev, linux-kernel, linux-acpi, richardcochran, andrew+netdev,
	davem, edumazet, kuba, pabeni

Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Sat, 14 Mar 2026 12:43:33 +0100 you wrote:
> From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
> 
> 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].
> 
> [...]

Here is the summary with links:
  - [v1] ptp: vmw: Convert to a platform driver
    https://git.kernel.org/netdev/net-next/c/6829f90906aa

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-03-18  3:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-14 11:43 [PATCH v1] ptp: vmw: Convert to a platform driver Rafael J. Wysocki
2026-03-17 16:32 ` Simon Horman
2026-03-18  3:20 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox