[PATCH 095/222] net:fec: clean up duplex mode handling
Russell King
rmk+kernel at arm.linux.org.uk
Fri Apr 25 04:39:02 PDT 2014
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.
Signed-off-by: Russell King <rmk+kernel at arm.linux.org.uk>
---
drivers/net/ethernet/freescale/fec_main.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index c79d604372a4..d5ad0c70e6a0 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -521,7 +521,7 @@ static void fec_enet_bd_init(struct net_device *dev)
* packet processing for this device must be stopped before this call.
*/
static void
-fec_restart(struct net_device *ndev, int duplex)
+fec_restart(struct net_device *ndev)
{
struct fec_enet_private *fep = netdev_priv(ndev);
const struct platform_device_id *id_entry =
@@ -572,7 +572,7 @@ fec_restart(struct net_device *ndev, int duplex)
}
/* Enable MII mode */
- if (duplex) {
+ if (fep->full_duplex == DUPLEX_FULL) {
/* FD enable */
writel(0x04, fep->hwp + FEC_X_CNTRL);
} else {
@@ -581,8 +581,6 @@ fec_restart(struct net_device *ndev, int duplex)
writel(0x0, fep->hwp + FEC_X_CNTRL);
}
- fep->full_duplex = duplex;
-
/* Set MII speed */
writel(fep->phy_speed, fep->hwp + FEC_MII_SPEED);
@@ -759,7 +757,7 @@ static void fec_enet_work(struct work_struct *work)
if (netif_device_present(ndev) || netif_running(ndev)) {
napi_disable(&fep->napi);
netif_tx_lock_bh(ndev);
- fec_restart(ndev, fep->full_duplex);
+ fec_restart(ndev);
netif_wake_queue(ndev);
netif_tx_unlock_bh(ndev);
napi_enable(&fep->napi);
@@ -1207,8 +1205,10 @@ static void fec_enet_adjust_link(struct net_device *ndev)
status_change = 1;
}
- if (fep->full_duplex != phy_dev->duplex)
+ if (fep->full_duplex != phy_dev->duplex) {
+ fep->full_duplex = phy_dev->duplex;
status_change = 1;
+ }
if (phy_dev->speed != fep->speed) {
fep->speed = phy_dev->speed;
@@ -1219,7 +1219,7 @@ static void fec_enet_adjust_link(struct net_device *ndev)
if (status_change) {
napi_disable(&fep->napi);
netif_tx_lock_bh(ndev);
- fec_restart(ndev, phy_dev->duplex);
+ fec_restart(ndev);
netif_wake_queue(ndev);
netif_tx_unlock_bh(ndev);
napi_enable(&fep->napi);
@@ -1572,7 +1572,7 @@ static int fec_enet_set_pauseparam(struct net_device *ndev,
if (netif_running(ndev)) {
napi_disable(&fep->napi);
netif_tx_lock_bh(ndev);
- fec_restart(ndev, fep->full_duplex);
+ fec_restart(ndev);
netif_wake_queue(ndev);
netif_tx_unlock_bh(ndev);
napi_enable(&fep->napi);
@@ -1850,7 +1850,7 @@ fec_enet_open(struct net_device *ndev)
return ret;
}
- fec_restart(ndev, fep->full_duplex);
+ fec_restart(ndev);
napi_enable(&fep->napi);
phy_start(fep->phy_dev);
netif_start_queue(ndev);
@@ -2024,7 +2024,7 @@ static int fec_set_features(struct net_device *netdev,
/* Resume the device after updates */
if (netif_running(netdev) && changed & FEATURES_NEED_QUIESCE) {
- fec_restart(netdev, fep->phy_dev->duplex);
+ fec_restart(netdev);
netif_wake_queue(netdev);
netif_tx_unlock_bh(netdev);
napi_enable(&fep->napi);
@@ -2110,7 +2110,7 @@ static int fec_enet_init(struct net_device *ndev)
fep->csum_flags |= FLAG_RX_CSUM_ENABLED;
}
- fec_restart(ndev, 0);
+ fec_restart(ndev);
return 0;
}
@@ -2422,7 +2422,7 @@ fec_resume(struct device *dev)
rtnl_lock();
if (netif_running(ndev)) {
- fec_restart(ndev, fep->full_duplex);
+ fec_restart(ndev);
netif_tx_lock_bh(ndev);
netif_device_attach(ndev);
netif_tx_unlock_bh(ndev);
--
1.8.3.1
More information about the linux-arm-kernel
mailing list