aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/smsc911x.c
diff options
context:
space:
mode:
authorSteve Glendinning <steve.glendinning@smsc.com>2008-12-16 05:00:48 -0500
committerDavid S. Miller <davem@davemloft.net>2008-12-16 05:00:48 -0500
commitbc02ff95fe4ebd3e5ee7455c0aa6f76ebe39ebca (patch)
tree675887b8007a53464e84b9da2f7b54a77fab035a /drivers/net/smsc911x.c
parente18ce3465477502108187c6c08b6423fb784a313 (diff)
net: Refactor full duplex flow control resolution
These 4 drivers have identical full duplex flow control resolution functions. This patch changes them all to use one common function. The function in question decides whether a device should enable TX and RX flow control in a standard way (IEEE 802.3-2005 table 28B-3), so this should also be useful for other drivers. Signed-off-by: Steve Glendinning <steve.glendinning@smsc.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/smsc911x.c')
-rw-r--r--drivers/net/smsc911x.c24
1 files changed, 1 insertions, 23 deletions
diff --git a/drivers/net/smsc911x.c b/drivers/net/smsc911x.c
index ae327166f978..fa28542b47d5 100644
--- a/drivers/net/smsc911x.c
+++ b/drivers/net/smsc911x.c
@@ -642,28 +642,6 @@ static int smsc911x_phy_loopbacktest(struct net_device *dev)
642} 642}
643#endif /* USE_PHY_WORK_AROUND */ 643#endif /* USE_PHY_WORK_AROUND */
644 644
645static u8 smsc95xx_resolve_flowctrl_fulldplx(u16 lcladv, u16 rmtadv)
646{
647 u8 cap = 0;
648
649 if (lcladv & ADVERTISE_PAUSE_CAP) {
650 if (lcladv & ADVERTISE_PAUSE_ASYM) {
651 if (rmtadv & LPA_PAUSE_CAP)
652 cap = FLOW_CTRL_TX | FLOW_CTRL_RX;
653 else if (rmtadv & LPA_PAUSE_ASYM)
654 cap = FLOW_CTRL_RX;
655 } else {
656 if (rmtadv & LPA_PAUSE_CAP)
657 cap = FLOW_CTRL_TX | FLOW_CTRL_RX;
658 }
659 } else if (lcladv & ADVERTISE_PAUSE_ASYM) {
660 if ((rmtadv & LPA_PAUSE_CAP) && (rmtadv & LPA_PAUSE_ASYM))
661 cap = FLOW_CTRL_TX;
662 }
663
664 return cap;
665}
666
667static void smsc911x_phy_update_flowcontrol(struct smsc911x_data *pdata) 645static void smsc911x_phy_update_flowcontrol(struct smsc911x_data *pdata)
668{ 646{
669 struct phy_device *phy_dev = pdata->phy_dev; 647 struct phy_device *phy_dev = pdata->phy_dev;
@@ -674,7 +652,7 @@ static void smsc911x_phy_update_flowcontrol(struct smsc911x_data *pdata)
674 if (phy_dev->duplex == DUPLEX_FULL) { 652 if (phy_dev->duplex == DUPLEX_FULL) {
675 u16 lcladv = phy_read(phy_dev, MII_ADVERTISE); 653 u16 lcladv = phy_read(phy_dev, MII_ADVERTISE);
676 u16 rmtadv = phy_read(phy_dev, MII_LPA); 654 u16 rmtadv = phy_read(phy_dev, MII_LPA);
677 u8 cap = smsc95xx_resolve_flowctrl_fulldplx(lcladv, rmtadv); 655 u8 cap = mii_resolve_flowctrl_fdx(lcladv, rmtadv);
678 656
679 if (cap & FLOW_CTRL_RX) 657 if (cap & FLOW_CTRL_RX)
680 flow = 0xFFFF0002; 658 flow = 0xFFFF0002;