staging: comedi: addi_common.c: remove addi_auto_attach()
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Tue, 14 Oct 2014 17:44:19 +0000 (10:44 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 29 Oct 2014 07:48:53 +0000 (15:48 +0800)
The addi_apci_035 and addi_apci_1500 are the only drivers left that use
this function in addi_common.c. The addi_common code adds a lot of bloat
to the drivers.

Copy the addi_auto_attach() code to the (*auto_attach) functions of the
drivers and remove the function. This will help with removing the bloat.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/addi-data/addi_common.c
drivers/staging/comedi/drivers/addi_apci_035.c
drivers/staging/comedi/drivers/addi_apci_1500.c

index d0bd8127d52cc838477ed3ae52b8e070db45a21a..850bdae4824327d3eaf44afbafeea6adb9c0b4b1 100644 (file)
@@ -64,195 +64,3 @@ static irqreturn_t v_ADDI_Interrupt(int irq, void *d)
        this_board->interrupt(irq, d);
        return IRQ_RETVAL(1);
 }
-
-static int addi_auto_attach(struct comedi_device *dev,
-                                     unsigned long context_unused)
-{
-       struct pci_dev *pcidev = comedi_to_pci_dev(dev);
-       const struct addi_board *this_board = dev->board_ptr;
-       struct addi_private *devpriv;
-       struct comedi_subdevice *s;
-       int ret, n_subdevices;
-       unsigned int dw_Dummy;
-
-       dev->board_name = this_board->pc_DriverName;
-
-       devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
-       if (!devpriv)
-               return -ENOMEM;
-
-       ret = comedi_pci_enable(dev);
-       if (ret)
-               return ret;
-
-       if (this_board->i_IorangeBase1)
-               dev->iobase = pci_resource_start(pcidev, 1);
-       else
-               dev->iobase = pci_resource_start(pcidev, 0);
-
-       devpriv->iobase = dev->iobase;
-       devpriv->i_IobaseAmcc = pci_resource_start(pcidev, 0);
-       devpriv->i_IobaseAddon = pci_resource_start(pcidev, 2);
-       devpriv->i_IobaseReserved = pci_resource_start(pcidev, 3);
-
-       /* Initialize parameters that can be overridden in EEPROM */
-       devpriv->s_EeParameters.i_NbrAiChannel = this_board->i_NbrAiChannel;
-       devpriv->s_EeParameters.i_NbrAoChannel = this_board->i_NbrAoChannel;
-       devpriv->s_EeParameters.i_AiMaxdata = this_board->i_AiMaxdata;
-       devpriv->s_EeParameters.i_AoMaxdata = this_board->i_AoMaxdata;
-       devpriv->s_EeParameters.i_NbrDiChannel = this_board->i_NbrDiChannel;
-       devpriv->s_EeParameters.i_NbrDoChannel = this_board->i_NbrDoChannel;
-       devpriv->s_EeParameters.i_DoMaxdata = this_board->i_DoMaxdata;
-       devpriv->s_EeParameters.i_Timer = this_board->i_Timer;
-       devpriv->s_EeParameters.ui_MinAcquisitiontimeNs =
-               this_board->ui_MinAcquisitiontimeNs;
-       devpriv->s_EeParameters.ui_MinDelaytimeNs =
-               this_board->ui_MinDelaytimeNs;
-
-       /* ## */
-
-       if (pcidev->irq > 0) {
-               ret = request_irq(pcidev->irq, v_ADDI_Interrupt, IRQF_SHARED,
-                                 dev->board_name, dev);
-               if (ret == 0)
-                       dev->irq = pcidev->irq;
-       }
-
-       /*  Read eepeom and fill addi_board Structure */
-
-       if (this_board->i_PCIEeprom) {
-               if (!(strcmp(this_board->pc_EepromChip, "S5920"))) {
-                       /*  Set 3 wait stait */
-                       if (!(strcmp(dev->board_name, "apci035")))
-                               outl(0x80808082, devpriv->i_IobaseAmcc + 0x60);
-                       else
-                               outl(0x83838383, devpriv->i_IobaseAmcc + 0x60);
-
-                       /*  Enable the interrupt for the controller */
-                       dw_Dummy = inl(devpriv->i_IobaseAmcc + 0x38);
-                       outl(dw_Dummy | 0x2000, devpriv->i_IobaseAmcc + 0x38);
-               }
-               addi_eeprom_read_info(dev, pci_resource_start(pcidev, 0));
-       }
-
-       n_subdevices = 7;
-       ret = comedi_alloc_subdevices(dev, n_subdevices);
-       if (ret)
-               return ret;
-
-       /*  Allocate and Initialise AI Subdevice Structures */
-       s = &dev->subdevices[0];
-       if ((devpriv->s_EeParameters.i_NbrAiChannel)
-               || (this_board->i_NbrAiChannelDiff)) {
-               dev->read_subdev = s;
-               s->type = COMEDI_SUBD_AI;
-               s->subdev_flags =
-                       SDF_READABLE | SDF_COMMON | SDF_GROUND
-                       | SDF_DIFF;
-               if (devpriv->s_EeParameters.i_NbrAiChannel)
-                       s->n_chan = devpriv->s_EeParameters.i_NbrAiChannel;
-               else
-                       s->n_chan = this_board->i_NbrAiChannelDiff;
-               s->maxdata = devpriv->s_EeParameters.i_AiMaxdata;
-               s->len_chanlist = this_board->i_AiChannelList;
-               s->range_table = this_board->pr_AiRangelist;
-
-               s->insn_config = this_board->ai_config;
-               s->insn_read = this_board->ai_read;
-               s->insn_write = this_board->ai_write;
-               s->insn_bits = this_board->ai_bits;
-               s->do_cmdtest = this_board->ai_cmdtest;
-               s->do_cmd = this_board->ai_cmd;
-               s->cancel = this_board->ai_cancel;
-
-       } else {
-               s->type = COMEDI_SUBD_UNUSED;
-       }
-
-       /*  Allocate and Initialise AO Subdevice Structures */
-       s = &dev->subdevices[1];
-       if (devpriv->s_EeParameters.i_NbrAoChannel) {
-               s->type = COMEDI_SUBD_AO;
-               s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON;
-               s->n_chan = devpriv->s_EeParameters.i_NbrAoChannel;
-               s->maxdata = devpriv->s_EeParameters.i_AoMaxdata;
-               s->len_chanlist =
-                       devpriv->s_EeParameters.i_NbrAoChannel;
-               s->insn_write = this_board->ao_write;
-       } else {
-               s->type = COMEDI_SUBD_UNUSED;
-       }
-       /*  Allocate and Initialise DI Subdevice Structures */
-       s = &dev->subdevices[2];
-       if (devpriv->s_EeParameters.i_NbrDiChannel) {
-               s->type = COMEDI_SUBD_DI;
-               s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_COMMON;
-               s->n_chan = devpriv->s_EeParameters.i_NbrDiChannel;
-               s->maxdata = 1;
-               s->len_chanlist =
-                       devpriv->s_EeParameters.i_NbrDiChannel;
-               s->range_table = &range_digital;
-               s->insn_config = this_board->di_config;
-               s->insn_read = this_board->di_read;
-               s->insn_write = this_board->di_write;
-               s->insn_bits = this_board->di_bits;
-       } else {
-               s->type = COMEDI_SUBD_UNUSED;
-       }
-       /*  Allocate and Initialise DO Subdevice Structures */
-       s = &dev->subdevices[3];
-       if (devpriv->s_EeParameters.i_NbrDoChannel) {
-               s->type = COMEDI_SUBD_DO;
-               s->subdev_flags =
-                       SDF_READABLE | SDF_WRITEABLE | SDF_GROUND | SDF_COMMON;
-               s->n_chan = devpriv->s_EeParameters.i_NbrDoChannel;
-               s->maxdata = devpriv->s_EeParameters.i_DoMaxdata;
-               s->len_chanlist =
-                       devpriv->s_EeParameters.i_NbrDoChannel;
-               s->range_table = &range_digital;
-
-               /* insn_config - for digital output memory */
-               s->insn_config = this_board->do_config;
-               s->insn_write = this_board->do_write;
-               s->insn_bits = this_board->do_bits;
-               s->insn_read = this_board->do_read;
-       } else {
-               s->type = COMEDI_SUBD_UNUSED;
-       }
-
-       /*  Allocate and Initialise Timer Subdevice Structures */
-       s = &dev->subdevices[4];
-       if (devpriv->s_EeParameters.i_Timer) {
-               s->type = COMEDI_SUBD_TIMER;
-               s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON;
-               s->n_chan = 1;
-               s->maxdata = 0;
-               s->len_chanlist = 1;
-               s->range_table = &range_digital;
-
-               s->insn_write = this_board->timer_write;
-               s->insn_read = this_board->timer_read;
-               s->insn_config = this_board->timer_config;
-               s->insn_bits = this_board->timer_bits;
-       } else {
-               s->type = COMEDI_SUBD_UNUSED;
-       }
-
-       /*  Allocate and Initialise TTL */
-       s = &dev->subdevices[5];
-       s->type = COMEDI_SUBD_UNUSED;
-
-       /* EEPROM */
-       s = &dev->subdevices[6];
-       if (this_board->i_PCIEeprom) {
-               s->type = COMEDI_SUBD_MEMORY;
-               s->subdev_flags = SDF_READABLE | SDF_INTERNAL;
-               s->n_chan = 256;
-               s->maxdata = 0xffff;
-               s->insn_read = i_ADDIDATA_InsnReadEeprom;
-       } else {
-               s->type = COMEDI_SUBD_UNUSED;
-       }
-
-       return 0;
-}
index dd28adb00e3d56daf05d0ffb88bce82979b98de5..4f068c2e6a7034369a937d6b234e37e7a58e4d1d 100644 (file)
@@ -39,14 +39,192 @@ static const struct addi_board apci035_boardtypes[] = {
 static int apci035_auto_attach(struct comedi_device *dev,
                               unsigned long context)
 {
+       struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+       const struct addi_board *this_board = dev->board_ptr;
+       struct addi_private *devpriv;
+       struct comedi_subdevice *s;
+       unsigned int dw_Dummy;
        int ret;
 
        dev->board_ptr = &apci035_boardtypes[0];
+       dev->board_name = this_board->pc_DriverName;
 
-       ret = addi_auto_attach(dev, context);
+       devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
+       if (!devpriv)
+               return -ENOMEM;
+
+       ret = comedi_pci_enable(dev);
        if (ret)
                return ret;
 
+       if (this_board->i_IorangeBase1)
+               dev->iobase = pci_resource_start(pcidev, 1);
+       else
+               dev->iobase = pci_resource_start(pcidev, 0);
+
+       devpriv->iobase = dev->iobase;
+       devpriv->i_IobaseAmcc = pci_resource_start(pcidev, 0);
+       devpriv->i_IobaseAddon = pci_resource_start(pcidev, 2);
+       devpriv->i_IobaseReserved = pci_resource_start(pcidev, 3);
+
+       /* Initialize parameters that can be overridden in EEPROM */
+       devpriv->s_EeParameters.i_NbrAiChannel = this_board->i_NbrAiChannel;
+       devpriv->s_EeParameters.i_NbrAoChannel = this_board->i_NbrAoChannel;
+       devpriv->s_EeParameters.i_AiMaxdata = this_board->i_AiMaxdata;
+       devpriv->s_EeParameters.i_AoMaxdata = this_board->i_AoMaxdata;
+       devpriv->s_EeParameters.i_NbrDiChannel = this_board->i_NbrDiChannel;
+       devpriv->s_EeParameters.i_NbrDoChannel = this_board->i_NbrDoChannel;
+       devpriv->s_EeParameters.i_DoMaxdata = this_board->i_DoMaxdata;
+       devpriv->s_EeParameters.i_Timer = this_board->i_Timer;
+       devpriv->s_EeParameters.ui_MinAcquisitiontimeNs =
+               this_board->ui_MinAcquisitiontimeNs;
+       devpriv->s_EeParameters.ui_MinDelaytimeNs =
+               this_board->ui_MinDelaytimeNs;
+
+       /* ## */
+
+       if (pcidev->irq > 0) {
+               ret = request_irq(pcidev->irq, v_ADDI_Interrupt, IRQF_SHARED,
+                                 dev->board_name, dev);
+               if (ret == 0)
+                       dev->irq = pcidev->irq;
+       }
+
+       /*  Read eepeom and fill addi_board Structure */
+
+       if (this_board->i_PCIEeprom) {
+               if (!(strcmp(this_board->pc_EepromChip, "S5920"))) {
+                       /*  Set 3 wait stait */
+                       if (!(strcmp(dev->board_name, "apci035")))
+                               outl(0x80808082, devpriv->i_IobaseAmcc + 0x60);
+                       else
+                               outl(0x83838383, devpriv->i_IobaseAmcc + 0x60);
+
+                       /*  Enable the interrupt for the controller */
+                       dw_Dummy = inl(devpriv->i_IobaseAmcc + 0x38);
+                       outl(dw_Dummy | 0x2000, devpriv->i_IobaseAmcc + 0x38);
+               }
+               addi_eeprom_read_info(dev, pci_resource_start(pcidev, 0));
+       }
+
+       ret = comedi_alloc_subdevices(dev, 7);
+       if (ret)
+               return ret;
+
+       /*  Allocate and Initialise AI Subdevice Structures */
+       s = &dev->subdevices[0];
+       if ((devpriv->s_EeParameters.i_NbrAiChannel)
+               || (this_board->i_NbrAiChannelDiff)) {
+               dev->read_subdev = s;
+               s->type = COMEDI_SUBD_AI;
+               s->subdev_flags =
+                       SDF_READABLE | SDF_COMMON | SDF_GROUND
+                       | SDF_DIFF;
+               if (devpriv->s_EeParameters.i_NbrAiChannel)
+                       s->n_chan = devpriv->s_EeParameters.i_NbrAiChannel;
+               else
+                       s->n_chan = this_board->i_NbrAiChannelDiff;
+               s->maxdata = devpriv->s_EeParameters.i_AiMaxdata;
+               s->len_chanlist = this_board->i_AiChannelList;
+               s->range_table = this_board->pr_AiRangelist;
+
+               s->insn_config = this_board->ai_config;
+               s->insn_read = this_board->ai_read;
+               s->insn_write = this_board->ai_write;
+               s->insn_bits = this_board->ai_bits;
+               s->do_cmdtest = this_board->ai_cmdtest;
+               s->do_cmd = this_board->ai_cmd;
+               s->cancel = this_board->ai_cancel;
+
+       } else {
+               s->type = COMEDI_SUBD_UNUSED;
+       }
+
+       /*  Allocate and Initialise AO Subdevice Structures */
+       s = &dev->subdevices[1];
+       if (devpriv->s_EeParameters.i_NbrAoChannel) {
+               s->type = COMEDI_SUBD_AO;
+               s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON;
+               s->n_chan = devpriv->s_EeParameters.i_NbrAoChannel;
+               s->maxdata = devpriv->s_EeParameters.i_AoMaxdata;
+               s->len_chanlist =
+                       devpriv->s_EeParameters.i_NbrAoChannel;
+               s->insn_write = this_board->ao_write;
+       } else {
+               s->type = COMEDI_SUBD_UNUSED;
+       }
+       /*  Allocate and Initialise DI Subdevice Structures */
+       s = &dev->subdevices[2];
+       if (devpriv->s_EeParameters.i_NbrDiChannel) {
+               s->type = COMEDI_SUBD_DI;
+               s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_COMMON;
+               s->n_chan = devpriv->s_EeParameters.i_NbrDiChannel;
+               s->maxdata = 1;
+               s->len_chanlist =
+                       devpriv->s_EeParameters.i_NbrDiChannel;
+               s->range_table = &range_digital;
+               s->insn_config = this_board->di_config;
+               s->insn_read = this_board->di_read;
+               s->insn_write = this_board->di_write;
+               s->insn_bits = this_board->di_bits;
+       } else {
+               s->type = COMEDI_SUBD_UNUSED;
+       }
+       /*  Allocate and Initialise DO Subdevice Structures */
+       s = &dev->subdevices[3];
+       if (devpriv->s_EeParameters.i_NbrDoChannel) {
+               s->type = COMEDI_SUBD_DO;
+               s->subdev_flags =
+                       SDF_READABLE | SDF_WRITEABLE | SDF_GROUND | SDF_COMMON;
+               s->n_chan = devpriv->s_EeParameters.i_NbrDoChannel;
+               s->maxdata = devpriv->s_EeParameters.i_DoMaxdata;
+               s->len_chanlist =
+                       devpriv->s_EeParameters.i_NbrDoChannel;
+               s->range_table = &range_digital;
+
+               /* insn_config - for digital output memory */
+               s->insn_config = this_board->do_config;
+               s->insn_write = this_board->do_write;
+               s->insn_bits = this_board->do_bits;
+               s->insn_read = this_board->do_read;
+       } else {
+               s->type = COMEDI_SUBD_UNUSED;
+       }
+
+       /*  Allocate and Initialise Timer Subdevice Structures */
+       s = &dev->subdevices[4];
+       if (devpriv->s_EeParameters.i_Timer) {
+               s->type = COMEDI_SUBD_TIMER;
+               s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON;
+               s->n_chan = 1;
+               s->maxdata = 0;
+               s->len_chanlist = 1;
+               s->range_table = &range_digital;
+
+               s->insn_write = this_board->timer_write;
+               s->insn_read = this_board->timer_read;
+               s->insn_config = this_board->timer_config;
+               s->insn_bits = this_board->timer_bits;
+       } else {
+               s->type = COMEDI_SUBD_UNUSED;
+       }
+
+       /*  Allocate and Initialise TTL */
+       s = &dev->subdevices[5];
+       s->type = COMEDI_SUBD_UNUSED;
+
+       /* EEPROM */
+       s = &dev->subdevices[6];
+       if (this_board->i_PCIEeprom) {
+               s->type = COMEDI_SUBD_MEMORY;
+               s->subdev_flags = SDF_READABLE | SDF_INTERNAL;
+               s->n_chan = 256;
+               s->maxdata = 0xffff;
+               s->insn_read = i_ADDIDATA_InsnReadEeprom;
+       } else {
+               s->type = COMEDI_SUBD_UNUSED;
+       }
+
        apci035_reset(dev);
 
        return 0;
index d4b42618859e459a02051d92fcd395c73b28c7c4..a4a0dab85d6a0240057aeb5bfbd6243009b667cc 100644 (file)
@@ -38,14 +38,192 @@ static const struct addi_board apci1500_boardtypes[] = {
 static int apci1500_auto_attach(struct comedi_device *dev,
                                unsigned long context)
 {
+       struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+       const struct addi_board *this_board = dev->board_ptr;
+       struct addi_private *devpriv;
+       struct comedi_subdevice *s;
+       unsigned int dw_Dummy;
        int ret;
 
        dev->board_ptr = &apci1500_boardtypes[0];
+       dev->board_name = this_board->pc_DriverName;
 
-       ret = addi_auto_attach(dev, context);
+       devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
+       if (!devpriv)
+               return -ENOMEM;
+
+       ret = comedi_pci_enable(dev);
        if (ret)
                return ret;
 
+       if (this_board->i_IorangeBase1)
+               dev->iobase = pci_resource_start(pcidev, 1);
+       else
+               dev->iobase = pci_resource_start(pcidev, 0);
+
+       devpriv->iobase = dev->iobase;
+       devpriv->i_IobaseAmcc = pci_resource_start(pcidev, 0);
+       devpriv->i_IobaseAddon = pci_resource_start(pcidev, 2);
+       devpriv->i_IobaseReserved = pci_resource_start(pcidev, 3);
+
+       /* Initialize parameters that can be overridden in EEPROM */
+       devpriv->s_EeParameters.i_NbrAiChannel = this_board->i_NbrAiChannel;
+       devpriv->s_EeParameters.i_NbrAoChannel = this_board->i_NbrAoChannel;
+       devpriv->s_EeParameters.i_AiMaxdata = this_board->i_AiMaxdata;
+       devpriv->s_EeParameters.i_AoMaxdata = this_board->i_AoMaxdata;
+       devpriv->s_EeParameters.i_NbrDiChannel = this_board->i_NbrDiChannel;
+       devpriv->s_EeParameters.i_NbrDoChannel = this_board->i_NbrDoChannel;
+       devpriv->s_EeParameters.i_DoMaxdata = this_board->i_DoMaxdata;
+       devpriv->s_EeParameters.i_Timer = this_board->i_Timer;
+       devpriv->s_EeParameters.ui_MinAcquisitiontimeNs =
+               this_board->ui_MinAcquisitiontimeNs;
+       devpriv->s_EeParameters.ui_MinDelaytimeNs =
+               this_board->ui_MinDelaytimeNs;
+
+       /* ## */
+
+       if (pcidev->irq > 0) {
+               ret = request_irq(pcidev->irq, v_ADDI_Interrupt, IRQF_SHARED,
+                                 dev->board_name, dev);
+               if (ret == 0)
+                       dev->irq = pcidev->irq;
+       }
+
+       /*  Read eepeom and fill addi_board Structure */
+
+       if (this_board->i_PCIEeprom) {
+               if (!(strcmp(this_board->pc_EepromChip, "S5920"))) {
+                       /*  Set 3 wait stait */
+                       if (!(strcmp(dev->board_name, "apci035")))
+                               outl(0x80808082, devpriv->i_IobaseAmcc + 0x60);
+                       else
+                               outl(0x83838383, devpriv->i_IobaseAmcc + 0x60);
+
+                       /*  Enable the interrupt for the controller */
+                       dw_Dummy = inl(devpriv->i_IobaseAmcc + 0x38);
+                       outl(dw_Dummy | 0x2000, devpriv->i_IobaseAmcc + 0x38);
+               }
+               addi_eeprom_read_info(dev, pci_resource_start(pcidev, 0));
+       }
+
+       ret = comedi_alloc_subdevices(dev, 7);
+       if (ret)
+               return ret;
+
+       /*  Allocate and Initialise AI Subdevice Structures */
+       s = &dev->subdevices[0];
+       if ((devpriv->s_EeParameters.i_NbrAiChannel)
+               || (this_board->i_NbrAiChannelDiff)) {
+               dev->read_subdev = s;
+               s->type = COMEDI_SUBD_AI;
+               s->subdev_flags =
+                       SDF_READABLE | SDF_COMMON | SDF_GROUND
+                       | SDF_DIFF;
+               if (devpriv->s_EeParameters.i_NbrAiChannel)
+                       s->n_chan = devpriv->s_EeParameters.i_NbrAiChannel;
+               else
+                       s->n_chan = this_board->i_NbrAiChannelDiff;
+               s->maxdata = devpriv->s_EeParameters.i_AiMaxdata;
+               s->len_chanlist = this_board->i_AiChannelList;
+               s->range_table = this_board->pr_AiRangelist;
+
+               s->insn_config = this_board->ai_config;
+               s->insn_read = this_board->ai_read;
+               s->insn_write = this_board->ai_write;
+               s->insn_bits = this_board->ai_bits;
+               s->do_cmdtest = this_board->ai_cmdtest;
+               s->do_cmd = this_board->ai_cmd;
+               s->cancel = this_board->ai_cancel;
+
+       } else {
+               s->type = COMEDI_SUBD_UNUSED;
+       }
+
+       /*  Allocate and Initialise AO Subdevice Structures */
+       s = &dev->subdevices[1];
+       if (devpriv->s_EeParameters.i_NbrAoChannel) {
+               s->type = COMEDI_SUBD_AO;
+               s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON;
+               s->n_chan = devpriv->s_EeParameters.i_NbrAoChannel;
+               s->maxdata = devpriv->s_EeParameters.i_AoMaxdata;
+               s->len_chanlist =
+                       devpriv->s_EeParameters.i_NbrAoChannel;
+               s->insn_write = this_board->ao_write;
+       } else {
+               s->type = COMEDI_SUBD_UNUSED;
+       }
+       /*  Allocate and Initialise DI Subdevice Structures */
+       s = &dev->subdevices[2];
+       if (devpriv->s_EeParameters.i_NbrDiChannel) {
+               s->type = COMEDI_SUBD_DI;
+               s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_COMMON;
+               s->n_chan = devpriv->s_EeParameters.i_NbrDiChannel;
+               s->maxdata = 1;
+               s->len_chanlist =
+                       devpriv->s_EeParameters.i_NbrDiChannel;
+               s->range_table = &range_digital;
+               s->insn_config = this_board->di_config;
+               s->insn_read = this_board->di_read;
+               s->insn_write = this_board->di_write;
+               s->insn_bits = this_board->di_bits;
+       } else {
+               s->type = COMEDI_SUBD_UNUSED;
+       }
+       /*  Allocate and Initialise DO Subdevice Structures */
+       s = &dev->subdevices[3];
+       if (devpriv->s_EeParameters.i_NbrDoChannel) {
+               s->type = COMEDI_SUBD_DO;
+               s->subdev_flags =
+                       SDF_READABLE | SDF_WRITEABLE | SDF_GROUND | SDF_COMMON;
+               s->n_chan = devpriv->s_EeParameters.i_NbrDoChannel;
+               s->maxdata = devpriv->s_EeParameters.i_DoMaxdata;
+               s->len_chanlist =
+                       devpriv->s_EeParameters.i_NbrDoChannel;
+               s->range_table = &range_digital;
+
+               /* insn_config - for digital output memory */
+               s->insn_config = this_board->do_config;
+               s->insn_write = this_board->do_write;
+               s->insn_bits = this_board->do_bits;
+               s->insn_read = this_board->do_read;
+       } else {
+               s->type = COMEDI_SUBD_UNUSED;
+       }
+
+       /*  Allocate and Initialise Timer Subdevice Structures */
+       s = &dev->subdevices[4];
+       if (devpriv->s_EeParameters.i_Timer) {
+               s->type = COMEDI_SUBD_TIMER;
+               s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON;
+               s->n_chan = 1;
+               s->maxdata = 0;
+               s->len_chanlist = 1;
+               s->range_table = &range_digital;
+
+               s->insn_write = this_board->timer_write;
+               s->insn_read = this_board->timer_read;
+               s->insn_config = this_board->timer_config;
+               s->insn_bits = this_board->timer_bits;
+       } else {
+               s->type = COMEDI_SUBD_UNUSED;
+       }
+
+       /*  Allocate and Initialise TTL */
+       s = &dev->subdevices[5];
+       s->type = COMEDI_SUBD_UNUSED;
+
+       /* EEPROM */
+       s = &dev->subdevices[6];
+       if (this_board->i_PCIEeprom) {
+               s->type = COMEDI_SUBD_MEMORY;
+               s->subdev_flags = SDF_READABLE | SDF_INTERNAL;
+               s->n_chan = 256;
+               s->maxdata = 0xffff;
+               s->insn_read = i_ADDIDATA_InsnReadEeprom;
+       } else {
+               s->type = COMEDI_SUBD_UNUSED;
+       }
+
        apci1500_reset(dev);
 
        return 0;