Commit c3521254 authored by Eugene Crosser's avatar Eugene Crosser Committed by David S. Miller

qeth: use qeth_card_hw_is_reachable() everywhere

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: default avatarEugene Crosser <Eugene.Crosser@ru.ibm.com>
Signed-off-by: default avatarUrsula Braun <ursula.braun@de.ibm.com>
Reviewed-by: default avatarThomas-Mich Richter <tmricht@de.ibm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b646c08e
...@@ -531,8 +531,7 @@ static ssize_t qeth_dev_isolation_store(struct device *dev, ...@@ -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)*/ /* defer IP assist if device is offline (until discipline->set_online)*/
card->options.prev_isolation = card->options.isolation; card->options.prev_isolation = card->options.isolation;
card->options.isolation = isolation; card->options.isolation = isolation;
if (card->state == CARD_STATE_SOFTSETUP || if (qeth_card_hw_is_reachable(card)) {
card->state == CARD_STATE_UP) {
int ipa_rc = qeth_set_access_ctrl_online(card, 1); int ipa_rc = qeth_set_access_ctrl_online(card, 1);
if (ipa_rc != 0) if (ipa_rc != 0)
rc = ipa_rc; rc = ipa_rc;
...@@ -555,7 +554,7 @@ static ssize_t qeth_dev_switch_attrs_show(struct device *dev, ...@@ -555,7 +554,7 @@ static ssize_t qeth_dev_switch_attrs_show(struct device *dev,
if (!card) if (!card)
return -EINVAL; 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"); return sprintf(buf, "n/a\n");
rc = qeth_query_switch_attributes(card, &sw_info); rc = qeth_query_switch_attributes(card, &sw_info);
...@@ -606,7 +605,7 @@ static ssize_t qeth_hw_trap_store(struct device *dev, ...@@ -606,7 +605,7 @@ static ssize_t qeth_hw_trap_store(struct device *dev,
return -EINVAL; return -EINVAL;
mutex_lock(&card->conf_mutex); 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; state = 1;
tmp = strsep(&curtoken, "\n"); tmp = strsep(&curtoken, "\n");
......
...@@ -48,8 +48,7 @@ static int qeth_l2_do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) ...@@ -48,8 +48,7 @@ static int qeth_l2_do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
if (!card) if (!card)
return -ENODEV; return -ENODEV;
if ((card->state != CARD_STATE_UP) && if (!qeth_card_hw_is_reachable(card))
(card->state != CARD_STATE_SOFTSETUP))
return -ENODEV; return -ENODEV;
if (card->info.type == QETH_CARD_TYPE_OSN) 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) ...@@ -1344,8 +1343,7 @@ int qeth_osn_assist(struct net_device *dev, void *data, int data_len)
if (!card) if (!card)
return -ENODEV; return -ENODEV;
QETH_CARD_TEXT(card, 2, "osnsdmc"); QETH_CARD_TEXT(card, 2, "osnsdmc");
if ((card->state != CARD_STATE_UP) && if (!qeth_card_hw_is_reachable(card))
(card->state != CARD_STATE_SOFTSETUP))
return -ENODEV; return -ENODEV;
iob = qeth_wait_for_buffer(&card->write); iob = qeth_wait_for_buffer(&card->write);
memcpy(iob->data+IPA_PDU_HEADER_SIZE, data, data_len); memcpy(iob->data+IPA_PDU_HEADER_SIZE, data, data_len);
......
...@@ -432,10 +432,8 @@ void qeth_l3_set_ip_addr_list(struct qeth_card *card) ...@@ -432,10 +432,8 @@ void qeth_l3_set_ip_addr_list(struct qeth_card *card)
QETH_CARD_TEXT(card, 2, "sdiplist"); QETH_CARD_TEXT(card, 2, "sdiplist");
QETH_CARD_HEX(card, 2, &card, sizeof(void *)); QETH_CARD_HEX(card, 2, &card, sizeof(void *));
if ((card->state != CARD_STATE_UP && if (!qeth_card_hw_is_reachable(card) || card->options.sniffer)
card->state != CARD_STATE_SOFTSETUP) || card->options.sniffer) {
return; return;
}
spin_lock_irqsave(&card->ip_lock, flags); spin_lock_irqsave(&card->ip_lock, flags);
tbd_list = card->ip_tbd_list; 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) ...@@ -2626,8 +2624,7 @@ static int qeth_l3_do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
if (!card) if (!card)
return -ENODEV; return -ENODEV;
if ((card->state != CARD_STATE_UP) && if (!qeth_card_hw_is_reachable(card))
(card->state != CARD_STATE_SOFTSETUP))
return -ENODEV; return -ENODEV;
switch (cmd) { switch (cmd) {
......
...@@ -78,8 +78,7 @@ static ssize_t qeth_l3_dev_route_store(struct qeth_card *card, ...@@ -78,8 +78,7 @@ static ssize_t qeth_l3_dev_route_store(struct qeth_card *card,
rc = -EINVAL; rc = -EINVAL;
goto out; goto out;
} }
if (((card->state == CARD_STATE_SOFTSETUP) || if (qeth_card_hw_is_reachable(card) &&
(card->state == CARD_STATE_UP)) &&
(old_route_type != route->type)) { (old_route_type != route->type)) {
if (prot == QETH_PROT_IPV4) if (prot == QETH_PROT_IPV4)
rc = qeth_l3_setrouting_v4(card); rc = qeth_l3_setrouting_v4(card);
......
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