s390/qeth: use dev->reg_state
authorJulian Wiedmann <jwi@linux.ibm.com>
Wed, 18 Mar 2020 12:54:55 +0000 (13:54 +0100)
committerDavid S. Miller <davem@davemloft.net>
Wed, 18 Mar 2020 23:33:35 +0000 (16:33 -0700)
To check whether a netdevice has already been registered, look at
NETREG_REGISTERED to replace some hacks I added a while ago.

Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/s390/net/qeth_core.h
drivers/s390/net/qeth_l2_main.c
drivers/s390/net/qeth_l3_main.c

index b8b356a..6eb431c 100644 (file)
@@ -847,11 +847,6 @@ struct qeth_trap_id {
 /*some helper functions*/
 #define QETH_CARD_IFNAME(card) (((card)->dev)? (card)->dev->name : "")
 
-static inline bool qeth_netdev_is_registered(struct net_device *dev)
-{
-       return dev->netdev_ops != NULL;
-}
-
 static inline u16 qeth_iqd_translate_txq(struct net_device *dev, u16 txq)
 {
        if (txq == QETH_IQD_MCAST_TXQ)
index 2aaf5e3..73cb363 100644 (file)
@@ -613,7 +613,7 @@ static void qeth_l2_remove_device(struct ccwgroup_device *cgdev)
                qeth_set_offline(card, false);
 
        cancel_work_sync(&card->close_dev_work);
-       if (qeth_netdev_is_registered(card->dev))
+       if (card->dev->reg_state == NETREG_REGISTERED)
                unregister_netdev(card->dev);
 }
 
@@ -651,7 +651,7 @@ static const struct net_device_ops qeth_osn_netdev_ops = {
        .ndo_tx_timeout         = qeth_tx_timeout,
 };
 
-static int qeth_l2_setup_netdev(struct qeth_card *card, bool carrier_ok)
+static int qeth_l2_setup_netdev(struct qeth_card *card)
 {
        int rc;
 
@@ -711,13 +711,7 @@ static int qeth_l2_setup_netdev(struct qeth_card *card, bool carrier_ok)
 
 add_napi:
        netif_napi_add(card->dev, &card->napi, qeth_poll, QETH_NAPI_WEIGHT);
-       rc = register_netdev(card->dev);
-       if (!rc && carrier_ok)
-               netif_carrier_on(card->dev);
-
-       if (rc)
-               card->dev->netdev_ops = NULL;
-       return rc;
+       return register_netdev(card->dev);
 }
 
 static void qeth_l2_trace_features(struct qeth_card *card)
@@ -790,10 +784,13 @@ static int qeth_l2_set_online(struct qeth_card *card)
 
        qeth_set_allowed_threads(card, 0xffffffff, 0);
 
-       if (!qeth_netdev_is_registered(dev)) {
-               rc = qeth_l2_setup_netdev(card, carrier_ok);
+       if (dev->reg_state != NETREG_REGISTERED) {
+               rc = qeth_l2_setup_netdev(card);
                if (rc)
                        goto out_remove;
+
+               if (carrier_ok)
+                       netif_carrier_on(dev);
        } else {
                rtnl_lock();
                if (carrier_ok)
index 81ec0d2..83ae75c 100644 (file)
@@ -1918,7 +1918,7 @@ static const struct net_device_ops qeth_l3_osa_netdev_ops = {
        .ndo_neigh_setup        = qeth_l3_neigh_setup,
 };
 
-static int qeth_l3_setup_netdev(struct qeth_card *card, bool carrier_ok)
+static int qeth_l3_setup_netdev(struct qeth_card *card)
 {
        unsigned int headroom;
        int rc;
@@ -1972,7 +1972,7 @@ static int qeth_l3_setup_netdev(struct qeth_card *card, bool carrier_ok)
 
                rc = qeth_l3_iqd_read_initial_mac(card);
                if (rc)
-                       goto out;
+                       return rc;
        } else
                return -ENODEV;
 
@@ -1987,14 +1987,7 @@ static int qeth_l3_setup_netdev(struct qeth_card *card, bool carrier_ok)
                                       PAGE_SIZE * (QETH_MAX_BUFFER_ELEMENTS(card) - 1));
 
        netif_napi_add(card->dev, &card->napi, qeth_poll, QETH_NAPI_WEIGHT);
-       rc = register_netdev(card->dev);
-       if (!rc && carrier_ok)
-               netif_carrier_on(card->dev);
-
-out:
-       if (rc)
-               card->dev->netdev_ops = NULL;
-       return rc;
+       return register_netdev(card->dev);
 }
 
 static const struct device_type qeth_l3_devtype = {
@@ -2041,7 +2034,7 @@ static void qeth_l3_remove_device(struct ccwgroup_device *cgdev)
                qeth_set_offline(card, false);
 
        cancel_work_sync(&card->close_dev_work);
-       if (qeth_netdev_is_registered(card->dev))
+       if (card->dev->reg_state == NETREG_REGISTERED)
                unregister_netdev(card->dev);
 
        flush_workqueue(card->cmd_wq);
@@ -2088,10 +2081,13 @@ static int qeth_l3_set_online(struct qeth_card *card)
        qeth_set_allowed_threads(card, 0xffffffff, 0);
        qeth_l3_recover_ip(card);
 
-       if (!qeth_netdev_is_registered(dev)) {
-               rc = qeth_l3_setup_netdev(card, carrier_ok);
+       if (dev->reg_state != NETREG_REGISTERED) {
+               rc = qeth_l3_setup_netdev(card);
                if (rc)
                        goto out_remove;
+
+               if (carrier_ok)
+                       netif_carrier_on(dev);
        } else {
                rtnl_lock();
                if (carrier_ok)