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

net: ethernet: gianfar_ethtool: get phc index through drvdata

Global variable gfar_phc_index was used to get and store
phc index through gianfar_ptp driver. However gianfar_ptp
had been renamed as ptp_qoriq for QorIQ common PTP driver.
This gfar_phc_index doesn't work any more, and the phc index
is stored in drvdata now. This patch is to support getting
phc index through ptp_qoriq drvdata.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Yangbo Lu and committed by
David S. Miller
7349a74e 6c50c1ed

+18 -8
-3
drivers/net/ethernet/freescale/gianfar.h
··· 1372 1372 struct gfar_filer_entry fe[MAX_FILER_CACHE_IDX + 20]; 1373 1373 }; 1374 1374 1375 - /* The gianfar_ptp module will set this variable */ 1376 - extern int gfar_phc_index; 1377 - 1378 1375 #endif /* __GIANFAR_H */
+18 -5
drivers/net/ethernet/freescale/gianfar_ethtool.c
··· 41 41 #include <linux/phy.h> 42 42 #include <linux/sort.h> 43 43 #include <linux/if_vlan.h> 44 + #include <linux/of_platform.h> 45 + #include <linux/fsl/ptp_qoriq.h> 44 46 45 47 #include "gianfar.h" 46 48 ··· 1511 1509 return ret; 1512 1510 } 1513 1511 1514 - int gfar_phc_index = -1; 1515 - EXPORT_SYMBOL(gfar_phc_index); 1516 - 1517 1512 static int gfar_get_ts_info(struct net_device *dev, 1518 1513 struct ethtool_ts_info *info) 1519 1514 { 1520 1515 struct gfar_private *priv = netdev_priv(dev); 1516 + struct platform_device *ptp_dev; 1517 + struct device_node *ptp_node; 1518 + struct qoriq_ptp *ptp = NULL; 1519 + 1520 + info->phc_index = -1; 1521 1521 1522 1522 if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_TIMER)) { 1523 1523 info->so_timestamping = SOF_TIMESTAMPING_RX_SOFTWARE | 1524 1524 SOF_TIMESTAMPING_SOFTWARE; 1525 - info->phc_index = -1; 1526 1525 return 0; 1527 1526 } 1527 + 1528 + ptp_node = of_find_compatible_node(NULL, NULL, "fsl,etsec-ptp"); 1529 + if (ptp_node) { 1530 + ptp_dev = of_find_device_by_node(ptp_node); 1531 + if (ptp_dev) 1532 + ptp = platform_get_drvdata(ptp_dev); 1533 + } 1534 + 1535 + if (ptp) 1536 + info->phc_index = ptp->phc_index; 1537 + 1528 1538 info->so_timestamping = SOF_TIMESTAMPING_TX_HARDWARE | 1529 1539 SOF_TIMESTAMPING_RX_HARDWARE | 1530 1540 SOF_TIMESTAMPING_RAW_HARDWARE; 1531 - info->phc_index = gfar_phc_index; 1532 1541 info->tx_types = (1 << HWTSTAMP_TX_OFF) | 1533 1542 (1 << HWTSTAMP_TX_ON); 1534 1543 info->rx_filters = (1 << HWTSTAMP_FILTER_NONE) |