net: ethernet: aquantia: Call netdev_register after all initialized.
authorPavel Belous <pavel.belous@aquantia.com>
Mon, 20 Feb 2017 19:36:47 +0000 (22:36 +0300)
committerDavid S. Miller <davem@davemloft.net>
Mon, 20 Feb 2017 22:11:09 +0000 (17:11 -0500)
netdev_register should be called when everything is initialized.
Also we should use net_device->reg_state field instead own
"is_ndev_registered" flag to avoid any race.

Signed-off-by: Pavel Belous <pavel.belous@aquantia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/aquantia/atlantic/aq_nic.c
drivers/net/ethernet/aquantia/atlantic/aq_nic_internal.h

index a8a27c5e8aebc1612349754f91f7f35924b8ce55..bce312a26e7c197d2f1e4995b82b5f56c6a79ab1 100644 (file)
@@ -261,16 +261,16 @@ int aq_nic_ndev_register(struct aq_nic_s *self)
                ether_addr_copy(self->ndev->dev_addr, mac_addr_permanent);
        }
 #endif
-       err = register_netdev(self->ndev);
-       if (err < 0)
-               goto err_exit;
 
-       self->is_ndev_registered = true;
        netif_carrier_off(self->ndev);
 
        for (i = AQ_CFG_VECS_MAX; i--;)
                aq_nic_ndev_queue_stop(self, i);
 
+       err = register_netdev(self->ndev);
+       if (err < 0)
+               goto err_exit;
+
 err_exit:
        return err;
 }
@@ -293,7 +293,7 @@ void aq_nic_ndev_free(struct aq_nic_s *self)
        if (!self->ndev)
                goto err_exit;
 
-       if (self->is_ndev_registered)
+       if (self->ndev->reg_state == NETREG_REGISTERED)
                unregister_netdev(self->ndev);
 
        if (self->aq_hw)
index f81738a71c42ef3ddc85bd12deca2e92da4f8181..e7d2711dc165962703ff60027dc71e7879110ca6 100644 (file)
@@ -22,7 +22,6 @@ struct aq_nic_s {
        unsigned int aq_vecs;
        unsigned int packet_filter;
        unsigned int power_state;
-       bool is_ndev_registered;
        u8 port;
        struct aq_hw_ops aq_hw_ops;
        struct aq_hw_caps_s aq_hw_caps;