diff options
Diffstat (limited to 'net/atm/common.c')
-rw-r--r-- | net/atm/common.c | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/net/atm/common.c b/net/atm/common.c index 63feea49fb13..83454e12317d 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) | |||
423 | if (vcc->qos.txtp.traffic_class == ATM_ANYCLASS || | 423 | if (vcc->qos.txtp.traffic_class == ATM_ANYCLASS || |
424 | vcc->qos.rxtp.traffic_class == ATM_ANYCLASS) | 424 | vcc->qos.rxtp.traffic_class == ATM_ANYCLASS) |
425 | return -EINVAL; | 425 | return -EINVAL; |
426 | if (itf != ATM_ITF_ANY) { | 426 | if (likely(itf != ATM_ITF_ANY)) { |
427 | dev = atm_dev_lookup(itf); | 427 | dev = atm_dev_lookup(itf); |
428 | if (!dev) | ||
429 | return -ENODEV; | ||
430 | error = __vcc_connect(vcc, dev, vpi, vci); | ||
431 | if (error) { | ||
432 | atm_dev_put(dev); | ||
433 | return error; | ||
434 | } | ||
435 | } else { | 428 | } else { |
436 | struct list_head *p, *next; | ||
437 | |||
438 | dev = NULL; | 429 | dev = NULL; |
439 | spin_lock(&atm_dev_lock); | 430 | spin_lock(&atm_dev_lock); |
440 | list_for_each_safe(p, next, &atm_devs) { | 431 | if (!list_empty(&atm_devs)) { |
441 | dev = list_entry(p, struct atm_dev, dev_list); | 432 | dev = list_entry(atm_devs.next, struct atm_dev, dev_list); |
442 | atm_dev_hold(dev); | 433 | atm_dev_hold(dev); |
443 | spin_unlock(&atm_dev_lock); | ||
444 | if (!__vcc_connect(vcc, dev, vpi, vci)) | ||
445 | break; | ||
446 | atm_dev_put(dev); | ||
447 | dev = NULL; | ||
448 | spin_lock(&atm_dev_lock); | ||
449 | } | 434 | } |
450 | spin_unlock(&atm_dev_lock); | 435 | spin_unlock(&atm_dev_lock); |
451 | if (!dev) | 436 | } |
452 | return -ENODEV; | 437 | if (!dev) |
438 | return -ENODEV; | ||
439 | error = __vcc_connect(vcc, dev, vpi, vci); | ||
440 | if (error) { | ||
441 | atm_dev_put(dev); | ||
442 | return error; | ||
453 | } | 443 | } |
454 | if (vpi == ATM_VPI_UNSPEC || vci == ATM_VCI_UNSPEC) | 444 | if (vpi == ATM_VPI_UNSPEC || vci == ATM_VCI_UNSPEC) |
455 | set_bit(ATM_VF_PARTIAL,&vcc->flags); | 445 | set_bit(ATM_VF_PARTIAL,&vcc->flags); |