Changed prototype of alloc_subdevices() so it doesn't require dev->n_subdevices
authorFrank Mori Hess <fmhess@speakeasy.net>
Sat, 15 Feb 2003 18:35:46 +0000 (18:35 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Sat, 15 Feb 2003 18:35:46 +0000 (18:35 +0000)
to be set prior to being called.  Fixed 8255 cleanup in ni_daq_dio24.c.  Comedi
sure has a lot of drivers these days!

65 files changed:
comedi/drivers/8255.c
comedi/drivers/adl_pci9111.c
comedi/drivers/adl_pci9118.c
comedi/drivers/adv_pci1710.c
comedi/drivers/amplc_pc236.c
comedi/drivers/amplc_pc263.c
comedi/drivers/amplc_pci230.c
comedi/drivers/cb_das16_cs.c
comedi/drivers/cb_pcidas.c
comedi/drivers/cb_pcidas64.c
comedi/drivers/cb_pcidda.c
comedi/drivers/cb_pcimdas.c
comedi/drivers/cb_pcimdda.c
comedi/drivers/comedi_parport.c
comedi/drivers/comedi_rt_timer.c
comedi/drivers/comedi_test.c
comedi/drivers/contec_pci_dio.c
comedi/drivers/daqboard2000.c
comedi/drivers/das08.c
comedi/drivers/das16.c
comedi/drivers/das16m1.c
comedi/drivers/das1800.c
comedi/drivers/das6402.c
comedi/drivers/das800.c
comedi/drivers/dt2801.c
comedi/drivers/dt2811.c
comedi/drivers/dt2814.c
comedi/drivers/dt2815.c
comedi/drivers/dt2817.c
comedi/drivers/dt282x.c
comedi/drivers/dt3000.c
comedi/drivers/fl512.c
comedi/drivers/icp_multi.c
comedi/drivers/ii_pci20kc.c
comedi/drivers/ke_counter.c
comedi/drivers/me_daq.c
comedi/drivers/mpc8260cpm.c
comedi/drivers/multiq3.c
comedi/drivers/ni_6527.c
comedi/drivers/ni_670x.c
comedi/drivers/ni_at_a2150.c
comedi/drivers/ni_at_ao.c
comedi/drivers/ni_atmio16d.c
comedi/drivers/ni_daq_dio24.c
comedi/drivers/ni_labpc.c
comedi/drivers/ni_mio_common.c
comedi/drivers/ni_pcidio.c
comedi/drivers/pcl711.c
comedi/drivers/pcl724.c
comedi/drivers/pcl725.c
comedi/drivers/pcl726.c
comedi/drivers/pcl812.c
comedi/drivers/pcl816.c
comedi/drivers/pcl818.c
comedi/drivers/pcm3730.c
comedi/drivers/pcmad.c
comedi/drivers/poc.c
comedi/drivers/quatech_daqp_cs.c
comedi/drivers/rtd520.c
comedi/drivers/rti800.c
comedi/drivers/rti802.c
comedi/drivers/serial2002.c
comedi/drivers/skel.c
comedi/drivers/ssv_dnp.c
include/linux/comedidev.h

index 6794100651f048ee148c2569d81ced9842b152d8..4d7354c047b30d10c11cacaea4c08484d214124c 100644 (file)
@@ -373,9 +373,8 @@ static int dev_8255_attach(comedi_device *dev,comedi_devconfig *it)
                printk(" no devices specified\n");
                return -EINVAL;
        }
-       dev->n_subdevices=i;
 
