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

net: ethernet: arc: emac: 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
01dea536 fa018484

+12 -18
-1
drivers/net/ethernet/arc/emac.h
··· 134 134 135 135 /* Devices */ 136 136 struct device *dev; 137 - struct phy_device *phy_dev; 138 137 struct mii_bus *bus; 139 138 struct arc_emac_mdio_bus_data bus_data; 140 139
+12 -17
drivers/net/ethernet/arc/emac_main.c
··· 47 47 static void arc_emac_adjust_link(struct net_device *ndev) 48 48 { 49 49 struct arc_emac_priv *priv = netdev_priv(ndev); 50 - struct phy_device *phy_dev = priv->phy_dev; 50 + struct phy_device *phy_dev = ndev->phydev; 51 51 unsigned int reg, state_changed = 0; 52 52 53 53 if (priv->link != phy_dev->link) { ··· 92 92 static int arc_emac_get_settings(struct net_device *ndev, 93 93 struct ethtool_cmd *cmd) 94 94 { 95 - struct arc_emac_priv *priv = netdev_priv(ndev); 96 - 97 - return phy_ethtool_gset(priv->phy_dev, cmd); 95 + return phy_ethtool_gset(ndev->phydev, cmd); 98 96 } 99 97 100 98 /** ··· 109 111 static int arc_emac_set_settings(struct net_device *ndev, 110 112 struct ethtool_cmd *cmd) 111 113 { 112 - struct arc_emac_priv *priv = netdev_priv(ndev); 113 - 114 114 if (!capable(CAP_NET_ADMIN)) 115 115 return -EPERM; 116 116 117 - return phy_ethtool_sset(priv->phy_dev, cmd); 117 + return phy_ethtool_sset(ndev->phydev, cmd); 118 118 } 119 119 120 120 /** ··· 399 403 static int arc_emac_open(struct net_device *ndev) 400 404 { 401 405 struct arc_emac_priv *priv = netdev_priv(ndev); 402 - struct phy_device *phy_dev = priv->phy_dev; 406 + struct phy_device *phy_dev = ndev->phydev; 403 407 int i; 404 408 405 409 phy_dev->autoneg = AUTONEG_ENABLE; ··· 470 474 /* Enable EMAC */ 471 475 arc_reg_or(priv, R_CTRL, EN_MASK); 472 476 473 - phy_start_aneg(priv->phy_dev); 477 + phy_start_aneg(ndev->phydev); 474 478 475 479 netif_start_queue(ndev); 476 480 ··· 768 772 struct device *dev = ndev->dev.parent; 769 773 struct resource res_regs; 770 774 struct device_node *phy_node; 775 + struct phy_device *phydev = NULL; 771 776 struct arc_emac_priv *priv; 772 777 const char *mac_addr; 773 778 unsigned int id, clock_frequency, irq; ··· 884 887 goto out_clken; 885 888 } 886 889 887 - priv->phy_dev = of_phy_connect(ndev, phy_node, arc_emac_adjust_link, 0, 888 - interface); 889 - if (!priv->phy_dev) { 890 + phydev = of_phy_connect(ndev, phy_node, arc_emac_adjust_link, 0, 891 + interface); 892 + if (!phydev) { 890 893 dev_err(dev, "of_phy_connect() failed\n"); 891 894 err = -ENODEV; 892 895 goto out_mdio; 893 896 } 894 897 895 898 dev_info(dev, "connected to %s phy with id 0x%x\n", 896 - priv->phy_dev->drv->name, priv->phy_dev->phy_id); 899 + phydev->drv->name, phydev->phy_id); 897 900 898 901 netif_napi_add(ndev, &priv->napi, arc_emac_poll, ARC_EMAC_NAPI_WEIGHT); 899 902 ··· 907 910 908 911 out_netif_api: 909 912 netif_napi_del(&priv->napi); 910 - phy_disconnect(priv->phy_dev); 911 - priv->phy_dev = NULL; 913 + phy_disconnect(phydev); 912 914 out_mdio: 913 915 arc_mdio_remove(priv); 914 916 out_clken: ··· 921 925 { 922 926 struct arc_emac_priv *priv = netdev_priv(ndev); 923 927 924 - phy_disconnect(priv->phy_dev); 925 - priv->phy_dev = NULL; 928 + phy_disconnect(ndev->phydev); 926 929 arc_mdio_remove(priv); 927 930 unregister_netdev(ndev); 928 931 netif_napi_del(&priv->napi);