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

net: ethernet: xilinx: axienet: use phydev from struct net_device

The private structure contain a pointer to phydev, but the structure
net_device already contain such pointer. So we can remove the pointer
phy in the private structure, and update the driver to use the
one contained in struct net_device.

Signed-off-by: Philippe Reynes <tremyfr@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Philippe Reynes and committed by
David S. Miller
b1b7dcff 3a11d9ef

+16 -21
-2
drivers/net/ethernet/xilinx/xilinx_axienet.h
··· 382 382 * struct axienet_local - axienet private per device data 383 383 * @ndev: Pointer for net_device to which it will be attached. 384 384 * @dev: Pointer to device structure 385 - * @phy_dev: Pointer to PHY device structure attached to the axienet_local 386 385 * @phy_node: Pointer to device node structure 387 386 * @mii_bus: Pointer to MII bus structure 388 387 * @regs: Base address for the axienet_local device address space ··· 419 420 struct device *dev; 420 421 421 422 /* Connection to PHY device */ 422 - struct phy_device *phy_dev; /* Pointer to PHY device */ 423 423 struct device_node *phy_node; 424 424 425 425 /* MDIO bus data */
+16 -19
drivers/net/ethernet/xilinx/xilinx_axienet_main.c
··· 525 525 u32 link_state; 526 526 u32 setspeed = 1; 527 527 struct axienet_local *lp = netdev_priv(ndev); 528 - struct phy_device *phy = lp->phy_dev; 528 + struct phy_device *phy = ndev->phydev; 529 529 530 530 link_state = phy->speed | (phy->duplex << 1) | phy->link; 531 531 if (lp->last_link != link_state) { ··· 911 911 { 912 912 int ret, mdio_mcreg; 913 913 struct axienet_local *lp = netdev_priv(ndev); 914 + struct phy_device *phydev = NULL; 914 915 915 916 dev_dbg(&ndev->dev, "axienet_open()\n"); 916 917 ··· 935 934 936 935 if (lp->phy_node) { 937 936 if (lp->phy_type == XAE_PHY_TYPE_GMII) { 938 - lp->phy_dev = of_phy_connect(lp->ndev, lp->phy_node, 939 - axienet_adjust_link, 0, 940 - PHY_INTERFACE_MODE_GMII); 937 + phydev = of_phy_connect(lp->ndev, lp->phy_node, 938 + axienet_adjust_link, 0, 939 + PHY_INTERFACE_MODE_GMII); 941 940 } else if (lp->phy_type == XAE_PHY_TYPE_RGMII_2_0) { 942 - lp->phy_dev = of_phy_connect(lp->ndev, lp->phy_node, 943 - axienet_adjust_link, 0, 944 - PHY_INTERFACE_MODE_RGMII_ID); 941 + phydev = of_phy_connect(lp->ndev, lp->phy_node, 942 + axienet_adjust_link, 0, 943 + PHY_INTERFACE_MODE_RGMII_ID); 945 944 } 946 945 947 - if (!lp->phy_dev) 946 + if (!phydev) 948 947 dev_err(lp->dev, "of_phy_connect() failed\n"); 949 948 else 950 - phy_start(lp->phy_dev); 949 + phy_start(phydev); 951 950 } 952 951 953 952 /* Enable tasklets for Axi DMA error handling */ ··· 968 967 err_rx_irq: 969 968 free_irq(lp->tx_irq, ndev); 970 969 err_tx_irq: 971 - if (lp->phy_dev) 972 - phy_disconnect(lp->phy_dev); 973 - lp->phy_dev = NULL; 970 + if (phydev) 971 + phy_disconnect(phydev); 974 972 tasklet_kill(&lp->dma_err_tasklet); 975 973 dev_err(lp->dev, "request_irq() failed\n"); 976 974 return ret; ··· 1006 1006 free_irq(lp->tx_irq, ndev); 1007 1007 free_irq(lp->rx_irq, ndev); 1008 1008 1009 - if (lp->phy_dev) 1010 - phy_disconnect(lp->phy_dev); 1011 - lp->phy_dev = NULL; 1009 + if (ndev->phydev) 1010 + phy_disconnect(ndev->phydev); 1012 1011 1013 1012 axienet_dma_bd_release(ndev); 1014 1013 return 0; ··· 1091 1092 static int axienet_ethtools_get_settings(struct net_device *ndev, 1092 1093 struct ethtool_cmd *ecmd) 1093 1094 { 1094 - struct axienet_local *lp = netdev_priv(ndev); 1095 - struct phy_device *phydev = lp->phy_dev; 1095 + struct phy_device *phydev = ndev->phydev; 1096 1096 if (!phydev) 1097 1097 return -ENODEV; 1098 1098 return phy_ethtool_gset(phydev, ecmd); ··· 1113 1115 static int axienet_ethtools_set_settings(struct net_device *ndev, 1114 1116 struct ethtool_cmd *ecmd) 1115 1117 { 1116 - struct axienet_local *lp = netdev_priv(ndev); 1117 - struct phy_device *phydev = lp->phy_dev; 1118 + struct phy_device *phydev = ndev->phydev; 1118 1119 if (!phydev) 1119 1120 return -ENODEV; 1120 1121 return phy_ethtool_sset(phydev, ecmd);