-       if((ret=alloc_subdevices(dev))<0)
+       if((ret=alloc_subdevices(dev, i))<0)
                return ret;
 
        for(i=0;i<dev->n_subdevices;i++){
index 12f9e1c28705e31001098c8932e06dde3a744ae6..31da8561f1256b2574d87e13523ab76fa42929c9 100644 (file)
@@ -1341,9 +1341,8 @@ found:
 //
 // TODO: Add external multiplexer setup (according to option[2]).
 //
-  
-  dev->n_subdevices = 4;
-  if((error=alloc_subdevices(dev))<0)
+
+  if((error=alloc_subdevices(dev, 4))<0)
     return  error;
   
   subdevice                    = dev->subdevices + 0;
index 046e3997702419ab3a15e3af885aee1b1686012b..f8d8cad47d02d33e700c0adcdac0ff34fd237a96 100644 (file)
@@ -2088,8 +2088,7 @@ static int pci9118_attach(comedi_device *dev,comedi_devconfig *it)
        pci_read_config_word(devpriv->pcidev, PCI_COMMAND, &u16w);
        pci_write_config_word(devpriv->pcidev, PCI_COMMAND, u16w|64);  // Enable parity check for parity error
 
-        dev->n_subdevices = 4;
-        if((ret=alloc_subdevices(dev))<0)
+        if((ret=alloc_subdevices(dev, 4))<0)
                return ret;
 
        s = dev->subdevices + 0;
index 45c64bdcbc7aad3cba2c29c84f4ffba5acdf26b4..7419058a309ff56a7174c23a63072bddb0b833d6 100644 (file)
@@ -1117,12 +1117,12 @@ static int pci1710_reset(comedi_device *dev)
 static int pci1710_attach(comedi_device *dev,comedi_devconfig *it)
 {
        comedi_subdevice *s;
-       int ret,subdev;
+       int ret,subdev,n_subdevices;
        unsigned short io_addr[5],master,irq;
        struct pcilst_struct *card=NULL;
         unsigned int iobase;
        unsigned char pci_bus,pci_slot,pci_func;
-       
+
        if (!pci_list_builded) {
                pci_card_list_init(PCI_VENDOR_ID_ADVANTECH,
 #ifdef PCI171X_EXTDEBUG
@@ -1137,20 +1137,20 @@ static int pci1710_attach(comedi_device *dev,comedi_devconfig *it)
        rt_printk("comedi%d: adv_pci1710: board=%s",dev->minor,this_board->name);
 
        /* this call pci_enable_device() */
-       if ((card=select_and_alloc_pci_card(PCI_VENDOR_ID_ADVANTECH, this_board->device_id, it->options[0], it->options[1], 0))==NULL) 
+       if ((card=select_and_alloc_pci_card(PCI_VENDOR_ID_ADVANTECH, this_board->device_id, it->options[0], it->options[1], 0))==NULL)
                return -EIO;
-       
+
        if ((pci_card_data(card,&pci_bus,&pci_slot,&pci_func,
                            &io_addr[0],&irq,&master))<0) {
                pci_card_free(card);
                rt_printk(" - Can't get configuration data!\n");
                return -EIO;
        }
-       
+
        iobase=io_addr[2];
-               
+
        rt_printk(", b:s:f=%d:%d:%d, io=0x%4x",pci_bus,pci_slot,pci_func,iobase);
-       
+
         if (check_region(iobase, this_board->iorange) < 0) {
                pci_card_free(card);
                rt_printk("I/O port conflict\n");
@@ -1159,7 +1159,7 @@ static int pci1710_attach(comedi_device *dev,comedi_devconfig *it)
 
         request_region(iobase, this_board->iorange, "Advantech PCI-1710");
         dev->iobase=iobase;
-    
+
        dev->board_name = this_board->name;
 
        if((ret=alloc_private(dev,sizeof(pci1710_private)))<0) {
@@ -1167,14 +1167,14 @@ static int pci1710_attach(comedi_device *dev,comedi_devconfig *it)
                pci_card_free(card);
                return -ENOMEM;
        }
-               
-        dev->n_subdevices = 0;
-       if (this_board->n_aichan) dev->n_subdevices++;
-       if (this_board->n_aochan) dev->n_subdevices++;
-       if (this_board->n_dichan) dev->n_subdevices++;
-       if (this_board->n_dochan) dev->n_subdevices++;
-       
-        if((ret=alloc_subdevices(dev))<0) {
+
+        n_subdevices = 0;
+       if (this_board->n_aichan) n_subdevices++;
+       if (this_board->n_aochan) n_subdevices++;
+       if (this_board->n_dichan) n_subdevices++;
+       if (this_board->n_dochan) n_subdevices++;
+
+        if((ret=alloc_subdevices(dev, n_subdevices))<0) {
                release_region(dev->iobase, this_board->iorange);
                pci_card_free(card);
                return ret;
index 4277ce2a3e4489545cdd33e57cc7036f39eec3dc..6706e712ffb03a72a7b7eadc98cb986279c462c9 100644 (file)
@@ -274,11 +274,9 @@ static int pc236_attach(comedi_device *dev,comedi_devconfig *it)
 
 /*
  * Allocate the subdevice structures.  alloc_subdevice() is a
- * convenient macro defined in comedidev.h.  It relies on
- * n_subdevices being set correctly.
+ * convenient macro defined in comedidev.h.
  */
-       dev->n_subdevices = 2;
-       if ((ret=alloc_subdevices(dev)) < 0) {
+       if ((ret=alloc_subdevices(dev, 2)) < 0) {
                printk("out of memory!\n");
                return ret;
        }
index cfe46a7b0d0a41d459d99ae15af15bc839df52dc..d83cf77c05b29b1e353df5f39016fb79db3f55f9 100644 (file)
@@ -236,11 +236,9 @@ static int pc263_attach(comedi_device *dev,comedi_devconfig *it)
 
 /*
  * Allocate the subdevice structures.  alloc_subdevice() is a
- * convenient macro defined in comedidev.h.  It relies on
- * n_subdevices being set correctly.
+ * convenient macro defined in comedidev.h.
  */
-       dev->n_subdevices = 1;
-       if ((ret=alloc_subdevices(dev)) < 0) {
+       if ((ret=alloc_subdevices(dev, 1)) < 0) {
                printk("out of memory!\n");
                return -ENOMEM;
        }
index f3ba44a4c8655b0a0c12001227a461d51af554cf..013e11af44b723a117c572b66ad2fbf79db03e86 100644 (file)
@@ -370,11 +370,9 @@ static int pci230_attach(comedi_device *dev,comedi_devconfig *it)
 
 /*
  * Allocate the subdevice structures.  alloc_subdevice() is a
- * convenient macro defined in comedidev.h.  It relies on
- * n_subdevices being set correctly.
+ * convenient macro defined in comedidev.h.
  */
-       dev->n_subdevices=4;
-       if(alloc_subdevices(dev)<0)
+       if(alloc_subdevices(dev, 4)<0)
                return -ENOMEM;
 
        s=dev->subdevices+0;
index 8a974dca912ca3bc91de6be599f7ebe9e93d9f03..371efab54c85446b98cdf87f48b129275d94a955 100644 (file)
@@ -198,8 +198,7 @@ static int das16cs_attach(comedi_device *dev,comedi_devconfig *it)
        if(alloc_private(dev,sizeof(das16cs_private))<0)
                return -ENOMEM;
 
-       dev->n_subdevices=4;
-       if(alloc_subdevices(dev)<0)
+       if(alloc_subdevices(dev, 4)<0)
                return -ENOMEM;
 
        s=dev->subdevices+0;
index 508eb37439649f099949f5eeecad657745c7cbc3..75ed737d792e8ad083d8da1cec04f4053f3b6087 100644 (file)
@@ -637,8 +637,7 @@ found:
 /*
  * Allocate the subdevice structures.
  */
-       dev->n_subdevices = 7;
-       if(alloc_subdevices(dev) < 0)
+       if(alloc_subdevices(dev, 7) < 0)
                return -ENOMEM;
 
        s = dev->subdevices + 0;
index cb8442366523956d506bae8823e8cb102fa63476..71236f2a1be30901c188d851ec604309cc1a0bc4 100644 (file)
@@ -1009,8 +1009,7 @@ static int setup_subdevices(comedi_device *dev)
        comedi_subdevice *s;
        unsigned long dio_8255_iobase;
 
-       dev->n_subdevices = 10;
-       if(alloc_subdevices(dev)<0)
+       if( alloc_subdevices( dev, 10 ) < 0 )
                return -ENOMEM;
 
        s = dev->subdevices + 0;
index e1cd33885444195c2bbcdbe8be7e521d10802ef3..9b5f9047afc003184cda611965f9e7601548ecbf 100644 (file)
@@ -364,8 +364,7 @@ found:
 /*
  * Allocate the subdevice structures.
  */
-       dev->n_subdevices = 3;
-       if(alloc_subdevices(dev) < 0)
+       if(alloc_subdevices( dev, 3 ) < 0)
                return -ENOMEM;
 
        s = dev->subdevices + 0;
index cc6ef29daeec3edf47ff4e5fef29762a01d61ac1..4bbe8bae121b5b4caccb2eecadc50f5ddc843ab2 100644 (file)
@@ -348,11 +348,9 @@ found:
 
 /*
  * Allocate the subdevice structures.  alloc_subdevice() is a
- * convenient macro defined in comedidev.h.  It relies on
- * n_subdevices being set correctly.
+ * convenient macro defined in comedidev.h.
  */
-       dev->n_subdevices=3;
-       if(alloc_subdevices(dev)<0) 
+       if(alloc_subdevices(dev, 3)<0)
                return -ENOMEM;
 
        s=dev->subdevices+0;
index f80ff2d31cb44186f3d7dd8c8183c96c3496e7c2..54a7dc52158cf74fbcf3c26d996bea70be774d18 100644 (file)
@@ -272,11 +272,9 @@ static int attach(comedi_device *dev,comedi_devconfig *it)
 
 /*
  * Allocate the subdevice structures.  alloc_subdevice() is a
- * convenient macro defined in comedidev.h.  It relies on
- * n_subdevices being set correctly.
+ * convenient macro defined in comedidev.h.
  */
-       dev->n_subdevices=2;
-       if(alloc_subdevices(dev)<0)
+       if(alloc_subdevices(dev, 2)<0)
                return -ENOMEM;
 
        s = dev->subdevices+0;
index 8f9635140f81f197d70a7d0067f6ebb306d56d97..b8defbc9ad30240af16121064eff05c848823b8b 100644 (file)
@@ -309,8 +309,7 @@ static int parport_attach(comedi_device *dev,comedi_devconfig *it)
        }
        dev->board_name="parport";
 
-       dev->n_subdevices=4;
-       if((ret=alloc_subdevices(dev))<0)
+       if((ret=alloc_subdevices(dev, 4))<0)
                return ret;
        if((ret=alloc_private(dev,sizeof(parport_private)))<0)
                return ret;
index 18acbdac48de659d405ce3d12d8555cf21c5e4b5..25eae43aeee1f239663ae3a1881b435e038bc192 100644 (file)
@@ -604,8 +604,7 @@ static int timer_attach(comedi_device *dev,comedi_devconfig *it)
 
        dev->board_name="timer";
 
-       dev->n_subdevices=1;
-       if((ret=alloc_subdevices(dev))<0)
+       if((ret=alloc_subdevices(dev, 1))<0)
                return ret;
        if((ret=alloc_private(dev,sizeof(timer_private)))<0)
                return ret;
index cc5949e1d6fd058ff1899568d24106ecdf750379..4eadb2fdbbf672dbf99d640c69c660f6a9076530 100644 (file)
@@ -198,8 +198,7 @@ static int waveform_attach(comedi_device *dev,comedi_devconfig *it)
        devpriv->usec_period = period;
 
        printk("%i microvolt, %li microsecond waveform ", devpriv->uvolt_amplitude, devpriv->usec_period);
-       dev->n_subdevices = 1;
-       if(alloc_subdevices(dev) < 0) return -ENOMEM;
+       if(alloc_subdevices(dev, 1) < 0) return -ENOMEM;
 
        s = dev->subdevices + 0;
        dev->read_subdev = s;
index 85362c880440d0d752c97bf5b4ff9b89f976d69e..4e6c8bc0a76ca09c55b6e236b8e7e785e67b7e8e 100644 (file)
@@ -104,8 +104,7 @@ static int contec_attach(comedi_device *dev,comedi_devconfig *it)
        if(alloc_private(dev,sizeof(contec_private))<0)
                return -ENOMEM;
 
-       dev->n_subdevices=2;
-       if(alloc_subdevices(dev)<0)
+       if(alloc_subdevices(dev, 2)<0)
                return -ENOMEM;
 
        pci_for_each_dev ( pcidev ) {
index bb44820495fb7892c47060a3d89585acdb1c95ea..133b8bb533cb68b6740a5e63b86b76b0b11b34e6 100644 (file)
@@ -726,8 +726,7 @@ static int daqboard2000_attach(comedi_device *dev, comedi_devconfig *it)
   result = alloc_private(dev,sizeof(daqboard2000_private));
   if(result<0)goto out;
 
-  dev->n_subdevices = 3;
-  result = alloc_subdevices(dev);
+  result = alloc_subdevices(dev, 3);
   if(result<0)goto out;
   
   devpriv->plx = ioremap(pci_resource_start(card,0), DAQBOARD2000_PLX_SIZE);
index b0f442d43940b439d744dea3bcdfae5a6c25525f..6bc999dc8763e63dd6e44dbb7087c4f583829ed2 100644 (file)
@@ -818,8 +818,7 @@ static int das08_attach(comedi_device *dev,comedi_devconfig *it)
 
        dev->board_name = thisboard->name;
 
-       dev->n_subdevices=5;
-       if((ret=alloc_subdevices(dev))<0)
+       if((ret=alloc_subdevices(dev, 5))<0)
                return ret;
 
        s=dev->subdevices+0;
index 1e753f6c2b89dd80d7de9f22993a15bf136f88c1..f48d570d0ac20372d100b96ca01f36f3dc1debe6 100644 (file)
@@ -1500,8 +1500,7 @@ static int das16_attach(comedi_device *dev, comedi_devconfig *it)
                devpriv->timer_mode = timer_mode ? 1 : 0;
        }
 
-       dev->n_subdevices = 5;
-       if((ret=alloc_subdevices(dev))<0)
+       if((ret=alloc_subdevices(dev, 5))<0)
                return ret;
 
        s=dev->subdevices+0;
index c6fb4ce936d33d3a895ff2591e196aec9f2ea482..9e6a3a6e8f7adc9a61d9c5b18e55450444c247c2 100644 (file)
@@ -681,8 +681,7 @@ static int das16m1_attach(comedi_device *dev, comedi_devconfig *it)
                return -EINVAL;
        }
 
-       dev->n_subdevices = 4;
-       if((ret = alloc_subdevices(dev)) < 0)
+       if((ret = alloc_subdevices(dev, 4)) < 0)
                return ret;
 
        s = dev->subdevices + 0;
index ca082d7cac6ab0e706ae80add254806366b0592e..b575c853df153e69861adc19e8ab2df76a3cc096 100644 (file)
@@ -700,8 +700,7 @@ static int das1800_attach(comedi_device *dev, comedi_devconfig *it)
                        return -ENOMEM;
        }
 
-       dev->n_subdevices = 4;
-       if(alloc_subdevices(dev) < 0)
+       if(alloc_subdevices(dev, 4) < 0)
                return -ENOMEM;
 
        /* analog input subdevice */
index 90a2054923edb877fbddaa06c87b0631b2f09077..a66d7591b93e5b3aeca3ba074aea0ae05374b092 100644 (file)
@@ -331,8 +331,7 @@ static int das6402_attach(comedi_device *dev,comedi_devconfig *it)
        if((ret=alloc_private(dev,sizeof(das6402_private)))<0)
                return ret;
 
-       dev->n_subdevices=1;
-       if((ret=alloc_subdevices(dev))<0)
+       if((ret=alloc_subdevices(dev, 1))<0)
                return ret;
 
        /* ai subdevice */
index d94c9458c99695e66d398c2f45a2ee1de0c143a4..9e9e6ddd35d1b01677f0b28e7c7571f92f1aeb37 100644 (file)
@@ -510,8 +510,7 @@ static int das800_attach(comedi_device *dev, comedi_devconfig *it)
 
        dev->board_name = thisboard->name;
 
-       dev->n_subdevices = 3;
-       if(alloc_subdevices(dev) < 0)
+       if(alloc_subdevices(dev, 3) < 0)
                return -ENOMEM;
 
        /* analog input subdevice */
index 9cef9222aef535aec15b4e2895cfcedfd40433d0..5e517baf599373fef327fda49223d3f9a6865b15 100644 (file)
@@ -520,9 +520,7 @@ havetype:
        n_ai_chans=probe_number_of_ai_chans(dev);
        printk(" (ai channels = %d)",n_ai_chans);
 
-       dev->n_subdevices=4;
-
-       if((ret=alloc_subdevices(dev))<0)
+       if((ret=alloc_subdevices(dev, 4))<0)
                goto out;
 
        if((ret=alloc_private(dev,sizeof(dt2801_private)))<0)
index 9fbd65c8a90b29dd107e4b71d2d88854e903b3a4..0c6d948faf072d8db3f36a007d10c2d82cc17135 100644 (file)
@@ -359,8 +359,7 @@ static int dt2811_attach(comedi_device * dev, comedi_devconfig * it)
        }
 #endif
 
-       dev->n_subdevices = 4;
-       if ((ret = alloc_subdevices(dev)) < 0)
+       if ((ret = alloc_subdevices(dev, 4)) < 0)
                return ret;
        if ((ret = alloc_private(dev, sizeof(dt2811_private))) < 0)
                return ret;
index c9bc55d4da0b02dbbac08145224e23200df9432b..0b6ff7aacbabc4e81c4722ff19997d802730693c 100644 (file)
@@ -289,9 +289,8 @@ static int dt2814_attach(comedi_device *dev,comedi_devconfig *it)
        }else{
                printk("(probe returned multiple irqs--bad)\n");
        }
-       
-       dev->n_subdevices=1;
-       if((ret=alloc_subdevices(dev))<0)
+
+       if((ret=alloc_subdevices(dev, 1))<0)
                return ret;
        if((ret=alloc_private(dev,sizeof(dt2814_private)))<0)
                return ret;
index c02ae551cc3d36c346679f8c66fb00324488480d..254790fd2f984f96e83d03528742e0bc65b70262 100644 (file)
@@ -191,8 +191,7 @@ static int dt2815_attach(comedi_device * dev, comedi_devconfig * it)
   dev->iobase = iobase;
   dev->board_name = "dt2815";
 
-  dev->n_subdevices = 1;
-  if(alloc_subdevices(dev)<0)
+  if(alloc_subdevices(dev, 1)<0)
     return -ENOMEM;
   if(alloc_private(dev,sizeof(dt2815_private))<0)
     return -ENOMEM;
index a0a95613d0a828ef28194798df38329cd872cad9..35421f989e15b84266ff2b407c1112bbeb893200 100644 (file)
@@ -139,8 +139,7 @@ static int dt2817_attach(comedi_device *dev,comedi_devconfig *it)
        dev->iobase = iobase;
        dev->board_name="dt2817";
 
-       dev->n_subdevices=1;
-       if((ret=alloc_subdevices(dev))<0)
+       if((ret=alloc_subdevices(dev, 1))<0)
                return ret;
 
        s=dev->subdevices+0;
index 5025933e12f6e4d06ee21f68af56f923dfb16b89..cf538324f3e362dbb0cf8381ab36f2cf5292283d 100644 (file)
@@ -1250,8 +1250,7 @@ static int dt282x_attach(comedi_device * dev, comedi_devconfig * it)
        if(ret<0)
                return ret;
 
-       dev->n_subdevices = 3;
-       if((ret=alloc_subdevices(dev))<0)
+       if((ret=alloc_subdevices(dev, 3))<0)
                return ret;
 
        s=dev->subdevices+0;
index 8da75e07e73f29f2e09178566c43f1aaef47eba3..04fb37997c16a9e6921727e3d9c604ca66f19e3f 100644 (file)
@@ -781,8 +781,7 @@ static int dt3000_attach(comedi_device *dev,comedi_devconfig *it)
        }
        dev->irq = devpriv->pci_dev->irq;
 
-       dev->n_subdevices = 4;
-       if( (ret = alloc_subdevices(dev)) <0)
+       if( (ret = alloc_subdevices(dev, 4)) <0)
                return ret;
 
        s=dev->subdevices;
index aa7a474857fed6de95f7cdf3a11496ba7b8b12b4..136c8230ef081ee53fc0458b9e30cbc609916a65 100644 (file)
@@ -148,7 +148,6 @@ static int fl512_attach(comedi_device *dev,comedi_devconfig *it)
   request_region(iobase, FL512_SIZE, "fl512");
   dev->iobase = iobase;
   dev->board_name = "fl512";
-  dev->n_subdevices = 2;      /* Analog in/out */
   if(alloc_private(dev,sizeof(fl512_private)) < 0)
     return -ENOMEM;
 
@@ -156,7 +155,7 @@ static int fl512_attach(comedi_device *dev,comedi_devconfig *it)
   printk("malloc ok\n");
 #endif
 
-  if(alloc_subdevices(dev)<0)
+  if(alloc_subdevices(dev, 2)<0)
     return -ENOMEM;
 
   /*
index a0ad8ddee2b33ae06b4acecc90c24e856d46c59d..482b1f2c2baa222ae4552049d3ea4579c3c9af91 100644 (file)
@@ -844,12 +844,12 @@ static int icp_multi_reset(comedi_device *dev)
 static int icp_multi_attach(comedi_device *dev,comedi_devconfig *it)
 {
        comedi_subdevice        *s;
-       int ret,                subdev;
+       int ret, subdev, n_subdevices;
        unsigned short          master,irq;
        struct pcilst_struct    *card=NULL;
         unsigned long          io_addr[5], iobase;
        unsigned char           pci_bus, pci_slot, pci_func;
-       
+
        printk("icp_multi EDBG: BGN: icp_multi_attach(...)\n");
 
        // Alocate private data storage space
@@ -872,13 +872,13 @@ static int icp_multi_attach(comedi_device *dev,comedi_devconfig *it)
 
        if ((card=select_and_alloc_pci_card(PCI_VENDOR_ID_ICP, this_board->device_id, it->options[0], it->options[1]))==NULL)
                return -EIO;
-       
+
        if ((pci_card_data(card, &pci_bus, &pci_slot, &pci_func, &io_addr[0], &irq, &master))<0) {
                pci_card_free(card);
                printk(" - Can't get configuration data!\n");
                return -EIO;
        }
-       
+
        iobase=io_addr[2];
 
 //     if(check_mem_region(iobase, ICP_MULTI_SIZE))
@@ -891,7 +891,7 @@ static int icp_multi_attach(comedi_device *dev,comedi_devconfig *it)
        devpriv->phys_iobase = iobase;
 
        printk(", b:s:f=%d:%d:%d, io=0x%8lx \n", pci_bus, pci_slot, pci_func, iobase);
-       
+
        devpriv->io_addr = ioremap(iobase, ICP_MULTI_SIZE);
 
        if (devpriv->io_addr == NULL) {
@@ -907,14 +907,14 @@ static int icp_multi_attach(comedi_device *dev,comedi_devconfig *it)
 
        dev->board_name = this_board->name;
 
-        dev->n_subdevices = 0;
-       if (this_board->n_aichan) dev->n_subdevices++;
-       if (this_board->n_aochan) dev->n_subdevices++;
-       if (this_board->n_dichan) dev->n_subdevices++;
-       if (this_board->n_dochan) dev->n_subdevices++;
-       if (this_board->n_ctrs)   dev->n_subdevices++;
-       
-        if((ret=alloc_subdevices(dev))<0) {
+        n_subdevices = 0;
+       if (this_board->n_aichan) n_subdevices++;
+       if (this_board->n_aochan) n_subdevices++;
+       if (this_board->n_dichan) n_subdevices++;
+       if (this_board->n_dochan) n_subdevices++;
+       if (this_board->n_ctrs)   n_subdevices++;
+
+        if((ret=alloc_subdevices(dev, n_subdevices))<0) {
                pci_card_free(card);
                return ret;
        }
index a5bb10de596f12a88930d6f12cf9f9f98902af08..63adcbe9aca3efc573e011501f7242afc406f65c 100644 (file)
@@ -209,8 +209,7 @@ static int pci20xxx_attach(comedi_device * dev, comedi_devconfig * it)
        comedi_subdevice *s;
        pci20xxx_subdev_private *sdp;
 
-       dev->n_subdevices = 1+PCI20000_MODULES;
-       if ((ret = alloc_subdevices(dev)) < 0)
+       if ((ret = alloc_subdevices(dev, 1 + PCI20000_MODULES)) < 0)
                return ret;
        if ((ret = alloc_private(dev, sizeof(pci20xxx_private))) < 0)
                return ret;
index 9d6c46cf16e7d3ef604cbc3e9702c31eb923ea5a..8aea37eed6b03e3963317e0e14bd064bc0aa0fca 100644 (file)
@@ -181,8 +181,7 @@ found:
   dev->iobase = io_base & PCI_BASE_ADDRESS_IO_MASK;
 
   /* allocate the subdevice structures */
-  dev->n_subdevices = 1;
-  if((error = alloc_subdevices(dev)) < 0)
+  if((error = alloc_subdevices(dev, 1)) < 0)
   {
     return error;
   }
index d9c1a72e205cee8e38208731e52e84c680e3fda5..4264d0c2a2633b91443f44cd8784ac637f74caa1 100644 (file)
@@ -818,8 +818,7 @@ found:
 
   // device driver capabilities
 
-  dev->n_subdevices = 3;
-  if((error = alloc_subdevices(dev)) < 0)
+  if((error = alloc_subdevices(dev, 3)) < 0)
     return error;
 
   subdevice = dev->subdevices + 0;
index b88bf56740634ef9c49ae362753a19cd3d1e6f51..2470295ac345a31dea19bac1407e0e1a5ee71014 100644 (file)
@@ -72,8 +72,7 @@ static int mpc8260cpm_attach(comedi_device *dev,comedi_devconfig *it)
        if(alloc_private(dev,sizeof(mpc8260cpm_private))<0)
                return -ENOMEM;
 
-       dev->n_subdevices=4;
-       if(alloc_subdevices(dev)<0)
+       if(alloc_subdevices(dev,4)<0)
                return -ENOMEM;
 
        for(i=0;i<4;i++){
index 79925ffd1e7e462ed1334e0a7541fca212f30d7b..bceab4f29ac23aff14d669787a9d1cd5ff60a78f 100644 (file)
@@ -250,8 +250,7 @@ static int multiq3_attach(comedi_device * dev, comedi_devconfig * it)
        printk("comedi%d: no irq\n", dev->minor);
       }
       dev->board_name = "multiq3";
-      dev->n_subdevices = 5;
-      result = alloc_subdevices(dev);
+      result = alloc_subdevices(dev, 5);
       if(result<0)return result;
 
       result = alloc_private(dev,sizeof(struct multiq3_private));
index 76649d14d30aaeb42231b8098cb57338a0c5f319..107662715d650e9996825d12afc69b97ed290cc8 100644 (file)
@@ -354,8 +354,7 @@ static int ni6527_attach(comedi_device *dev,comedi_devconfig *it)
 
        printk(" ID=0x%02x", readb(dev->iobase + ID_Register));
 
-       dev->n_subdevices=2;
-       if((ret=alloc_subdevices(dev))<0)
+       if((ret=alloc_subdevices(dev,2))<0)
                return ret;
 
        s=dev->subdevices+0;
index 7ee82813e9a9aef5de99eabb3e306f70a6d9aa61..169dc318fa69ab6f438522e0c277d62823e0c2eb 100644 (file)
@@ -157,9 +157,7 @@ static int ni_670x_attach(comedi_device *dev,comedi_devconfig *it)
        dev->irq=mite_irq(devpriv->mite);
        printk(" %s",dev->board_name);
 
-       dev->n_subdevices=2;
-       
-       if(alloc_subdevices(dev)<0)
+       if(alloc_subdevices(dev, 2)<0)
                return -ENOMEM;
 
        s=dev->subdevices+0;
index d97fd126a28128c905a36fd5a03eaa87a4ba2238..296b1c00b226873584f60bd0bb235387f4dde9b4 100644 (file)
@@ -418,8 +418,7 @@ static int a2150_attach(comedi_device *dev, comedi_devconfig *it)
        dev->board_ptr = a2150_boards + a2150_probe(dev);
        dev->board_name = thisboard->name;
 
-       dev->n_subdevices = 1;
-       if(alloc_subdevices(dev) < 0)
+       if(alloc_subdevices(dev, 1) < 0)
                return -ENOMEM;
 
        /* analog input subdevice */
index 711898c0e943e952425690e9aa9819a07a0efb4a..c8656f4e8c84f62538221141238ba5dbfa5d5ec4 100644 (file)
@@ -224,8 +224,7 @@ static int atao_attach(comedi_device *dev,comedi_devconfig *it)
        if(alloc_private(dev,sizeof(atao_private))<0)
                return -ENOMEM;
 
-       dev->n_subdevices=4;
-       if(alloc_subdevices(dev)<0)
+       if(alloc_subdevices(dev, 4)<0)
                return -ENOMEM;
 
        s=dev->subdevices+0;
index 68df12d072dbdf07adfbec0983f67e05cab12f95..6723ff63f42284b9a2769de2aceb924e2216610d 100644 (file)
@@ -716,10 +716,7 @@ static int atmio16d_attach(comedi_device * dev, comedi_devconfig * it)
        /* board name */
        dev->board_name = boardtype->name;
 
-       /* set number of subdevices */
-       dev->n_subdevices=4;
-
-       if((ret=alloc_subdevices(dev))<0)
+       if((ret=alloc_subdevices(dev, 4))<0)
                return ret;
        if((ret=alloc_private(dev,sizeof(atmio16d_private)))<0)
                return ret;
index ae8d8b9e6487a6bd1bbaae1d7da1a8e8d14de024..cc6d02205204ab874b72ac6d9a4b979a4503233d 100644 (file)
@@ -166,8 +166,7 @@ static int dio24_attach(comedi_device *dev, comedi_devconfig *it)
 
        dev->board_name = thisboard->name;
 
-       dev->n_subdevices = 2;  // Antes era 5
-       if(alloc_subdevices(dev) < 0)
+       if(alloc_subdevices(dev, 1) < 0)
                return -ENOMEM;
 
        /* 8255 dio */
@@ -182,7 +181,7 @@ static int dio24_detach(comedi_device *dev)
        printk("comedi%d: ni_daq_dio24: remove\n", dev->minor);
 
        if(dev->subdevices)
-               subdev_8255_cleanup(dev,dev->subdevices + 2);
+               subdev_8255_cleanup(dev,dev->subdevices + 0);
 
        if(thisboard->bustype != pcmcia_bustype &&
                dev->iobase)
index 873c99edb751d3382fbdd08eea172403b4416d1c..10037fbdd34a9eb31c46d0646a502353efb7b797 100644 (file)
@@ -663,8 +663,7 @@ static int labpc_attach(comedi_device *dev, comedi_devconfig *it)
 
        dev->board_name = thisboard->name;
 
-       dev->n_subdevices = 5;
-       if(alloc_subdevices(dev) < 0)
+       if(alloc_subdevices(dev, 5) < 0)
                return -ENOMEM;
 
        /* analog input subdevice */
index 8b597a1fc24d64c229ce731fec92ba506547c578..3be67445b2ed3cea4a20f910dda54c29c4b7d03c 100644 (file)
@@ -2367,9 +2367,7 @@ static int ni_E_init(comedi_device *dev,comedi_devconfig *it)
        comedi_subdevice *s;
        int bits;
 
-       dev->n_subdevices=8;
-
-       if(alloc_subdevices(dev)<0)
+       if(alloc_subdevices(dev, 8)<0)
                return -ENOMEM;
 
        /* analog input subdevice */
index 5ed0d3a88c01a4cb51bb22495018206f403dbcf6..582c8466494f9da92fc532ee1cf04ace644e020e 100644 (file)
@@ -923,12 +923,13 @@ static int nidio_attach(comedi_device *dev,comedi_devconfig *it)
        comedi_subdevice *s;
        int i;
        int ret;
-       
+       int n_subdevices;
+
        printk("comedi%d: nidio:",dev->minor);
 
        if((ret=alloc_private(dev,sizeof(nidio96_private)))<0)
                return ret;
-       
+
        ret=nidio_find_device(dev,it->options[0],it->options[1]);
        if(ret<0)return ret;
 
@@ -945,11 +946,11 @@ static int nidio_attach(comedi_device *dev,comedi_devconfig *it)
        printk(" %s",dev->board_name);
 
        if(!this_board->is_diodaq){
-               dev->n_subdevices=this_board->n_8255;
+               n_subdevices=this_board->n_8255;
        }else{
-               dev->n_subdevices=1;
+               n_subdevices=1;
        }
-       if((ret=alloc_subdevices(dev))<0)
+       if((ret=alloc_subdevices(dev, n_subdevices))<0)
                return ret;
 
        if(!this_board->is_diodaq){
index baca557f96cdb68d640ea0febffc7a10b32dc35f..41943c9d9049df7abff2b1761f301e3974639d4e 100644 (file)
@@ -526,8 +526,7 @@ static int pcl711_attach(comedi_device * dev, comedi_devconfig * it)
        }
        dev->irq = irq;
 
-       dev->n_subdevices = 4;
-       if((ret=alloc_subdevices(dev))<0)
+       if((ret=alloc_subdevices(dev, 4))<0)
                return ret;
        if((ret=alloc_private(dev,sizeof(pcl711_private)))<0)
                return ret;
index b28bc1ee7bff590cf6513c50dc592b515fd73841..c77866590db39216bd4f085bd8e5f2203e5f1286 100644 (file)
@@ -125,8 +125,8 @@ static int subdev_8255mapped_cb(int dir,int port,int data,unsigned long iobase)
 static int pcl724_attach(comedi_device *dev,comedi_devconfig *it)
 {
         int iobase,iorange;
-       int ret,i;
-       
+       int ret,i,n_subdevices;
+
         iobase=it->options[0];
         iorange=this_board->io_range;
        if ((this_board->can_have96)&&((it->options[1]==1)||(it->options[1]==96)))
@@ -137,10 +137,10 @@ static int pcl724_attach(comedi_device *dev,comedi_devconfig *it)
                printk("I/O port conflict\n");
                return -EIO;
        }
-       
+
         request_region(iobase, iorange, "pcl724");
         dev->iobase=iobase;
-    
+
        dev->board_name = this_board->name;
 
 #ifdef PCL724_IRQ
@@ -151,27 +151,27 @@ static int pcl724_attach(comedi_device *dev,comedi_devconfig *it)
                        if (((1<<irq)&this_board->IRQbits)==0) {
                                rt_printk(", IRQ %d is out of allowed range, DISABLING IT",irq);
                                irq=0; /* Bad IRQ */
-                       } else { 
+                       } else {
                                if (comedi_request_irq(irq, interrupt_pcl724, 0, "pcl724", dev)) {
                                        rt_printk(", unable to allocate IRQ %d, DISABLING IT", irq);
                                        irq=0; /* Can't use IRQ */
                                } else {
                                        rt_printk(", irq=%d", irq);
-                               }    
-                       }  
+                               }
+                       }
                }
        }
 
         dev->irq = irq;
 #endif
