ptp: link the phc device to its parent device
authorRichard Cochran <richardcochran@gmail.com>
Sat, 22 Sep 2012 07:02:03 +0000 (07:02 +0000)
committerDavid S. Miller <davem@davemloft.net>
Sat, 22 Sep 2012 19:42:38 +0000 (15:42 -0400)
PTP Hardware Clock devices appear as class devices in sysfs. This patch
changes the registration API to use the parent device, clarifying the
clock's relationship to the underlying device.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Acked-by: Ben Hutchings <bhutchings@solarflare.com>
Acked-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/freescale/gianfar_ptp.c
drivers/net/ethernet/intel/igb/igb_ptp.c
drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
drivers/net/ethernet/sfc/ptp.c
drivers/net/phy/dp83640.c
drivers/ptp/ptp_clock.c
drivers/ptp/ptp_ixp46x.c
drivers/ptp/ptp_pch.c
include/linux/ptp_clock_kernel.h

index c08e5d40fecb425c7f6c26b8de269d270bac727f..18762a3ccce4a812e779336cb6f329ccc23a62d7 100644 (file)
@@ -510,7 +510,7 @@ static int gianfar_ptp_probe(struct platform_device *dev)
 
        spin_unlock_irqrestore(&etsects->lock, flags);
 
-       etsects->clock = ptp_clock_register(&etsects->caps);
+       etsects->clock = ptp_clock_register(&etsects->caps, &dev->dev);
        if (IS_ERR(etsects->clock)) {
                err = PTR_ERR(etsects->clock);
                goto no_clock;
index e13ba1d5369fced6e6b26c0a1d722184600fa3a8..ee21445157a3e8907a7b01267806d10b3ffab6e2 100644 (file)
@@ -752,7 +752,8 @@ void igb_ptp_init(struct igb_adapter *adapter)
                wr32(E1000_IMS, E1000_IMS_TS);
        }
 
-       adapter->ptp_clock = ptp_clock_register(&adapter->ptp_caps);
+       adapter->ptp_clock = ptp_clock_register(&adapter->ptp_caps,
+                                               &adapter->pdev->dev);
        if (IS_ERR(adapter->ptp_clock)) {
                adapter->ptp_clock = NULL;
                dev_err(&adapter->pdev->dev, "ptp_clock_register failed\n");
index 3456d56171437cfbab401c39e3db6ad08c153782..39881cb17a4b5fe8958b8e0aead9188feaaf0370 100644 (file)
@@ -960,7 +960,8 @@ void ixgbe_ptp_init(struct ixgbe_adapter *adapter)
        /* (Re)start the overflow check */
        adapter->flags2 |= IXGBE_FLAG2_OVERFLOW_CHECK_ENABLED;
 
-       adapter->ptp_clock = ptp_clock_register(&adapter->ptp_caps);
+       adapter->ptp_clock = ptp_clock_register(&adapter->ptp_caps,
+                                               &adapter->pdev->dev);
        if (IS_ERR(adapter->ptp_clock)) {
                adapter->ptp_clock = NULL;
                e_dev_err("ptp_clock_register failed\n");
index 2b07a4eae07e88bb23eaffe41938fd4df7f50b95..5b3dd028ce852a267833254bf4c5f28fcf9acf7e 100644 (file)
@@ -931,7 +931,8 @@ static int efx_ptp_probe_channel(struct efx_channel *channel)
        ptp->phc_clock_info.settime = efx_phc_settime;
        ptp->phc_clock_info.enable = efx_phc_enable;
 
-       ptp->phc_clock = ptp_clock_register(&ptp->phc_clock_info);
+       ptp->phc_clock = ptp_clock_register(&ptp->phc_clock_info,
+                                           &efx->pci_dev->dev);
        if (!ptp->phc_clock)
                goto fail3;
 
index b0da0226661f76b1c9af768cc1eeb6f21d5e1b61..24e05c43bff872e34e35e1deb4d385884057ae4a 100644 (file)
@@ -980,7 +980,7 @@ static int dp83640_probe(struct phy_device *phydev)
 
        if (choose_this_phy(clock, phydev)) {
                clock->chosen = dp83640;
-               clock->ptp_clock = ptp_clock_register(&clock->caps);
+               clock->ptp_clock = ptp_clock_register(&clock->caps, &phydev->dev);
                if (IS_ERR(clock->ptp_clock)) {
                        err = PTR_ERR(clock->ptp_clock);
                        goto no_register;
index c470ddf1a6fa878a0e6dca07de3bdd662d9e76c0..79f4bce061bd289d5f01a35601ad151f73ee8d80 100644 (file)
@@ -182,7 +182,8 @@ static void delete_ptp_clock(struct posix_clock *pc)
 
 /* public interface */
 
-struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info)
+struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info,
+                                    struct device *parent)
 {
        struct ptp_clock *ptp;
        int err = 0, index, major = MAJOR(ptp_devt);
@@ -215,7 +216,7 @@ struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info)
        init_waitqueue_head(&ptp->tsev_wq);
 
        /* Create a new device in our class. */
-       ptp->dev = device_create(ptp_class, NULL, ptp->devid, ptp,
+       ptp->dev = device_create(ptp_class, parent, ptp->devid, ptp,
                                 "ptp%d", ptp->index);
        if (IS_ERR(ptp->dev))
                goto no_device;
index e03c40692b0073106f845f9adbb1d38250590e76..d49b85164fd22e830f51e066337801134eef9354 100644 (file)
@@ -298,7 +298,7 @@ static int __init ptp_ixp_init(void)
 
        ixp_clock.caps = ptp_ixp_caps;
 
-       ixp_clock.ptp_clock = ptp_clock_register(&ixp_clock.caps);
+       ixp_clock.ptp_clock = ptp_clock_register(&ixp_clock.caps, NULL);
 
        if (IS_ERR(ixp_clock.ptp_clock))
                return PTR_ERR(ixp_clock.ptp_clock);
index 3a9c17eced10c3a34d591fd465db555ec9498b88..e624e4dd2abb001444c08dc0593800ddab9f8da0 100644 (file)
@@ -627,7 +627,7 @@ pch_probe(struct pci_dev *pdev, const struct pci_device_id *id)
        }
 
        chip->caps = ptp_pch_caps;
-       chip->ptp_clock = ptp_clock_register(&chip->caps);
+       chip->ptp_clock = ptp_clock_register(&chip->caps, &pdev->dev);
 
        if (IS_ERR(chip->ptp_clock))
                return PTR_ERR(chip->ptp_clock);
index a644b29f116125830dd8c5c01e06a05eace8db70..56c71b27112eaf2a26397b7c93e7813c8864c05a 100644 (file)
@@ -21,6 +21,7 @@
 #ifndef _PTP_CLOCK_KERNEL_H_
 #define _PTP_CLOCK_KERNEL_H_
 
+#include <linux/device.h>
 #include <linux/pps_kernel.h>
 #include <linux/ptp_clock.h>
 
@@ -93,10 +94,12 @@ struct ptp_clock;
 /**
  * ptp_clock_register() - register a PTP hardware clock driver
  *
- * @info:  Structure describing the new clock.
+ * @info:   Structure describing the new clock.
+ * @parent: Pointer to the parent device of the new clock.
  */
 
-extern struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info);
+extern struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info,
+                                           struct device *parent);
 
 /**
  * ptp_clock_unregister() - unregister a PTP hardware clock driver