]> git.hungrycats.org Git - linux/commitdiff
[ATM]: Eliminate atm_find_ci().
authorChas Williams <chas@cmf.nrl.navy.mil>
Wed, 8 Oct 2003 02:11:48 +0000 (19:11 -0700)
committerDavid S. Miller <davem@nuts.ninka.net>
Wed, 8 Oct 2003 02:11:48 +0000 (19:11 -0700)
16 files changed:
drivers/atm/ambassador.c
drivers/atm/atmtcp.c
drivers/atm/eni.c
drivers/atm/firestream.c
drivers/atm/fore200e.c
drivers/atm/he.c
drivers/atm/horizon.c
drivers/atm/idt77252.c
drivers/atm/iphase.c
drivers/atm/lanai.c
drivers/atm/nicstar.c
drivers/atm/zatm.c
drivers/usb/misc/speedtch.c
include/linux/atmdev.h
net/atm/atm_misc.c
net/atm/common.c

index d119d0e56560bd3b1959496a9ed1d2cbb45c3d7f..17a788aff5cb77a41d8a054488ee7a07e6d1c36d 100644 (file)
@@ -1064,7 +1064,8 @@ static unsigned int make_rate (unsigned int rate, rounding r,
 
 /********** Open a VC **********/
 
-static int amb_open (struct atm_vcc * atm_vcc, short vpi, int vci) {
+static int amb_open (struct atm_vcc * atm_vcc)
+{
   int error;
   
   struct atm_qos * qos;
@@ -1077,6 +1078,8 @@ static int amb_open (struct atm_vcc * atm_vcc, short vpi, int vci) {
   amb_dev * dev = AMB_DEV(atm_vcc->dev);
   amb_vcc * vcc;
   unsigned char pool = -1; // hush gcc
+  short vpi = atm_vcc->vpi;
+  int vci = atm_vcc->vci;
   
   PRINTD (DBG_FLOW|DBG_VCC, "amb_open %x %x", vpi, vci);
   
@@ -1088,14 +1091,6 @@ static int amb_open (struct atm_vcc * atm_vcc, short vpi, int vci) {
   }
 #endif
   
-  // deal with possibly wildcarded VCs
-  error = atm_find_ci (atm_vcc, &vpi, &vci);
-  if (error) {
-    PRINTD (DBG_WARN|DBG_VCC, "atm_find_ci failed!");
-    return error;
-  }
-  PRINTD (DBG_VCC, "atm_find_ci gives %x %x", vpi, vci);
-  
   if (!(0 <= vpi && vpi < (1<<NUM_VPI_BITS) &&
        0 <= vci && vci < (1<<NUM_VCI_BITS))) {
     PRINTD (DBG_WARN|DBG_VCC, "VPI/VCI out of range: %hd/%d", vpi, vci);
@@ -1274,10 +1269,6 @@ static int amb_open (struct atm_vcc * atm_vcc, short vpi, int vci) {
     up (&dev->vcc_sf);
   }
   
-  // set elements of vcc
-  atm_vcc->vpi = vpi; // 0
-  atm_vcc->vci = vci;
-  
   // indicate readiness
   set_bit(ATM_VF_READY,&atm_vcc->flags);
   
index 744159897ea0f9941ddecc14ff12277c3c3b91f1..f673b7705171406ad76815dd91fe9f57f46ea0a3 100644 (file)
@@ -115,10 +115,12 @@ static void atmtcp_v_dev_close(struct atm_dev *dev)
 }
 
 
-static int atmtcp_v_open(struct atm_vcc *vcc,short vpi,int vci)
+static int atmtcp_v_open(struct atm_vcc *vcc)
 {
        struct atmtcp_control msg;
        int error;
+       short vpi = vcc->vpi;
+       int vci = vcc->vci;
 
        memset(&msg,0,sizeof(msg));
        msg.addr.sap_family = AF_ATMPVC;
@@ -126,8 +128,6 @@ static int atmtcp_v_open(struct atm_vcc *vcc,short vpi,int vci)
        msg.addr.sap_addr.vpi = vpi;
        msg.hdr.vci = htons(vci);
        msg.addr.sap_addr.vci = vci;
-       error = atm_find_ci(vcc,&msg.addr.sap_addr.vpi,&msg.addr.sap_addr.vci);
-       if (error) return error;
        if (vpi == ATM_VPI_UNSPEC || vci == ATM_VCI_UNSPEC) return 0;
        msg.type = ATMTCP_CTRL_OPEN;
        msg.qos = vcc->qos;
index 45e3f57fbdffd3df1696a0c707d1812dad916775..27f3b486edd4bbe72ff8e5e66b3c2629e431d173 100644 (file)
@@ -1881,80 +1881,18 @@ static void eni_close(struct atm_vcc *vcc)
 }
 
 
-static int get_ci(struct atm_vcc *vcc,short *vpi,int *vci)
-{
-       struct sock *s;
-       struct hlist_node *node;
-       struct atm_vcc *walk;
-
-       read_lock(&vcc_sklist_lock);
-       if (*vpi == ATM_VPI_ANY) *vpi = 0;
-       if (*vci == ATM_VCI_ANY) {
-               for (*vci = ATM_NOT_RSV_VCI; *vci < NR_VCI; (*vci)++) {
-                       if (vcc->qos.rxtp.traffic_class != ATM_NONE &&
-                           ENI_DEV(vcc->dev)->rx_map[*vci])
-                               continue;
-                       if (vcc->qos.txtp.traffic_class != ATM_NONE) {
-                               sk_for_each(s, node, &vcc_sklist) {
-                                       walk = atm_sk(s);
-                                       if (walk->dev != vcc->dev)
-                                               continue;
-                                       if (test_bit(ATM_VF_ADDR,&walk->flags)
-                                           && walk->vci == *vci &&
-                                           walk->qos.txtp.traffic_class !=
-                                           ATM_NONE)
-                                               break;
-                               }
-                               if (node)
-                                       continue;
-                       }
-                       break;
-               }
-               read_unlock(&vcc_sklist_lock);
-               return *vci == NR_VCI ? -EADDRINUSE : 0;
-       }
-       if (*vci == ATM_VCI_UNSPEC) {
-               read_unlock(&vcc_sklist_lock);
-               return 0;
-       }
-       if (vcc->qos.rxtp.traffic_class != ATM_NONE &&
-           ENI_DEV(vcc->dev)->rx_map[*vci]) {
-               read_unlock(&vcc_sklist_lock);
-               return -EADDRINUSE;
-       }
-       if (vcc->qos.txtp.traffic_class == ATM_NONE) {
-               read_unlock(&vcc_sklist_lock);
-               return 0;
-       }
-       sk_for_each(s, node, &vcc_sklist) {
-               walk = atm_sk(s);
-               if (walk->dev != vcc->dev)
-                       continue;
-               if (test_bit(ATM_VF_ADDR,&walk->flags) && walk->vci == *vci &&
-                   walk->qos.txtp.traffic_class != ATM_NONE) {
-                       read_unlock(&vcc_sklist_lock);
-                       return -EADDRINUSE;
-               }
-       }
-       read_unlock(&vcc_sklist_lock);
-       return 0;
-}
-
-
-static int eni_open(struct atm_vcc *vcc,short vpi,int vci)
+static int eni_open(struct atm_vcc *vcc)
 {
        struct eni_dev *eni_dev;
        struct eni_vcc *eni_vcc;
        int error;
+       short vpi = vcc->vpi;
+       int vci = vcc->vci;
 
        DPRINTK(">eni_open\n");
        EVENT("eni_open\n",0,0);
        if (!test_bit(ATM_VF_PARTIAL,&vcc->flags)) ENI_VCC(vcc) = NULL;
        eni_dev = ENI_DEV(vcc->dev);
-       error = get_ci(vcc,&vpi,&vci);
-       if (error) return error;
-       vcc->vpi = vpi;
-       vcc->vci = vci;
        if (vci != ATM_VPI_UNSPEC && vpi != ATM_VCI_UNSPEC)
                set_bit(ATM_VF_ADDR,&vcc->flags);
        if (vcc->qos.aal != ATM_AAL0 && vcc->qos.aal != ATM_AAL5)
index 98cb2fce6bfef8cbbc8faacc8ccd728fe98e7fe4..f45adbb4c59f90856511a1b7ffffb076c7019ed3 100644 (file)
@@ -854,7 +854,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
 
 #define DO_DIRECTION(tp) ((tp)->traffic_class != ATM_NONE)
 
-static int fs_open(struct atm_vcc *atm_vcc, short vpi, int vci)
+static int fs_open(struct atm_vcc *atm_vcc)
 {
        struct fs_dev *dev;
        struct fs_vcc *vcc;
@@ -867,6 +867,8 @@ static int fs_open(struct atm_vcc *atm_vcc, short vpi, int vci)
        int bfp;
        int to;
        unsigned short tmc0;
+       short vpi = atm_vcc->vpi;
+       int vci = atm_vcc->vci;
 
        func_enter ();
 
@@ -874,14 +876,6 @@ static int fs_open(struct atm_vcc *atm_vcc, short vpi, int vci)
        fs_dprintk (FS_DEBUG_OPEN, "fs: open on dev: %p, vcc at %p\n", 
                    dev, atm_vcc);
 
-       error = atm_find_ci(atm_vcc, &vpi, &vci);
-       if (error) {
-               fs_dprintk (FS_DEBUG_OPEN, "fs: find_ci failed.\n");
-               return error;
-       }
-
-       atm_vcc->vpi = vpi;
-       atm_vcc->vci = vci;
        if (vci != ATM_VPI_UNSPEC && vpi != ATM_VCI_UNSPEC)
                set_bit(ATM_VF_ADDR, &atm_vcc->flags);
 
index bc801c8e13bdf188df7f99c215d8aee39c5f7252..53f4955746573d644c3cfbd481d95cc5e9ed8a57 100644 (file)
@@ -1351,56 +1351,6 @@ fore200e_activate_vcin(struct fore200e* fore200e, int activate, struct atm_vcc*
 }
 
 
-static int
-fore200e_walk_vccs(struct atm_vcc *vcc, short *vpi, int *vci)
-{
-    struct atm_vcc* walk;
-    struct sock *s;
-    struct hlist_node *node;
-
-    /* find a free VPI */
-
-    read_lock(&vcc_sklist_lock);
-
-    if (*vpi == ATM_VPI_ANY) {
-
-       *vpi = 0;
-restart_vpi_search:
-       sk_for_each(s, node, &vcc_sklist) {
-           walk = atm_sk(s);
-           if (walk->dev != vcc->dev)
-               continue;
-
-           if ((walk->vci == *vci) && (walk->vpi == *vpi)) {
-               (*vpi)++;
-               goto restart_vpi_search;
-           }
-       }
-    }
-
-    /* find a free VCI */
-    if (*vci == ATM_VCI_ANY) {
-       
-       *vci = ATM_NOT_RSV_VCI;
-restart_vci_search:
-       sk_for_each(s, node, &vcc_sklist) {
-           walk = atm_sk(s);
-           if (walk->dev != vcc->dev)
-               continue;
-
-           if ((walk->vpi = *vpi) && (walk->vci == *vci)) {
-               *vci = walk->vci + 1;
-               goto restart_vci_search;
-           }
-       }
-    }
-
-    read_unlock(&vcc_sklist_lock);
-
-    return 0;
-}
-
-
 #define FORE200E_MAX_BACK2BACK_CELLS 255    /* XXX depends on CDVT */
 
 static void
@@ -1420,17 +1370,13 @@ fore200e_rate_ctrl(struct atm_qos* qos, struct tpd_rate* rate)
 
 
 static int
-fore200e_open(struct atm_vcc *vcc, short vpi, int vci)
+fore200e_open(struct atm_vcc *vcc)
 {
     struct fore200e*     fore200e = FORE200E_DEV(vcc->dev);
     struct fore200e_vcc* fore200e_vcc;
+    short vpi = vcc->vpi;
+    int vci = vcc->vci;
     
-    /* find a free VPI/VCI */
-    fore200e_walk_vccs(vcc, &vpi, &vci);
-
-    vcc->vpi = vpi;
-    vcc->vci = vci;
-
     /* ressource checking only? */
     if (vci == ATM_VCI_UNSPEC || vpi == ATM_VPI_UNSPEC)
        return 0;
index 470244b70942d19913c9352eacf42247c2d9093b..ec33717c28fa464efe65755065ac86a84bdf52e2 100644 (file)
@@ -135,7 +135,7 @@ static char *version = "$Id: he.c,v 1.18 2003/05/06 22:57:15 chas Exp $";
 
 /* declarations */
 
-static int he_open(struct atm_vcc *vcc, short vpi, int vci);
+static int he_open(struct atm_vcc *vcc);
 static void he_close(struct atm_vcc *vcc);
 static int he_send(struct atm_vcc *vcc, struct sk_buff *skb);
 static int he_ioctl(struct atm_dev *dev, unsigned int cmd, void *arg);
@@ -2333,23 +2333,18 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
 }
 
 static int
-he_open(struct atm_vcc *vcc, short vpi, int vci)
+he_open(struct atm_vcc *vcc)
 {
        unsigned long flags;
        struct he_dev *he_dev = HE_DEV(vcc->dev);
        struct he_vcc *he_vcc;
        int err = 0;
        unsigned cid, rsr0, rsr1, rsr4, tsr0, tsr0_aal, tsr4, period, reg, clock;
+       short vpi = vcc->vpi;
+       int vci = vcc->vci;
 
-       
-       if ((err = atm_find_ci(vcc, &vpi, &vci))) {
-               HPRINTK("atm_find_ci err = %d\n", err);
-               return err;
-       }
        if (vci == ATM_VCI_UNSPEC || vpi == ATM_VPI_UNSPEC)
                return 0;
-       vcc->vpi = vpi;
-       vcc->vci = vci;
 
        HPRINTK("open vcc %p %d.%d\n", vcc, vpi, vci);
 
index 911eab75200b3200582bb222fa431fea422e8476..00a164af68303ae34740a6760bca3f519ebe2818 100644 (file)
@@ -2174,7 +2174,8 @@ static int atm_pcr_check (struct atm_trafprm * tp, unsigned int pcr) {
 
 /********** open VC **********/
 
-static int hrz_open (struct atm_vcc * atm_vcc, short vpi, int vci) {
+static int hrz_open (struct atm_vcc *atm_vcc)
+{
   int error;
   u16 channel;
   
@@ -2185,6 +2186,8 @@ static int hrz_open (struct atm_vcc * atm_vcc, short vpi, int vci) {
   hrz_dev * dev = HRZ_DEV(atm_vcc->dev);
   hrz_vcc vcc;
   hrz_vcc * vccp; // allocated late
+  short vpi = atm_vcc->vpi;
+  int vci = atm_vcc->vci;
   PRINTD (DBG_FLOW|DBG_VCC, "hrz_open %x %x", vpi, vci);
   
 #ifdef ATM_VPI_UNSPEC
@@ -2195,14 +2198,6 @@ static int hrz_open (struct atm_vcc * atm_vcc, short vpi, int vci) {
   }
 #endif
   
-  // deal with possibly wildcarded VCs
-  error = atm_find_ci (atm_vcc, &vpi, &vci);
-  if (error) {
-    PRINTD (DBG_WARN|DBG_VCC, "atm_find_ci failed!");
-    return error;
-  }
-  PRINTD (DBG_VCC, "atm_find_ci gives %x %x", vpi, vci);
-  
   error = vpivci_to_channel (&channel, vpi, vci);
   if (error) {
     PRINTD (DBG_WARN|DBG_VCC, "VPI/VCI out of range: %hd/%d", vpi, vci);
@@ -2557,8 +2552,6 @@ static int hrz_open (struct atm_vcc * atm_vcc, short vpi, int vci) {
   }
   
   // success, set elements of atm_vcc
-  atm_vcc->vpi = vpi;
-  atm_vcc->vci = vci;
   atm_vcc->dev_data = (void *) vccp;
   
   // indicate readiness
index 86ff59491a9a088fffb2ae25e88278e4939ca2ff..a758c226e150c68227eac00784dd70dcc50d9464 100644 (file)
@@ -122,7 +122,7 @@ static void idt77252_tx(struct idt77252_dev *);
  * ATM Interface.
  */
 static void idt77252_dev_close(struct atm_dev *dev);
-static int idt77252_open(struct atm_vcc *vcc, short vpi, int vci);
+static int idt77252_open(struct atm_vcc *vcc);
 static void idt77252_close(struct atm_vcc *vcc);
 static int idt77252_send(struct atm_vcc *vcc, struct sk_buff *skb);
 static int idt77252_send_oam(struct atm_vcc *vcc, void *cell,
@@ -2402,50 +2402,7 @@ idt77252_init_rx(struct idt77252_dev *card, struct vc_map *vc,
 }
 
 static int
-idt77252_find_vcc(struct atm_vcc *vcc, short *vpi, int *vci)
-{
-       struct sock *s;
-       struct atm_vcc *walk;
-
-       read_lock(&vcc_sklist_lock);
-       if (*vpi == ATM_VPI_ANY) {
-               *vpi = 0;
-               s = sk_head(&vcc_sklist);
-               while (s) {
-                       walk = atm_sk(s);
-                       if (walk->dev != vcc->dev)
-                               continue;
-                       if ((walk->vci == *vci) && (walk->vpi == *vpi)) {
-                               (*vpi)++;
-                               s = sk_head(&vcc_sklist);
-                               continue;
-                       }
-                       s = sk_next(s);
-               }
-       }
-
-       if (*vci == ATM_VCI_ANY) {
-               *vci = ATM_NOT_RSV_VCI;
-               s = sk_head(&vcc_sklist);
-               while (s) {
-                       walk = atm_sk(s);
-                       if (walk->dev != vcc->dev)
-                               continue;
-                       if ((walk->vci == *vci) && (walk->vpi == *vpi)) {
-                               (*vci)++;
-                               s = sk_head(&vcc_sklist);
-                               continue;
-                       }
-                       s = sk_next(s);
-               }
-       }
-
-       read_unlock(&vcc_sklist_lock);
-       return 0;
-}
-
-static int
-idt77252_open(struct atm_vcc *vcc, short vpi, int vci)
+idt77252_open(struct atm_vcc *vcc)
 {
        struct atm_dev *dev = vcc->dev;
        struct idt77252_dev *card = dev->dev_data;
@@ -2453,8 +2410,8 @@ idt77252_open(struct atm_vcc *vcc, short vpi, int vci)
        unsigned int index;
        unsigned int inuse;
        int error;
-
-       idt77252_find_vcc(vcc, &vpi, &vci);
+       int vci = vcc->vci;
+       short vpi = vcc->vpi;
 
        if (vpi == ATM_VPI_UNSPEC || vci == ATM_VCI_UNSPEC)
                return 0;
@@ -2469,8 +2426,6 @@ idt77252_open(struct atm_vcc *vcc, short vpi, int vci)
                return -EINVAL;
        }
 
-       vcc->vpi = vpi;
-       vcc->vci = vci;
        set_bit(ATM_VF_ADDR, &vcc->flags);
 
        down(&card->mutex);
index d0257727e8b8059a733827f578ca533db93a2d44..478fa3961a8bc73627e24172f3770c44a65927a0 100644 (file)
@@ -2676,7 +2676,7 @@ static void ia_close(struct atm_vcc *vcc)
         return;        
 }  
   
-static int ia_open(struct atm_vcc *vcc, short vpi, int vci)  
+static int ia_open(struct atm_vcc *vcc)
 {  
        IADEV *iadev;  
        struct ia_vcc *ia_vcc;  
@@ -2687,15 +2687,7 @@ static int ia_open(struct atm_vcc *vcc, short vpi, int vci)
                INPH_IA_VCC(vcc) = NULL;  
        }  
        iadev = INPH_IA_DEV(vcc->dev);  
-       error = atm_find_ci(vcc, &vpi, &vci);  
-       if (error)   
-       {  
-           printk("iadev: atm_find_ci returned error %d\n", error);  
-           return error;  
-       }  
-       vcc->vpi = vpi;  
-       vcc->vci = vci;  
-       if (vci != ATM_VPI_UNSPEC && vpi != ATM_VCI_UNSPEC)  
+       if (vcc->vci != ATM_VPI_UNSPEC && vcc->vpi != ATM_VCI_UNSPEC)  
        {  
                IF_EVENT(printk("iphase open: unspec part\n");)  
                set_bit(ATM_VF_ADDR,&vcc->flags);
index 101a71c4831d307634c18cc97a3b97eefd354e52..cb99c67b5abafc88704f868ebe88f5b49988df9f 100644 (file)
@@ -2350,11 +2350,13 @@ static void lanai_close(struct atm_vcc *atmvcc)
 }
 
 /* open a vcc on the card to vpi/vci */
-static int lanai_open(struct atm_vcc *atmvcc, short vpi, int vci)
+static int lanai_open(struct atm_vcc *atmvcc)
 {
        struct lanai_dev *lanai;
        struct lanai_vcc *lvcc;
        int result = 0;
+       int vci = atmvcc->vci;
+       short vpi = atmvcc->vpi;
        /* we don't support partial open - it's not really useful anyway */
        if ((test_bit(ATM_VF_PARTIAL, &atmvcc->flags)) ||
            (vpi == ATM_VPI_UNSPEC) || (vci == ATM_VCI_UNSPEC))
@@ -2363,8 +2365,6 @@ static int lanai_open(struct atm_vcc *atmvcc, short vpi, int vci)
        result = lanai_normalize_ci(lanai, atmvcc, &vpi, &vci);
        if (unlikely(result != 0))
                goto out;
-       atmvcc->vpi = vpi;
-       atmvcc->vci = vci;
        set_bit(ATM_VF_ADDR, &atmvcc->flags);
        if (atmvcc->qos.aal != ATM_AAL0 && atmvcc->qos.aal != ATM_AAL5)
                return -EINVAL;
index ee68d05635bba86c193960e71e32a80c0176e56a..4fd82600163ce1274b9fcfc3ae51f3de09bedb13 100644 (file)
@@ -221,7 +221,7 @@ static void free_scq(scq_info *scq, struct atm_vcc *vcc);
 static void push_rxbufs(ns_dev *card, u32 type, u32 handle1, u32 addr1,
                        u32 handle2, u32 addr2);
 static irqreturn_t ns_irq_handler(int irq, void *dev_id, struct pt_regs *regs);
-static int ns_open(struct atm_vcc *vcc, short vpi, int vci);
+static int ns_open(struct atm_vcc *vcc);
 static void ns_close(struct atm_vcc *vcc);
 static void fill_tst(ns_dev *card, int n, vc_map *vc);
 static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb);
@@ -1371,11 +1371,10 @@ static irqreturn_t ns_irq_handler(int irq, void *dev_id, struct pt_regs *regs)
 
 
 
-static int ns_open(struct atm_vcc *vcc, short vpi, int vci)
+static int ns_open(struct atm_vcc *vcc)
 {
    ns_dev *card;
    vc_map *vc;
-   int error;
    unsigned long tmpl, modl;
    int tcr, tcra;      /* target cell rate, and absolute value */
    int n = 0;          /* Number of entries in the TST. Initialized to remove
@@ -1386,6 +1385,8 @@ static int ns_open(struct atm_vcc *vcc, short vpi, int vci)
                           tell which variables can truly be used
                           uninitialized... */
    int inuse;          /* tx or rx vc already in use by another vcc */
+   short vpi = vcc->vpi;
+   int vci = vcc->vci;
 
    card = (ns_dev *) vcc->dev->dev_data;
    PRINTK("nicstar%d: opening vpi.vci %d.%d \n", card->index, (int) vpi, vci);
@@ -1395,14 +1396,7 @@ static int ns_open(struct atm_vcc *vcc, short vpi, int vci)
       return -EINVAL;
    }
 
-   if ((error = atm_find_ci(vcc, &vpi, &vci)))
-   {
-      PRINTK("nicstar%d: error in atm_find_ci().\n", card->index);
-      return error;
-   }
    vc = &(card->vcmap[vpi << card->vcibits | vci]);
-   vcc->vpi = vpi;
-   vcc->vci = vci;
    vcc->dev_data = vc;
 
    inuse = 0;
index de4e075a5eeedbd55f55ee6a67651c9c6484f105..383eca59b67caa3b5005825c6a99ae2fce30e70d 100644 (file)
@@ -1373,19 +1373,17 @@ static void zatm_close(struct atm_vcc *vcc)
 }
 
 
-static int zatm_open(struct atm_vcc *vcc,short vpi,int vci)
+static int zatm_open(struct atm_vcc *vcc)
 {
        struct zatm_dev *zatm_dev;
        struct zatm_vcc *zatm_vcc;
+       short vpi = vcc->vpi;
+       int vci = vcc->vci;
        int error;
 
        DPRINTK(">zatm_open\n");
        zatm_dev = ZATM_DEV(vcc->dev);
        if (!test_bit(ATM_VF_PARTIAL,&vcc->flags)) ZATM_VCC(vcc) = NULL;
-       error = atm_find_ci(vcc,&vpi,&vci);
-       if (error) return error;
-       vcc->vpi = vpi;
-       vcc->vci = vci;
        if (vci != ATM_VPI_UNSPEC && vpi != ATM_VCI_UNSPEC)
                set_bit(ATM_VF_ADDR,&vcc->flags);
        if (vcc->qos.aal != ATM_AAL5) return -EINVAL; /* @@@ AAL0 */
index 6efb367328525c79df8567d866357836ab1e659f..b3908d9c8357d1a42997dc8af76acd79eace2e46 100644 (file)
@@ -263,7 +263,7 @@ struct udsl_instance_data {
 /* ATM */
 
 static void udsl_atm_dev_close (struct atm_dev *dev);
-static int udsl_atm_open (struct atm_vcc *vcc, short vpi, int vci);
+static int udsl_atm_open (struct atm_vcc *vcc);
 static void udsl_atm_close (struct atm_vcc *vcc);
 static int udsl_atm_ioctl (struct atm_dev *dev, unsigned int cmd, void *arg);
 static int udsl_atm_send (struct atm_vcc *vcc, struct sk_buff *skb);
@@ -863,11 +863,13 @@ static int udsl_atm_proc_read (struct atm_dev *atm_dev, loff_t *pos, char *page)
        return 0;
 }
 
-static int udsl_atm_open (struct atm_vcc *vcc, short vpi, int vci)
+static int udsl_atm_open (struct atm_vcc *vcc)
 {
        struct udsl_instance_data *instance = vcc->dev->dev_data;
        struct udsl_vcc_data *new;
        unsigned int max_pdu;
+       int vci = vcc->vci;
+       short vpi = vcc->vpi;
 
        dbg ("udsl_atm_open: vpi %hd, vci %d", vpi, vci);
 
@@ -876,9 +878,6 @@ static int udsl_atm_open (struct atm_vcc *vcc, short vpi, int vci)
                return -ENODEV;
        }
 
-       if ((vpi == ATM_VPI_ANY) || (vci == ATM_VCI_ANY))
-               return -EINVAL;
-
        /* only support AAL5 */
        if ((vcc->qos.aal != ATM_AAL5) || (vcc->qos.rxtp.max_sdu < 0) || (vcc->qos.rxtp.max_sdu > ATM_MAX_AAL5_PDU)) {
                dbg ("udsl_atm_open: unsupported ATM type %d!", vcc->qos.aal);
@@ -919,8 +918,6 @@ static int udsl_atm_open (struct atm_vcc *vcc, short vpi, int vci)
        }
 
        vcc->dev_data = new;
-       vcc->vpi = vpi;
-       vcc->vci = vci;
 
        tasklet_disable (&instance->receive_tasklet);
        list_add (&new->list, &instance->vcc_list);
index c050f5537da4825d5560b094d4217ff280c0cc05..7a190d47b60ebd34a0e8e2a2e6c4cb3f27744e93 100644 (file)
@@ -351,7 +351,7 @@ struct atm_dev {
 
 struct atmdev_ops { /* only send is required */
        void (*dev_close)(struct atm_dev *dev);
-       int (*open)(struct atm_vcc *vcc,short vpi,int vci);
+       int (*open)(struct atm_vcc *vcc);
        void (*close)(struct atm_vcc *vcc);
        int (*ioctl)(struct atm_dev *dev,unsigned int cmd,void *arg);
        int (*getsockopt)(struct atm_vcc *vcc,int level,int optname,
@@ -443,7 +443,6 @@ static inline void atm_dev_put(struct atm_dev *dev)
 int atm_charge(struct atm_vcc *vcc,int truesize);
 struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc,int pdu_size,
     int gfp_flags);
-int atm_find_ci(struct atm_vcc *vcc,short *vpi,int *vci);
 int atm_pcr_goal(struct atm_trafprm *tp);
 
 void vcc_release_async(struct atm_vcc *vcc, int reply);
index fc33330ff6c0371a97b8a0156a3480d165185184..d842ecd4bfd1c4b442e4702faca0f994d6267026 100644 (file)
@@ -45,76 +45,6 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc,int pdu_size,
 }
 
 
-static int check_ci(struct atm_vcc *vcc,short vpi,int vci)
-{
-       struct hlist_node *node;
-       struct sock *s;
-       struct atm_vcc *walk;
-
-       sk_for_each(s, node, &vcc_sklist) {
-               walk = atm_sk(s);
-               if (walk->dev != vcc->dev)
-                       continue;
-               if (test_bit(ATM_VF_ADDR,&walk->flags) && walk->vpi == vpi &&
-                   walk->vci == vci && ((walk->qos.txtp.traffic_class !=
-                   ATM_NONE && vcc->qos.txtp.traffic_class != ATM_NONE) ||
-                   (walk->qos.rxtp.traffic_class != ATM_NONE &&
-                   vcc->qos.rxtp.traffic_class != ATM_NONE)))
-                       return -EADDRINUSE;
-       }
-               /* allow VCCs with same VPI/VCI iff they don't collide on
-                  TX/RX (but we may refuse such sharing for other reasons,
-                  e.g. if protocol requires to have both channels) */
-       return 0;
-}
-
-
-int atm_find_ci(struct atm_vcc *vcc,short *vpi,int *vci)
-{
-       static short p;        /* poor man's per-device cache */
-       static int c;
-       short old_p;
-       int old_c;
-       int err;
-
-       read_lock(&vcc_sklist_lock);
-       if (*vpi != ATM_VPI_ANY && *vci != ATM_VCI_ANY) {
-               err = check_ci(vcc,*vpi,*vci);
-               read_unlock(&vcc_sklist_lock);
-               return err;
-       }
-       /* last scan may have left values out of bounds for current device */
-       if (*vpi != ATM_VPI_ANY) p = *vpi;
-       else if (p >= 1 << vcc->dev->ci_range.vpi_bits) p = 0;
-       if (*vci != ATM_VCI_ANY) c = *vci;
-       else if (c < ATM_NOT_RSV_VCI || c >= 1 << vcc->dev->ci_range.vci_bits)
-                       c = ATM_NOT_RSV_VCI;
-       old_p = p;
-       old_c = c;
-       do {
-               if (!check_ci(vcc,p,c)) {
-                       *vpi = p;
-                       *vci = c;
-                       read_unlock(&vcc_sklist_lock);
-                       return 0;
-               }
-               if (*vci == ATM_VCI_ANY) {
-                       c++;
-                       if (c >= 1 << vcc->dev->ci_range.vci_bits)
-                               c = ATM_NOT_RSV_VCI;
-               }
-               if ((c == ATM_NOT_RSV_VCI || *vci != ATM_VCI_ANY) &&
-                   *vpi == ATM_VPI_ANY) {
-                       p++;
-                       if (p >= 1 << vcc->dev->ci_range.vpi_bits) p = 0;
-               }
-       }
-       while (old_p != p || old_c != c);
-       read_unlock(&vcc_sklist_lock);
-       return -EADDRINUSE;
-}
-
-
 /*
  * atm_pcr_goal returns the positive PCR if it should be rounded up, the
  * negative PCR if it should be rounded down, and zero if the maximum available
@@ -170,7 +100,6 @@ void sonet_subtract_stats(struct k_sonet_stats *from,struct sonet_stats *to)
 
 EXPORT_SYMBOL(atm_charge);
 EXPORT_SYMBOL(atm_alloc_charge);
-EXPORT_SYMBOL(atm_find_ci);
 EXPORT_SYMBOL(atm_pcr_goal);
 EXPORT_SYMBOL(sonet_copy_stats);
 EXPORT_SYMBOL(sonet_subtract_stats);
index af93929b0affd71e93513ccc0e37d9088790c062..13e1a844c9d7a8ea9fe41d4a1b7fa7a570348411 100644 (file)
@@ -248,7 +248,78 @@ static int adjust_tp(struct atm_trafprm *tp,unsigned char aal)
 }
 
 
-static int __vcc_connect(struct atm_vcc *vcc, struct atm_dev *dev, int vpi,
+static int check_ci(struct atm_vcc *vcc, short vpi, int vci)
+{
+       struct hlist_node *node;
+       struct sock *s;
+       struct atm_vcc *walk;
+
+       sk_for_each(s, node, &vcc_sklist) {
+               walk = atm_sk(s);
+               if (walk->dev != vcc->dev)
+                       continue;
+               if (test_bit(ATM_VF_ADDR, &walk->flags) && walk->vpi == vpi &&
+                   walk->vci == vci && ((walk->qos.txtp.traffic_class !=
+                   ATM_NONE && vcc->qos.txtp.traffic_class != ATM_NONE) ||
+                   (walk->qos.rxtp.traffic_class != ATM_NONE &&
+                   vcc->qos.rxtp.traffic_class != ATM_NONE)))
+                       return -EADDRINUSE;
+       }
+
+       /* allow VCCs with same VPI/VCI iff they don't collide on
+          TX/RX (but we may refuse such sharing for other reasons,
+          e.g. if protocol requires to have both channels) */
+
+       return 0;
+}
+
+
+static int find_ci(struct atm_vcc *vcc, short *vpi, int *vci)
+{
+       static short p;        /* poor man's per-device cache */
+       static int c;
+       short old_p;
+       int old_c;
+       int err;
+
+       if (*vpi != ATM_VPI_ANY && *vci != ATM_VCI_ANY) {
+               err = check_ci(vcc, *vpi, *vci);
+               return err;
+       }
+       /* last scan may have left values out of bounds for current device */
+       if (*vpi != ATM_VPI_ANY)
+               p = *vpi;
+       else if (p >= 1 << vcc->dev->ci_range.vpi_bits)
+               p = 0;
+       if (*vci != ATM_VCI_ANY)
+               c = *vci;
+       else if (c < ATM_NOT_RSV_VCI || c >= 1 << vcc->dev->ci_range.vci_bits)
+                       c = ATM_NOT_RSV_VCI;
+       old_p = p;
+       old_c = c;
+       do {
+               if (!check_ci(vcc, p, c)) {
+                       *vpi = p;
+                       *vci = c;
+                       return 0;
+               }
+               if (*vci == ATM_VCI_ANY) {
+                       c++;
+                       if (c >= 1 << vcc->dev->ci_range.vci_bits)
+                               c = ATM_NOT_RSV_VCI;
+               }
+               if ((c == ATM_NOT_RSV_VCI || *vci != ATM_VCI_ANY) &&
+                   *vpi == ATM_VPI_ANY) {
+                       p++;
+                       if (p >= 1 << vcc->dev->ci_range.vpi_bits) p = 0;
+               }
+       }
+       while (old_p != p || old_c != c);
+       return -EADDRINUSE;
+}
+
+
+static int __vcc_connect(struct atm_vcc *vcc, struct atm_dev *dev, short vpi,
                         int vci)
 {
        int error;
@@ -260,8 +331,18 @@ static int __vcc_connect(struct atm_vcc *vcc, struct atm_dev *dev, int vpi,
        if (vci > 0 && vci < ATM_NOT_RSV_VCI && !capable(CAP_NET_BIND_SERVICE))
                return -EPERM;
        error = 0;
+       if (!try_module_get(dev->ops->owner))
+               return -ENODEV;
        vcc->dev = dev;
-       vcc_insert_socket(vcc->sk);
+       write_lock_irq(&vcc_sklist_lock);
+       if ((error = find_ci(vcc, &vpi, &vci))) {
+               write_unlock_irq(&vcc_sklist_lock);
+               goto fail_module_put;
+       }
+       vcc->vpi = vpi;
+       vcc->vci = vci;
+       __vcc_insert_socket(vcc->sk);
+       write_unlock_irq(&vcc_sklist_lock);
        switch (vcc->qos.aal) {
                case ATM_AAL0:
                        error = atm_init_aal0(vcc);
@@ -291,21 +372,17 @@ static int __vcc_connect(struct atm_vcc *vcc, struct atm_dev *dev, int vpi,
            vcc->qos.txtp.min_pcr,vcc->qos.txtp.max_pcr,vcc->qos.txtp.max_sdu);
        DPRINTK("  RX: %d, PCR %d..%d, SDU %d\n",vcc->qos.rxtp.traffic_class,
            vcc->qos.rxtp.min_pcr,vcc->qos.rxtp.max_pcr,vcc->qos.rxtp.max_sdu);
-       if (!try_module_get(dev->ops->owner)) {
-               error = -ENODEV;
-               goto fail;
-       }
 
        if (dev->ops->open) {
-               if ((error = dev->ops->open(vcc,vpi,vci)))
-                       goto put_module_fail;
+               if ((error = dev->ops->open(vcc)))
+                       goto fail;
        }
        return 0;
 
-put_module_fail:
-       module_put(dev->ops->owner);
 fail:
        vcc_remove_socket(vcc->sk);
+fail_module_put:
+       module_put(dev->ops->owner);
        /* ensure we get dev module ref count correct */
        vcc->dev = NULL;
        return error;