-       
+
        printk("\n");
 
-       dev->n_subdevices=this_board->numofports;
+       n_subdevices=this_board->numofports;
        if ((this_board->can_have96)&&((it->options[1]==1)||(it->options[1]==96)))
-               dev->n_subdevices=4;    // PCL-724 in 96 DIO configuration
-       
-       if((ret=alloc_subdevices(dev))<0)
+               n_subdevices=4; // PCL-724 in 96 DIO configuration
+
+       if((ret=alloc_subdevices(dev, n_subdevices))<0)
                return ret;
 
        for(i=0;i<dev->n_subdevices;i++){
index 3575aa96b6ae3253e17b94d6a589ddb82854e970..af864e76b23b409c842a1a4be850b69047dacf10 100644 (file)
@@ -73,9 +73,7 @@ static int pcl725_attach(comedi_device *dev,comedi_devconfig *it)
        dev->iobase=iobase;
        dev->irq=0;
 
-       dev->n_subdevices=2;
-
-       if(alloc_subdevices(dev)<0)
+       if(alloc_subdevices(dev, 2)<0)
                return -ENOMEM;
 
        s=dev->subdevices+0;
index 6bb7811ae0adf8aed701b4e9578bf9ed68af501b..1f1bfadccb8e0ea12d5282e1166e1b950732e87b 100644 (file)
@@ -288,9 +288,7 @@ static int pcl726_attach(comedi_device *dev,comedi_devconfig *it)
        
        printk("\n");
 
-       dev->n_subdevices=3;
-       
-       if((ret=alloc_subdevices(dev))<0)
+       if((ret=alloc_subdevices(dev, 3))<0)
                return ret;
 
        s=dev->subdevices+0;
index d6391f17522ce87a899e1194d9bf26c5f6856c5a..570b7c44edc8513b07e304bfda8ee8fd58490c38 100644 (file)
@@ -1165,7 +1165,7 @@ static void pcl812_reset(comedi_device * dev)
 }
 
 
