Commit 1ef76158 authored by Richard Cochran's avatar Richard Cochran Committed by David S. Miller

ptp: link the phc device to its parent device

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: default avatarRichard Cochran <richardcochran@gmail.com>
Acked-by: default avatarBen Hutchings <bhutchings@solarflare.com>
Acked-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5c35bad5
...@@ -510,7 +510,7 @@ static int gianfar_ptp_probe(struct platform_device *dev) ...@@ -510,7 +510,7 @@ static int gianfar_ptp_probe(struct platform_device *dev)
spin_unlock_irqrestore(&etsects->lock, flags); 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)) { if (IS_ERR(etsects->clock)) {
err = PTR_ERR(etsects->clock); err = PTR_ERR(etsects->clock);
goto no_clock; goto no_clock;
......
...@@ -752,7 +752,8 @@ void igb_ptp_init(struct igb_adapter *adapter) ...@@ -752,7 +752,8 @@ void igb_ptp_init(struct igb_adapter *adapter)
wr32(E1000_IMS, E1000_IMS_TS); 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)) { if (IS_ERR(adapter->ptp_clock)) {
adapter->ptp_clock = NULL; adapter->ptp_clock = NULL;
dev_err(&adapter->pdev->dev, "ptp_clock_register failed\n"); dev_err(&adapter->pdev->dev, "ptp_clock_register failed\n");
......
...@@ -960,7 +960,8 @@ void ixgbe_ptp_init(struct ixgbe_adapter *adapter) ...@@ -960,7 +960,8 @@ void ixgbe_ptp_init(struct ixgbe_adapter *adapter)
/* (Re)start the overflow check */ /* (Re)start the overflow check */
adapter->flags2 |= IXGBE_FLAG2_OVERFLOW_CHECK_ENABLED; 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)) { if (IS_ERR(adapter->ptp_clock)) {
adapter->ptp_clock = NULL; adapter->ptp_clock = NULL;
e_dev_err("ptp_clock_register failed\n"); e_dev_err("ptp_clock_register failed\n");
......
...@@ -931,7 +931,8 @@ static int efx_ptp_probe_channel(struct efx_channel *channel) ...@@ -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.settime = efx_phc_settime;
ptp->phc_clock_info.enable = efx_phc_enable; 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) if (!ptp->phc_clock)
goto fail3; goto fail3;
......
...@@ -980,7 +980,7 @@ static int dp83640_probe(struct phy_device *phydev) ...@@ -980,7 +980,7 @@ static int dp83640_probe(struct phy_device *phydev)
if (choose_this_phy(clock, phydev)) { if (choose_this_phy(clock, phydev)) {
clock->chosen = dp83640; 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)) { if (IS_ERR(clock->ptp_clock)) {
err = PTR_ERR(clock->ptp_clock); err = PTR_ERR(clock->ptp_clock);
goto no_register; goto no_register;
......
...@@ -182,7 +182,8 @@ static void delete_ptp_clock(struct posix_clock *pc) ...@@ -182,7 +182,8 @@ static void delete_ptp_clock(struct posix_clock *pc)
/* public interface */ /* 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; struct ptp_clock *ptp;
int err = 0, index, major = MAJOR(ptp_devt); int err = 0, index, major = MAJOR(ptp_devt);
...@@ -215,7 +216,7 @@ struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info) ...@@ -215,7 +216,7 @@ struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info)
init_waitqueue_head(&ptp->tsev_wq); init_waitqueue_head(&ptp->tsev_wq);
/* Create a new device in our class. */ /* 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); "ptp%d", ptp->index);
if (IS_ERR(ptp->dev)) if (IS_ERR(ptp->dev))
goto no_device; goto no_device;
......
...@@ -298,7 +298,7 @@ static int __init ptp_ixp_init(void) ...@@ -298,7 +298,7 @@ static int __init ptp_ixp_init(void)
ixp_clock.caps = ptp_ixp_caps; 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)) if (IS_ERR(ixp_clock.ptp_clock))
return PTR_ERR(ixp_clock.ptp_clock); return PTR_ERR(ixp_clock.ptp_clock);
......
...@@ -627,7 +627,7 @@ pch_probe(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -627,7 +627,7 @@ pch_probe(struct pci_dev *pdev, const struct pci_device_id *id)
} }
chip->caps = ptp_pch_caps; 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)) if (IS_ERR(chip->ptp_clock))
return PTR_ERR(chip->ptp_clock); return PTR_ERR(chip->ptp_clock);
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#ifndef _PTP_CLOCK_KERNEL_H_ #ifndef _PTP_CLOCK_KERNEL_H_
#define _PTP_CLOCK_KERNEL_H_ #define _PTP_CLOCK_KERNEL_H_
#include <linux/device.h>
#include <linux/pps_kernel.h> #include <linux/pps_kernel.h>
#include <linux/ptp_clock.h> #include <linux/ptp_clock.h>
...@@ -94,9 +95,11 @@ struct ptp_clock; ...@@ -94,9 +95,11 @@ struct ptp_clock;
* ptp_clock_register() - register a PTP hardware clock driver * 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 * ptp_clock_unregister() - unregister a PTP hardware clock driver
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment