aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBen Hutchings <bhutchings@solarflare.com>2009-08-26 04:16:27 -0400
committerDavid S. Miller <davem@davemloft.net>2009-08-26 20:38:49 -0400
commitaed0628dae0c26b47d40d65f942abe30279b52a5 (patch)
treec6525e610300eb43f138bb9c14ee9ef1f8693f0c /drivers
parent7c6a3ed5bd61ec981c8a0d0111cfd435adf3f2b7 (diff)
sfc: Fix ordering of device registration and initial netif_carrier_off()
We must call netif_carrier_off() after the device is registered, not before, to set the operational state and user-space IFF_RUNNING flag correctly. Since we don't want observers to see an intermediate state, open-code register_netdev() and add efx_update_name() and netif_carrier_off() into the locked region. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/sfc/efx.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/drivers/net/sfc/efx.c b/drivers/net/sfc/efx.c
index 343e8da1fa30..d4dc92042d77 100644
--- a/drivers/net/sfc/efx.c
+++ b/drivers/net/sfc/efx.c
@@ -1614,21 +1614,24 @@ static int efx_register_netdev(struct efx_nic *efx)
1614 SET_NETDEV_DEV(net_dev, &efx->pci_dev->dev); 1614 SET_NETDEV_DEV(net_dev, &efx->pci_dev->dev);
1615 SET_ETHTOOL_OPS(net_dev, &efx_ethtool_ops); 1615 SET_ETHTOOL_OPS(net_dev, &efx_ethtool_ops);
1616 1616
1617 /* Always start with carrier off; PHY events will detect the link */
1618 netif_carrier_off(efx->net_dev);
1619
1620 /* Clear MAC statistics */ 1617 /* Clear MAC statistics */
1621 efx->mac_op->update_stats(efx); 1618 efx->mac_op->update_stats(efx);
1622 memset(&efx->mac_stats, 0, sizeof(efx->mac_stats)); 1619 memset(&efx->mac_stats, 0, sizeof(efx->mac_stats));
1623 1620
1624 rc = register_netdev(net_dev);
1625 if (rc) {
1626 EFX_ERR(efx, "could not register net dev\n");
1627 return rc;
1628 }
1629
1630 rtnl_lock(); 1621 rtnl_lock();
1622
1623 rc = dev_alloc_name(net_dev, net_dev->name);
1624 if (rc < 0)
1625 goto fail_locked;
1631 efx_update_name(efx); 1626 efx_update_name(efx);
1627
1628 rc = register_netdevice(net_dev);
1629 if (rc)
1630 goto fail_locked;
1631
1632 /* Always start with carrier off; PHY events will detect the link */
1633 netif_carrier_off(efx->net_dev);
1634
1632 rtnl_unlock(); 1635 rtnl_unlock();
1633 1636
1634 rc = device_create_file(&efx->pci_dev->dev, &dev_attr_phy_type); 1637 rc = device_create_file(&efx->pci_dev->dev, &dev_attr_phy_type);
@@ -1639,6 +1642,11 @@ static int efx_register_netdev(struct efx_nic *efx)
1639 1642
1640 return 0; 1643 return 0;
1641 1644
1645fail_locked:
1646 rtnl_unlock();
1647 EFX_ERR(efx, "could not register net dev\n");
1648 return rc;
1649
1642fail_registered: 1650fail_registered:
1643 unregister_netdev(net_dev); 1651 unregister_netdev(net_dev);
1644 return rc; 1652 return rc;