aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/freescale
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2014-07-08 07:40:43 -0400
committerDavid S. Miller <davem@davemloft.net>2014-07-08 23:02:59 -0400
commitef83337d138354e3d1e32d9f929e0afefe5552aa (patch)
tree91c71ba90f13d1b32db756c40fe56f51c0ef88f6 /drivers/net/ethernet/freescale
parentf208ce10046888052d3a5e9fc88b7c1b819877d2 (diff)
net: fec: clean up duplex mode handling
Many places call fec_restart() with the second parameter being some kind of previously saved duplex value, but only two places call it with some other setting. This is at odds with how the other link settings are handled, and used to be racy before the rtnl locks were added to fec_restart()'s various call paths. Clean this up so all link capabilities are handled in the same way - saved into the fec_enet_private structure, and then fec_restart() acts on those settings. Acked-by: Fugang Duan <B38611@freescale.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/freescale')
-rw-r--r--drivers/net/ethernet/freescale/fec_main.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 0186fec1f7f9..9d82d915b06d 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -824,7 +824,7 @@ static void fec_enet_bd_init(struct net_device *dev)
824 * packet processing for this device must be stopped before this call. 824 * packet processing for this device must be stopped before this call.
825 */ 825 */
826static void 826static void
827fec_restart(struct net_device *ndev, int duplex) 827fec_restart(struct net_device *ndev)
828{ 828{
829 struct fec_enet_private *fep = netdev_priv(ndev); 829 struct fec_enet_private *fep = netdev_priv(ndev);
830 const struct platform_device_id *id_entry = 830 const struct platform_device_id *id_entry =
@@ -875,7 +875,7 @@ fec_restart(struct net_device *ndev, int duplex)
875 } 875 }
876 876
877 /* Enable MII mode */ 877 /* Enable MII mode */
878 if (duplex) { 878 if (fep->full_duplex == DUPLEX_FULL) {
879 /* FD enable */ 879 /* FD enable */
880 writel(0x04, fep->hwp + FEC_X_CNTRL); 880 writel(0x04, fep->hwp + FEC_X_CNTRL);
881 } else { 881 } else {
@@ -884,8 +884,6 @@ fec_restart(struct net_device *ndev, int duplex)
884 writel(0x0, fep->hwp + FEC_X_CNTRL); 884 writel(0x0, fep->hwp + FEC_X_CNTRL);
885 } 885 }
886 886
887 fep->full_duplex = duplex;
888
889 /* Set MII speed */ 887 /* Set MII speed */
890 writel(fep->phy_speed, fep->hwp + FEC_MII_SPEED); 888 writel(fep->phy_speed, fep->hwp + FEC_MII_SPEED);
891 889
@@ -1060,7 +1058,7 @@ static void fec_enet_work(struct work_struct *work)
1060 if (netif_device_present(ndev) || netif_running(ndev)) { 1058 if (netif_device_present(ndev) || netif_running(ndev)) {
1061 napi_disable(&fep->napi); 1059 napi_disable(&fep->napi);
1062 netif_tx_lock_bh(ndev); 1060 netif_tx_lock_bh(ndev);
1063 fec_restart(ndev, fep->full_duplex); 1061 fec_restart(ndev);
1064 netif_wake_queue(ndev); 1062 netif_wake_queue(ndev);
1065 netif_tx_unlock_bh(ndev); 1063 netif_tx_unlock_bh(ndev);
1066 napi_enable(&fep->napi); 1064 napi_enable(&fep->napi);
@@ -1511,8 +1509,10 @@ static void fec_enet_adjust_link(struct net_device *ndev)
1511 status_change = 1; 1509 status_change = 1;
1512 } 1510 }
1513 1511
1514 if (fep->full_duplex != phy_dev->duplex) 1512 if (fep->full_duplex != phy_dev->duplex) {
1513 fep->full_duplex = phy_dev->duplex;
1515 status_change = 1; 1514 status_change = 1;
1515 }
1516 1516
1517 if (phy_dev->speed != fep->speed) { 1517 if (phy_dev->speed != fep->speed) {
1518 fep->speed = phy_dev->speed; 1518 fep->speed = phy_dev->speed;
@@ -1523,7 +1523,7 @@ static void fec_enet_adjust_link(struct net_device *ndev)
1523 if (status_change) { 1523 if (status_change) {
1524 napi_disable(&fep->napi); 1524 napi_disable(&fep->napi);
1525 netif_tx_lock_bh(ndev); 1525 netif_tx_lock_bh(ndev);
1526 fec_restart(ndev, phy_dev->duplex); 1526 fec_restart(ndev);
1527 netif_wake_queue(ndev); 1527 netif_wake_queue(ndev);
1528 netif_tx_unlock_bh(ndev); 1528 netif_tx_unlock_bh(ndev);
1529 napi_enable(&fep->napi); 1529 napi_enable(&fep->napi);
@@ -1919,7 +1919,7 @@ static int fec_enet_set_pauseparam(struct net_device *ndev,
1919 if (netif_running(ndev)) { 1919 if (netif_running(ndev)) {
1920 napi_disable(&fep->napi); 1920 napi_disable(&fep->napi);
1921 netif_tx_lock_bh(ndev); 1921 netif_tx_lock_bh(ndev);
1922 fec_restart(ndev, fep->full_duplex); 1922 fec_restart(ndev);
1923 netif_wake_queue(ndev); 1923 netif_wake_queue(ndev);
1924 netif_tx_unlock_bh(ndev); 1924 netif_tx_unlock_bh(ndev);
1925 napi_enable(&fep->napi); 1925 napi_enable(&fep->napi);
@@ -2201,7 +2201,7 @@ fec_enet_open(struct net_device *ndev)
2201 return ret; 2201 return ret;
2202 } 2202 }
2203 2203
2204 fec_restart(ndev, fep->full_duplex); 2204 fec_restart(ndev);
2205 napi_enable(&fep->napi); 2205 napi_enable(&fep->napi);
2206 phy_start(fep->phy_dev); 2206 phy_start(fep->phy_dev);
2207 netif_start_queue(ndev); 2207 netif_start_queue(ndev);
@@ -2377,7 +2377,7 @@ static int fec_set_features(struct net_device *netdev,
2377 2377
2378 /* Resume the device after updates */ 2378 /* Resume the device after updates */
2379 if (netif_running(netdev) && changed & FEATURES_NEED_QUIESCE) { 2379 if (netif_running(netdev) && changed & FEATURES_NEED_QUIESCE) {
2380 fec_restart(netdev, fep->phy_dev->duplex); 2380 fec_restart(netdev);
2381 netif_wake_queue(netdev); 2381 netif_wake_queue(netdev);
2382 netif_tx_unlock_bh(netdev); 2382 netif_tx_unlock_bh(netdev);
2383 napi_enable(&fep->napi); 2383 napi_enable(&fep->napi);
@@ -2481,7 +2481,7 @@ static int fec_enet_init(struct net_device *ndev)
2481 2481
2482 ndev->hw_features = ndev->features; 2482 ndev->hw_features = ndev->features;
2483 2483
2484 fec_restart(ndev, 0); 2484 fec_restart(ndev);
2485 2485
2486 return 0; 2486 return 0;
2487} 2487}
@@ -2750,7 +2750,7 @@ fec_resume(struct device *dev)
2750 2750
2751 rtnl_lock(); 2751 rtnl_lock();
2752 if (netif_running(ndev)) { 2752 if (netif_running(ndev)) {
2753 fec_restart(ndev, fep->full_duplex); 2753 fec_restart(ndev);
2754 netif_tx_lock_bh(ndev); 2754 netif_tx_lock_bh(ndev);
2755 netif_device_attach(ndev); 2755 netif_device_attach(ndev);
2756 netif_tx_unlock_bh(ndev); 2756 netif_tx_unlock_bh(ndev);