aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/smsc9420.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/smsc9420.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/smsc9420.c')
-rw-r--r--drivers/net/smsc9420.c24
1 files changed, 1 insertions, 23 deletions
diff --git a/drivers/net/smsc9420.c b/drivers/net/smsc9420.c
index bc9879d5f281..940220f60921 100644
--- a/drivers/net/smsc9420.c
+++ b/drivers/net/smsc9420.c
@@ -1080,28 +1080,6 @@ static void smsc9420_set_multicast_list(struct net_device *dev)
1080 smsc9420_pci_flush_write(pd); 1080 smsc9420_pci_flush_write(pd);
1081} 1081}
1082 1082
1083static u8 smsc9420_resolve_flowctrl_fulldplx(u16 lcladv, u16 rmtadv)
1084{
1085 u8 cap = 0;
1086
1087 if (lcladv & ADVERTISE_PAUSE_CAP) {
1088 if (lcladv & ADVERTISE_PAUSE_ASYM) {
1089 if (rmtadv & LPA_PAUSE_CAP)
1090 cap = FLOW_CTRL_TX | FLOW_CTRL_RX;
1091 else if (rmtadv & LPA_PAUSE_ASYM)
1092 cap = FLOW_CTRL_RX;
1093 } else {
1094 if (rmtadv & LPA_PAUSE_CAP)
1095 cap = FLOW_CTRL_TX | FLOW_CTRL_RX;
1096 }
1097 } else if (lcladv & ADVERTISE_PAUSE_ASYM) {
1098 if ((rmtadv & LPA_PAUSE_CAP) && (rmtadv & LPA_PAUSE_ASYM))
1099 cap = FLOW_CTRL_TX;
1100 }
1101
1102 return cap;
1103}
1104
1105static void smsc9420_phy_update_flowcontrol(struct smsc9420_pdata *pd) 1083static void smsc9420_phy_update_flowcontrol(struct smsc9420_pdata *pd)
1106{ 1084{
1107 struct phy_device *phy_dev = pd->phy_dev; 1085 struct phy_device *phy_dev = pd->phy_dev;
@@ -1110,7 +1088,7 @@ static void smsc9420_phy_update_flowcontrol(struct smsc9420_pdata *pd)
1110 if (phy_dev->duplex == DUPLEX_FULL) { 1088 if (phy_dev->duplex == DUPLEX_FULL) {
1111 u16 lcladv = phy_read(phy_dev, MII_ADVERTISE); 1089 u16 lcladv = phy_read(phy_dev, MII_ADVERTISE);
1112 u16 rmtadv = phy_read(phy_dev, MII_LPA); 1090 u16 rmtadv = phy_read(phy_dev, MII_LPA);
1113 u8 cap = smsc9420_resolve_flowctrl_fulldplx(lcladv, rmtadv); 1091 u8 cap = mii_resolve_flowctrl_fdx(lcladv, rmtadv);
1114 1092
1115 if (cap & FLOW_CTRL_RX) 1093 if (cap & FLOW_CTRL_RX)
1116 flow = 0xFFFF0002; 1094 flow = 0xFFFF0002;