diff options
author | Philippe Reynes <tremyfr@gmail.com> | 2016-07-02 14:06:51 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-07-04 18:59:52 -0400 |
commit | 01dea536dc4e8eccd0d7741ec0e3dacd3060055c (patch) | |
tree | cee00777197cbb801ea544a2ff9043c8b5a2f80d /drivers/net/ethernet/arc/emac_main.c | |
parent | fa018484cf5ea67678143c4570b63154fa819682 (diff) |
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>
Diffstat (limited to 'drivers/net/ethernet/arc/emac_main.c')
-rw-r--r-- | drivers/net/ethernet/arc/emac_main.c | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/drivers/net/ethernet/arc/emac_main.c b/drivers/net/ethernet/arc/emac_main.c index a3a9392a4954..a8a1dc9f6725 100644 --- a/drivers/net/ethernet/arc/emac_main.c +++ b/drivers/net/ethernet/arc/emac_main.c | |||
@@ -47,7 +47,7 @@ static inline int arc_emac_tx_avail(struct arc_emac_priv *priv) | |||
47 | static void arc_emac_adjust_link(struct net_device *ndev) | 47 | static void arc_emac_adjust_link(struct net_device *ndev) |
48 | { | 48 | { |
49 | struct arc_emac_priv *priv = netdev_priv(ndev); | 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 | unsigned int reg, state_changed = 0; | 51 | unsigned int reg, state_changed = 0; |
52 | 52 | ||
53 | if (priv->link != phy_dev->link) { | 53 | if (priv->link != phy_dev->link) { |
@@ -92,9 +92,7 @@ static void arc_emac_adjust_link(struct net_device *ndev) | |||
92 | static int arc_emac_get_settings(struct net_device *ndev, | 92 | static int arc_emac_get_settings(struct net_device *ndev, |
93 | struct ethtool_cmd *cmd) | 93 | struct ethtool_cmd *cmd) |
94 | { | 94 | { |
95 | struct arc_emac_priv *priv = netdev_priv(ndev); | 95 | return phy_ethtool_gset(ndev->phydev, cmd); |
96 | |||
97 | return phy_ethtool_gset(priv->phy_dev, cmd); | ||
98 | } | 96 | } |
99 | 97 | ||
100 | /** | 98 | /** |
@@ -111,12 +109,10 @@ static int arc_emac_get_settings(struct net_device *ndev, | |||
111 | static int arc_emac_set_settings(struct net_device *ndev, | 109 | static int arc_emac_set_settings(struct net_device *ndev, |
112 | struct ethtool_cmd *cmd) | 110 | struct ethtool_cmd *cmd) |
113 | { | 111 | { |
114 | struct arc_emac_priv *priv = netdev_priv(ndev); | ||
115 | |||
116 | if (!capable(CAP_NET_ADMIN)) | 112 | if (!capable(CAP_NET_ADMIN)) |
117 | return -EPERM; | 113 | return -EPERM; |
118 | 114 | ||
119 | return phy_ethtool_sset(priv->phy_dev, cmd); | 115 | return phy_ethtool_sset(ndev->phydev, cmd); |
120 | } | 116 | } |
121 | 117 | ||
122 | /** | 118 | /** |
@@ -403,7 +399,7 @@ static void arc_emac_poll_controller(struct net_device *dev) | |||
403 | static int arc_emac_open(struct net_device *ndev) | 399 | static int arc_emac_open(struct net_device *ndev) |
404 | { | 400 | { |
405 | struct arc_emac_priv *priv = netdev_priv(ndev); | 401 | struct arc_emac_priv *priv = netdev_priv(ndev); |
406 | struct phy_device *phy_dev = priv->phy_dev; | 402 | struct phy_device *phy_dev = ndev->phydev; |
407 | int i; | 403 | int i; |
408 | 404 | ||
409 | phy_dev->autoneg = AUTONEG_ENABLE; | 405 | phy_dev->autoneg = AUTONEG_ENABLE; |
@@ -474,7 +470,7 @@ static int arc_emac_open(struct net_device *ndev) | |||
474 | /* Enable EMAC */ | 470 | /* Enable EMAC */ |
475 | arc_reg_or(priv, R_CTRL, EN_MASK); | 471 | arc_reg_or(priv, R_CTRL, EN_MASK); |
476 | 472 | ||
477 | phy_start_aneg(priv->phy_dev); | 473 | phy_start_aneg(ndev->phydev); |
478 | 474 | ||
479 | netif_start_queue(ndev); | 475 | netif_start_queue(ndev); |
480 | 476 | ||
@@ -772,6 +768,7 @@ int arc_emac_probe(struct net_device *ndev, int interface) | |||
772 | struct device *dev = ndev->dev.parent; | 768 | struct device *dev = ndev->dev.parent; |
773 | struct resource res_regs; | 769 | struct resource res_regs; |
774 | struct device_node *phy_node; | 770 | struct device_node *phy_node; |
771 | struct phy_device *phydev = NULL; | ||
775 | struct arc_emac_priv *priv; | 772 | struct arc_emac_priv *priv; |
776 | const char *mac_addr; | 773 | const char *mac_addr; |
777 | unsigned int id, clock_frequency, irq; | 774 | unsigned int id, clock_frequency, irq; |
@@ -887,16 +884,16 @@ int arc_emac_probe(struct net_device *ndev, int interface) | |||
887 | goto out_clken; | 884 | goto out_clken; |
888 | } | 885 | } |
889 | 886 | ||
890 | priv->phy_dev = of_phy_connect(ndev, phy_node, arc_emac_adjust_link, 0, | 887 | phydev = of_phy_connect(ndev, phy_node, arc_emac_adjust_link, 0, |
891 | interface); | 888 | interface); |
892 | if (!priv->phy_dev) { | 889 | if (!phydev) { |
893 | dev_err(dev, "of_phy_connect() failed\n"); | 890 | dev_err(dev, "of_phy_connect() failed\n"); |
894 | err = -ENODEV; | 891 | err = -ENODEV; |
895 | goto out_mdio; | 892 | goto out_mdio; |
896 | } | 893 | } |
897 | 894 | ||
898 | dev_info(dev, "connected to %s phy with id 0x%x\n", | 895 | dev_info(dev, "connected to %s phy with id 0x%x\n", |
899 | priv->phy_dev->drv->name, priv->phy_dev->phy_id); | 896 | phydev->drv->name, phydev->phy_id); |
900 | 897 | ||
901 | netif_napi_add(ndev, &priv->napi, arc_emac_poll, ARC_EMAC_NAPI_WEIGHT); | 898 | netif_napi_add(ndev, &priv->napi, arc_emac_poll, ARC_EMAC_NAPI_WEIGHT); |
902 | 899 | ||
@@ -910,8 +907,7 @@ int arc_emac_probe(struct net_device *ndev, int interface) | |||
910 | 907 | ||
911 | out_netif_api: | 908 | out_netif_api: |
912 | netif_napi_del(&priv->napi); | 909 | netif_napi_del(&priv->napi); |
913 | phy_disconnect(priv->phy_dev); | 910 | phy_disconnect(phydev); |
914 | priv->phy_dev = NULL; | ||
915 | out_mdio: | 911 | out_mdio: |
916 | arc_mdio_remove(priv); | 912 | arc_mdio_remove(priv); |
917 | out_clken: | 913 | out_clken: |
@@ -925,8 +921,7 @@ int arc_emac_remove(struct net_device *ndev) | |||
925 | { | 921 | { |
926 | struct arc_emac_priv *priv = netdev_priv(ndev); | 922 | struct arc_emac_priv *priv = netdev_priv(ndev); |
927 | 923 | ||
928 | phy_disconnect(priv->phy_dev); | 924 | phy_disconnect(ndev->phydev); |
929 | priv->phy_dev = NULL; | ||
930 | arc_mdio_remove(priv); | 925 | arc_mdio_remove(priv); |
931 | unregister_netdev(ndev); | 926 | unregister_netdev(ndev); |
932 | netif_napi_del(&priv->napi); | 927 | netif_napi_del(&priv->napi); |