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++){
//
// 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;
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;
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
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");
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) {
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;
/*
* 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;
}
/*
* 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;
}
/*
* 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;
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;
/*
* 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;
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;
/*
* 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;
/*
* 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;
/*
* 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;
}
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;
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;
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;
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 ) {
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);
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;
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;
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;
return -ENOMEM;
}
- dev->n_subdevices = 4;
- if(alloc_subdevices(dev) < 0)
+ if(alloc_subdevices(dev, 4) < 0)
return -ENOMEM;
/* analog input subdevice */
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 */
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 */
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)
}
#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;
}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;
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;
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;
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;
}
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;
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;
printk("malloc ok\n");
#endif
- if(alloc_subdevices(dev)<0)
+ if(alloc_subdevices(dev, 2)<0)
return -ENOMEM;
/*
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
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))
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) {
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;
}
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;
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;
}
// 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;
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++){
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));
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;
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;
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 */
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;
/* 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;
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 */
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)
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 */
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 */
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;
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){
}
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;
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)))
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
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++){
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;
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;
}
-/*
+/*
==============================================================================
*/
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,
}
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;
}
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;
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){
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;
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;
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;
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",
/*
* 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;
}
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;
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;
}
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 */
/*
* 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;
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 */
/* 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;