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

net: ethernet: amd: au1000_eth: 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
phydev 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
1e8b7389 a1b198b7

+16 -25
+16 -24
drivers/net/ethernet/amd/au1000_eth.c
··· 412 412 au1000_adjust_link(struct net_device *dev) 413 413 { 414 414 struct au1000_private *aup = netdev_priv(dev); 415 - struct phy_device *phydev = aup->phy_dev; 415 + struct phy_device *phydev = dev->phydev; 416 416 unsigned long flags; 417 417 u32 reg; 418 418 419 419 int status_change = 0; 420 420 421 - BUG_ON(!aup->phy_dev); 421 + BUG_ON(!phydev); 422 422 423 423 spin_lock_irqsave(&aup->lock, flags); 424 424 ··· 579 579 aup->old_link = 0; 580 580 aup->old_speed = 0; 581 581 aup->old_duplex = -1; 582 - aup->phy_dev = phydev; 583 582 584 583 phy_attached_info(phydev); 585 584 ··· 679 680 680 681 static int au1000_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) 681 682 { 682 - struct au1000_private *aup = netdev_priv(dev); 683 - 684 - if (aup->phy_dev) 685 - return phy_ethtool_gset(aup->phy_dev, cmd); 683 + if (dev->phydev) 684 + return phy_ethtool_gset(dev->phydev, cmd); 686 685 687 686 return -EINVAL; 688 687 } 689 688 690 689 static int au1000_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) 691 690 { 692 - struct au1000_private *aup = netdev_priv(dev); 693 - 694 691 if (!capable(CAP_NET_ADMIN)) 695 692 return -EPERM; 696 693 697 - if (aup->phy_dev) 698 - return phy_ethtool_sset(aup->phy_dev, cmd); 694 + if (dev->phydev) 695 + return phy_ethtool_sset(dev->phydev, cmd); 699 696 700 697 return -EINVAL; 701 698 } ··· 773 778 #ifndef CONFIG_CPU_LITTLE_ENDIAN 774 779 control |= MAC_BIG_ENDIAN; 775 780 #endif 776 - if (aup->phy_dev) { 777 - if (aup->phy_dev->link && (DUPLEX_FULL == aup->phy_dev->duplex)) 781 + if (dev->phydev) { 782 + if (dev->phydev->link && (DUPLEX_FULL == dev->phydev->duplex)) 778 783 control |= MAC_FULL_DUPLEX; 779 784 else 780 785 control |= MAC_DISABLE_RX_OWN; ··· 886 891 887 892 static void au1000_update_tx_stats(struct net_device *dev, u32 status) 888 893 { 889 - struct au1000_private *aup = netdev_priv(dev); 890 894 struct net_device_stats *ps = &dev->stats; 891 895 892 896 if (status & TX_FRAME_ABORTED) { 893 - if (!aup->phy_dev || (DUPLEX_FULL == aup->phy_dev->duplex)) { 897 + if (!dev->phydev || (DUPLEX_FULL == dev->phydev->duplex)) { 894 898 if (status & (TX_JAB_TIMEOUT | TX_UNDERRUN)) { 895 899 /* any other tx errors are only valid 896 900 * in half duplex mode ··· 969 975 return retval; 970 976 } 971 977 972 - if (aup->phy_dev) { 978 + if (dev->phydev) { 973 979 /* cause the PHY state machine to schedule a link state check */ 974 - aup->phy_dev->state = PHY_CHANGELINK; 975 - phy_start(aup->phy_dev); 980 + dev->phydev->state = PHY_CHANGELINK; 981 + phy_start(dev->phydev); 976 982 } 977 983 978 984 netif_start_queue(dev); ··· 989 995 990 996 netif_dbg(aup, drv, dev, "close: dev=%p\n", dev); 991 997 992 - if (aup->phy_dev) 993 - phy_stop(aup->phy_dev); 998 + if (dev->phydev) 999 + phy_stop(dev->phydev); 994 1000 995 1001 spin_lock_irqsave(&aup->lock, flags); 996 1002 ··· 1104 1110 1105 1111 static int au1000_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) 1106 1112 { 1107 - struct au1000_private *aup = netdev_priv(dev); 1108 - 1109 1113 if (!netif_running(dev)) 1110 1114 return -EINVAL; 1111 1115 1112 - if (!aup->phy_dev) 1116 + if (!dev->phydev) 1113 1117 return -EINVAL; /* PHY not controllable */ 1114 1118 1115 - return phy_mii_ioctl(aup->phy_dev, rq, cmd); 1119 + return phy_mii_ioctl(dev->phydev, rq, cmd); 1116 1120 } 1117 1121 1118 1122 static const struct net_device_ops au1000_netdev_ops = {
-1
drivers/net/ethernet/amd/au1000_eth.h
··· 106 106 int old_speed; 107 107 int old_duplex; 108 108 109 - struct phy_device *phy_dev; 110 109 struct mii_bus *mii_bus; 111 110 112 111 /* PHY configuration */