qeth: use qeth_card_hw_is_reachable() everywhere
authorEugene Crosser <Eugene.Crosser@ru.ibm.com>
Fri, 16 Jan 2015 13:05:47 +0000 (14:05 +0100)
committerDavid S. Miller <davem@davemloft.net>
Sun, 18 Jan 2015 04:54:59 +0000 (23:54 -0500)
qeth_card_hw_is_reachable() was introduced as part of a new
functionality, but it is a useful abstraction that can replace
verbose checks througout the rest of the `qeth` driver.

Signed-off-by: Eugene Crosser <Eugene.Crosser@ru.ibm.com>
Signed-off-by: Ursula Braun <ursula.braun@de.ibm.com>
Reviewed-by: Thomas-Mich Richter <tmricht@de.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/s390/net/qeth_core_sys.c
drivers/s390/net/qeth_l2_main.c
drivers/s390/net/qeth_l3_main.c
drivers/s390/net/qeth_l3_sys.c

index 15523f0e4c03666d77d7203102b8f3548cd86e3d..8c76574e727062659c60857f08e5aebed58d15f7 100644 (file)
@@ -531,8 +531,7 @@ static ssize_t qeth_dev_isolation_store(struct device *dev,
        /* defer IP assist if device is offline (until discipline->set_online)*/
        card->options.prev_isolation = card->options.isolation;
        card->options.isolation = isolation;
-       if (card->state == CARD_STATE_SOFTSETUP ||
-           card->state == CARD_STATE_UP) {
+       if (qeth_card_hw_is_reachable(card)) {
                int ipa_rc = qeth_set_access_ctrl_online(card, 1);
                if (ipa_rc != 0)
                        rc = ipa_rc;
@@ -555,7 +554,7 @@ static ssize_t qeth_dev_switch_attrs_show(struct device *dev,
        if (!card)
                return -EINVAL;
 
-       if (card->state != CARD_STATE_SOFTSETUP && card->state != CARD_STATE_UP)
+       if (!qeth_card_hw_is_reachable(card))
                return sprintf(buf, "n/a\n");
 
        rc = qeth_query_switch_attributes(card, &sw_info);
@@ -606,7 +605,7 @@ static ssize_t qeth_hw_trap_store(struct device *dev,
                return -EINVAL;
 
        mutex_lock(&card->conf_mutex);
-       if (card->state == CARD_STATE_SOFTSETUP || card->state == CARD_STATE_UP)
+       if (qeth_card_hw_is_reachable(card))
                state = 1;
        tmp = strsep(&curtoken, "\n");
 
index d02cd1a679432fc7ef485295d308bac046f96df9..f5f409d85295212ebb29c06ee4fd315c81ae2d63 100644 (file)
@@ -48,8 +48,7 @@ static int qeth_l2_do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
        if (!card)
                return -ENODEV;
 
-       if ((card->state != CARD_STATE_UP) &&
-               (card->state != CARD_STATE_SOFTSETUP))
+       if (!qeth_card_hw_is_reachable(card))
                return -ENODEV;
 
        if (card->info.type == QETH_CARD_TYPE_OSN)
@@ -1344,8 +1343,7 @@ int qeth_osn_assist(struct net_device *dev, void *data, int data_len)
        if (!card)
                return -ENODEV;
        QETH_CARD_TEXT(card, 2, "osnsdmc");
-       if ((card->state != CARD_STATE_UP) &&
-           (card->state != CARD_STATE_SOFTSETUP))
+       if (!qeth_card_hw_is_reachable(card))
                return -ENODEV;
        iob = qeth_wait_for_buffer(&card->write);
        memcpy(iob->data+IPA_PDU_HEADER_SIZE, data, data_len);
index dd4ab8d73d34903b85590131e16241d7d3b66883..1432b10e95adcb8cb5381c3bb3d089c1e7cea1cb 100644 (file)
@@ -432,10 +432,8 @@ void qeth_l3_set_ip_addr_list(struct qeth_card *card)
        QETH_CARD_TEXT(card, 2, "sdiplist");
        QETH_CARD_HEX(card, 2, &card, sizeof(void *));
 
-       if ((card->state != CARD_STATE_UP &&
-            card->state != CARD_STATE_SOFTSETUP) || card->options.sniffer) {
+       if (!qeth_card_hw_is_reachable(card) || card->options.sniffer)
                return;
-       }
 
        spin_lock_irqsave(&card->ip_lock, flags);
        tbd_list = card->ip_tbd_list;
@@ -2626,8 +2624,7 @@ static int qeth_l3_do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
        if (!card)
                return -ENODEV;
 
-       if ((card->state != CARD_STATE_UP) &&
-               (card->state != CARD_STATE_SOFTSETUP))
+       if (!qeth_card_hw_is_reachable(card))
                return -ENODEV;
 
        switch (cmd) {
index adef5f5de118a7ed9b320b3cea07672bc511ec36..c4dcd667c894538f67b2e80fb058040b0c3f0262 100644 (file)
@@ -78,8 +78,7 @@ static ssize_t qeth_l3_dev_route_store(struct qeth_card *card,
                rc = -EINVAL;
                goto out;
        }
-       if (((card->state == CARD_STATE_SOFTSETUP) ||
-            (card->state == CARD_STATE_UP)) &&
+       if (qeth_card_hw_is_reachable(card) &&
            (old_route_type != route->type)) {
                if (prot == QETH_PROT_IPV4)
                        rc = qeth_l3_setrouting_v4(card);