-/* 
+/*
 ==============================================================================
 */
 static int pcl812_attach(comedi_device * dev, comedi_devconfig * it)
@@ -1176,6 +1176,7 @@ static int pcl812_attach(comedi_device * dev, comedi_devconfig * it)
        int dma;
        unsigned long pages;
        comedi_subdevice *s;
+       int n_subdevices;
 
        iobase = it->options[0];
        printk("comedi%d: pcl812:  board=%s, ioport=0x%03x", dev->minor,
@@ -1255,14 +1256,13 @@ static int pcl812_attach(comedi_device * dev, comedi_devconfig * it)
        }
       no_dma:
 
-       dev->n_subdevices=0;
-
-       if (this_board->n_aichan > 0) dev->n_subdevices++;
-       if (this_board->n_aochan > 0) dev->n_subdevices++;
-       if (this_board->n_dichan > 0) dev->n_subdevices++;
-       if (this_board->n_dochan > 0) dev->n_subdevices++;
+       n_subdevices=0;
+       if (this_board->n_aichan > 0) n_subdevices++;
+       if (this_board->n_aochan > 0) n_subdevices++;
+       if (this_board->n_dichan > 0) n_subdevices++;
+       if (this_board->n_dochan > 0) n_subdevices++;
 
-       if ((ret = alloc_subdevices(dev)) < 0) {
+       if ((ret = alloc_subdevices(dev, n_subdevices)) < 0) {
                free_resources(dev);
                return ret;
        }
index 66312c86e5fc49d0137d7985759247e899e6771a..5a7d83f5123f368aae86b4568aec7d5ee516ebc4 100644 (file)
@@ -1152,8 +1152,7 @@ no_dma:
   if (this_board->n_dochan > 0)
     subdevs[3] = COMEDI_SUBD_DO;
 */
-  dev->n_subdevices = 1;
-  if ((ret = alloc_subdevices (dev)) < 0)
+  if ((ret = alloc_subdevices (dev, 1)) < 0)
     return ret;
 
   s = dev->subdevices + 0;
index 8ce26613375aea9374586dbbc794c4cb17d2b81e..298965cd2d10b259fd263dd1a2938c3d06d99d53 100644 (file)
@@ -1490,8 +1490,7 @@ no_rtc:
 
 no_dma:
 
-        dev->n_subdevices = 4;
-        if((ret=alloc_subdevices(dev))<0) return ret;
+        if((ret=alloc_subdevices(dev, 4))<0) return ret;
 
        s = dev->subdevices + 0;
        if(!this_board->n_aichan_se){
index 9a0370501b65bbd3ffacf86754f6af3ab7a6a2f4..bde98e354d1136a20a9e186e137bb426b2bb85e5 100644 (file)
@@ -79,9 +79,7 @@ static int pcm3730_attach(comedi_device *dev,comedi_devconfig *it)
        dev->iobase=dev->iobase;
        dev->irq=0;
 
-       dev->n_subdevices=6;
-
-       if(alloc_subdevices(dev)<0)
+       if(alloc_subdevices(dev, 6)<0)
                return -ENOMEM;
 
        s=dev->subdevices+0;
index 2dfe32428e2f2a72e02f34456446efabe8cfe20e..8b5c99b013e6f82a618563a2405d0dc8b2e5e65d 100644 (file)
@@ -142,8 +142,7 @@ static int pcmad_attach(comedi_device *dev,comedi_devconfig *it)
        request_region(iobase,PCMAD_SIZE,"pcmad");
        dev->iobase=iobase;
 
-       dev->n_subdevices=1;
-       if((ret=alloc_subdevices(dev))<0)
+       if((ret=alloc_subdevices(dev, 1))<0)
                return ret;
        if((ret=alloc_private(dev,sizeof(struct pcmad_priv_struct)))<0)
                return ret;
index 3efd2dc08034376acc845782f6ebadcab9626f8c..3474eeded2f97c058a75e6931a27d957f82398fa 100644 (file)
@@ -137,8 +137,7 @@ static int poc_attach(comedi_device *dev, comedi_devconfig *it)
        request_region(iobase, iosize, "dac02");
        dev->iobase = iobase;
 
-       dev->n_subdevices = 1;
-       if(alloc_subdevices(dev) < 0)
+       if(alloc_subdevices(dev, 1) < 0)
                return -ENOMEM;
        if(alloc_private(dev,sizeof(lsampl_t)*this_board->n_chan) < 0)
                return -ENOMEM;
index 4be6d06bf699936870331123340e644d1b9104f1..b757f94c1519eea46fd401b852c4764b0f497aac 100644 (file)
@@ -384,8 +384,7 @@ static int daqp_attach(comedi_device *dev, comedi_devconfig *it)
                return ret;
        devpriv->devnum = it->options[0];
 
-       dev->n_subdevices=1;
-       if((ret=alloc_subdevices(dev))<0)
+       if((ret=alloc_subdevices(dev, 1))<0)
                return ret;
 
        printk("comedi%d: attaching daqp%d (io 0x%04x)\n",
index 26ff9f3eb22b8d3ce385a18898b905b3aaae0b8f..d91c837085eabc0a09d51aae8ee2dd1c8dfd24b9 100644 (file)
@@ -863,11 +863,9 @@ static int rtd_attach (
 
     /*
      * Allocate the subdevice structures.  alloc_subdevice() is a
-     * convenient macro defined in comedidev.h.  It relies on
-     * n_subdevices being set correctly.
+     * convenient macro defined in comedidev.h.
      */
-    dev->n_subdevices=4;
-    if (alloc_subdevices(dev)<0) {
+    if (alloc_subdevices(dev, 4)<0) {
        return -ENOMEM;
     }
 
index a00bf534fcdf1d15d4c1f7cce29af23cc80b69b7..c102fed86d3bb1c8fff5bec499c3842b92c7dac1 100644 (file)
@@ -328,8 +328,7 @@ static int rti800_attach(comedi_device * dev, comedi_devconfig * it)
 
        dev->board_name = this_board->name;
 
-       dev->n_subdevices=4;
-       if((ret=alloc_subdevices(dev))<0)
+       if((ret=alloc_subdevices(dev, 4))<0)
                return ret;
        if((ret=alloc_private(dev,sizeof(rti800_private)))<0)
                return ret;
index 34fd615caa91868a3c8ae7ae890c4c2b82905346..f5a50573f67d4a215456cb51fcd0ae6e6647bd1f 100644 (file)
@@ -114,8 +114,7 @@ static int rti802_attach(comedi_device * dev, comedi_devconfig * it)
 
        dev->board_name = "rti802";
 
-       dev->n_subdevices = 1;
-       if(alloc_subdevices(dev)<0 || alloc_private(dev,sizeof(rti802_private))){
+       if(alloc_subdevices(dev, 1)<0 || alloc_private(dev,sizeof(rti802_private))){
                return -ENOMEM;
        }
 
index 92aa7d9ca38a64499187ee5a3060d7c6ef21be5c..b6933693b15b314ae00c154a8bf6732cd4070c6a 100644 (file)
@@ -549,8 +549,7 @@ static int serial2002_attach(comedi_device *dev,comedi_devconfig *it)
   devpriv->speed = it->options[1];
   printk("/dev/ttyS%d @ %d\n", devpriv->port, devpriv->speed);
 
-  dev->n_subdevices=4;
-  if(alloc_subdevices(dev)<0)
+  if(alloc_subdevices(dev, 4)<0)
     return -ENOMEM;
   
   /* digital input subdevice */
index 517eb4ca0641fed7655fd500ec2f77d3640c3de4..63141c0a4dbd9a4ae3e1aafa053bd6fa66a571b2 100644 (file)
@@ -226,11 +226,9 @@ static int skel_attach(comedi_device *dev,comedi_devconfig *it)
 
 /*
  * Allocate the subdevice structures.  alloc_subdevice() is a
- * convenient macro defined in comedidev.h.  It relies on
- * n_subdevices being set correctly.
+ * convenient macro defined in comedidev.h.
  */
-       dev->n_subdevices=3;
-       if(alloc_subdevices(dev)<0)
+       if(alloc_subdevices(dev, 3)<0)
                return -ENOMEM;
 
        s=dev->subdevices+0;
index 5a155d49b8607c84c030d797ff3cad8fb4fc6944..f1ee19f3b77cc9c2e206ec507d08aa0c51d045a3 100644 (file)
@@ -146,11 +146,9 @@ static int dnp_attach(comedi_device *dev,comedi_devconfig *it)
   if(alloc_private(dev,sizeof(dnp_private_data))<0) return -ENOMEM;
 
   /* Allocate the subdevice structures. alloc_subdevice() is a convenient    */
-  /* macro defined in comedidev.h. It relies on n_subdevices being set       */
-  /* correctly.                                                              */
+  /* macro defined in comedidev.h.                                           */
 
-  dev->n_subdevices=1;
-  if(alloc_subdevices(dev)<0) return -ENOMEM;
+  if(alloc_subdevices(dev, 1)<0) return -ENOMEM;
 
   s=dev->subdevices+0;
   /* digital i/o subdevice                                                   */
index e0e45289825679699e93886be0d3877cd6770a9c..038d04868373a6c7864f60ec32223835c307a655 100644 (file)
@@ -316,10 +316,11 @@ struct comedi_lrange_struct{
 
 /* some silly little inline functions */
 
-static inline int alloc_subdevices(comedi_device *dev)
+static inline int alloc_subdevices(comedi_device *dev, unsigned int num_subdevices)
 {
-       int size=sizeof(comedi_subdevice)*dev->n_subdevices;
+       int size=sizeof(comedi_subdevice)*num_subdevices;
 
+       dev->n_subdevices = num_subdevices;
        dev->subdevices=kmalloc(size,GFP_KERNEL);
        if(!dev->subdevices)
                return -ENOMEM;