aboutsummaryrefslogtreecommitdiff
path: root/net/atm/common.c
diff options
context:
space:
mode:
authorMitchell Blank Jr <mitch@sfgoth.com>2005-11-29 16:13:32 -0800
committerDavid S. Miller <davem@davemloft.net>2005-11-29 16:13:32 -0800
commitc9933d0856d6d0ede6b4b30e5e7330614f5203af (patch)
tree5f31d09df861fd83fc327a7eb5b5ac12bfc4188e /net/atm/common.c
parent18955cfcb2a5d75a08e0cb297f13ccfb6904de48 (diff)
[ATM]: always return the first interface for ATM_ITF_ANY
From: Mitchell Blank Jr <mitch@sfgoth.com> Signed-off-by: Chas Williams <chas@cmf.nrl.navy.mil> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/atm/common.c')
-rw-r--r--net/atm/common.c30
1 files changed, 10 insertions, 20 deletions
diff --git a/net/atm/common.c b/net/atm/common.c
index 63feea49fb1..83454e12317 100644
--- a/net/atm/common.c
+++ b/net/atm/common.c
@@ -423,33 +423,23 @@ int vcc_connect(struct socket *sock, int itf, short vpi, int vci)
if (vcc->qos.txtp.traffic_class == ATM_ANYCLASS ||
vcc->qos.rxtp.traffic_class == ATM_ANYCLASS)
return -EINVAL;
- if (itf != ATM_ITF_ANY) {
+ if (likely(itf != ATM_ITF_ANY)) {
dev = atm_dev_lookup(itf);
- if (!dev)
- return -ENODEV;
- error = __vcc_connect(vcc, dev, vpi, vci);
- if (error) {
- atm_dev_put(dev);
- return error;
- }
} else {
- struct list_head *p, *next;
-
dev = NULL;
spin_lock(&atm_dev_lock);
- list_for_each_safe(p, next, &atm_devs) {
- dev = list_entry(p, struct atm_dev, dev_list);
+ if (!list_empty(&atm_devs)) {
+ dev = list_entry(atm_devs.next, struct atm_dev, dev_list);
atm_dev_hold(dev);
- spin_unlock(&atm_dev_lock);
- if (!__vcc_connect(vcc, dev, vpi, vci))
- break;
- atm_dev_put(dev);
- dev = NULL;
- spin_lock(&atm_dev_lock);
}
spin_unlock(&atm_dev_lock);
- if (!dev)
- return -ENODEV;
+ }
+ if (!dev)
+ return -ENODEV;
+ error = __vcc_connect(vcc, dev, vpi, vci);
+ if (error) {
+ atm_dev_put(dev);
+ return error;
}
if (vpi == ATM_VPI_UNSPEC || vci == ATM_VCI_UNSPEC)
set_bit(ATM_VF_PARTIAL,&vcc->flags);