Commit adeb15aa authored by Ben Hutchings's avatar Ben Hutchings

sfc: Assign efx and efx->type as early as possible in efx_pci_probe()

We also stop clearing *efx in efx_init_struct().  This is safe because
alloc_etherdev_mq() already clears it for us.
Signed-off-by: default avatarBen Hutchings <bhutchings@solarflare.com>
parent 3f65ea5b
...@@ -2422,13 +2422,12 @@ static const struct efx_phy_operations efx_dummy_phy_operations = { ...@@ -2422,13 +2422,12 @@ static const struct efx_phy_operations efx_dummy_phy_operations = {
/* This zeroes out and then fills in the invariants in a struct /* This zeroes out and then fills in the invariants in a struct
* efx_nic (including all sub-structures). * efx_nic (including all sub-structures).
*/ */
static int efx_init_struct(struct efx_nic *efx, const struct efx_nic_type *type, static int efx_init_struct(struct efx_nic *efx,
struct pci_dev *pci_dev, struct net_device *net_dev) struct pci_dev *pci_dev, struct net_device *net_dev)
{ {
int i; int i;
/* Initialise common structures */ /* Initialise common structures */
memset(efx, 0, sizeof(*efx));
spin_lock_init(&efx->biu_lock); spin_lock_init(&efx->biu_lock);
#ifdef CONFIG_SFC_MTD #ifdef CONFIG_SFC_MTD
INIT_LIST_HEAD(&efx->mtd_list); INIT_LIST_HEAD(&efx->mtd_list);
...@@ -2455,8 +2454,6 @@ static int efx_init_struct(struct efx_nic *efx, const struct efx_nic_type *type, ...@@ -2455,8 +2454,6 @@ static int efx_init_struct(struct efx_nic *efx, const struct efx_nic_type *type,
goto fail; goto fail;
} }
efx->type = type;
EFX_BUG_ON_PARANOID(efx->type->phys_addr_channels > EFX_MAX_CHANNELS); EFX_BUG_ON_PARANOID(efx->type->phys_addr_channels > EFX_MAX_CHANNELS);
/* Higher numbered interrupt modes are less capable! */ /* Higher numbered interrupt modes are less capable! */
...@@ -2660,7 +2657,6 @@ static int efx_pci_probe_main(struct efx_nic *efx) ...@@ -2660,7 +2657,6 @@ static int efx_pci_probe_main(struct efx_nic *efx)
static int __devinit efx_pci_probe(struct pci_dev *pci_dev, static int __devinit efx_pci_probe(struct pci_dev *pci_dev,
const struct pci_device_id *entry) const struct pci_device_id *entry)
{ {
const struct efx_nic_type *type = (const struct efx_nic_type *) entry->driver_data;
struct net_device *net_dev; struct net_device *net_dev;
struct efx_nic *efx; struct efx_nic *efx;
int rc; int rc;
...@@ -2670,10 +2666,12 @@ static int __devinit efx_pci_probe(struct pci_dev *pci_dev, ...@@ -2670,10 +2666,12 @@ static int __devinit efx_pci_probe(struct pci_dev *pci_dev,
EFX_MAX_RX_QUEUES); EFX_MAX_RX_QUEUES);
if (!net_dev) if (!net_dev)
return -ENOMEM; return -ENOMEM;
net_dev->features |= (type->offload_features | NETIF_F_SG | efx = netdev_priv(net_dev);
efx->type = (const struct efx_nic_type *) entry->driver_data;
net_dev->features |= (efx->type->offload_features | NETIF_F_SG |
NETIF_F_HIGHDMA | NETIF_F_TSO | NETIF_F_HIGHDMA | NETIF_F_TSO |
NETIF_F_RXCSUM); NETIF_F_RXCSUM);
if (type->offload_features & NETIF_F_V6_CSUM) if (efx->type->offload_features & NETIF_F_V6_CSUM)
net_dev->features |= NETIF_F_TSO6; net_dev->features |= NETIF_F_TSO6;
/* Mask for features that also apply to VLAN devices */ /* Mask for features that also apply to VLAN devices */
net_dev->vlan_features |= (NETIF_F_ALL_CSUM | NETIF_F_SG | net_dev->vlan_features |= (NETIF_F_ALL_CSUM | NETIF_F_SG |
...@@ -2681,10 +2679,9 @@ static int __devinit efx_pci_probe(struct pci_dev *pci_dev, ...@@ -2681,10 +2679,9 @@ static int __devinit efx_pci_probe(struct pci_dev *pci_dev,
NETIF_F_RXCSUM); NETIF_F_RXCSUM);
/* All offloads can be toggled */ /* All offloads can be toggled */
net_dev->hw_features = net_dev->features & ~NETIF_F_HIGHDMA; net_dev->hw_features = net_dev->features & ~NETIF_F_HIGHDMA;
efx = netdev_priv(net_dev);
pci_set_drvdata(pci_dev, efx); pci_set_drvdata(pci_dev, efx);
SET_NETDEV_DEV(net_dev, &pci_dev->dev); SET_NETDEV_DEV(net_dev, &pci_dev->dev);
rc = efx_init_struct(efx, type, pci_dev, net_dev); rc = efx_init_struct(efx, pci_dev, net_dev);
if (rc) if (rc)
goto fail1; goto fail1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment