Commit 694dcf50 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: addi_apci_3501: only allocate needed subdevices

The addi-data "common" code always allocated 7 subdevices. This
driver only uses 5. Change the allocation and remove the unused
subdevices.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 94f68357
...@@ -225,7 +225,7 @@ static int apci3501_auto_attach(struct comedi_device *dev, ...@@ -225,7 +225,7 @@ static int apci3501_auto_attach(struct comedi_device *dev,
struct addi_private *devpriv; struct addi_private *devpriv;
struct comedi_subdevice *s; struct comedi_subdevice *s;
int ao_n_chan; int ao_n_chan;
int ret, n_subdevices; int ret;
dev->board_name = dev->driver->driver_name; dev->board_name = dev->driver->driver_name;
...@@ -250,17 +250,12 @@ static int apci3501_auto_attach(struct comedi_device *dev, ...@@ -250,17 +250,12 @@ static int apci3501_auto_attach(struct comedi_device *dev,
dev->irq = pcidev->irq; dev->irq = pcidev->irq;
} }
n_subdevices = 7; ret = comedi_alloc_subdevices(dev, 5);
ret = comedi_alloc_subdevices(dev, n_subdevices);
if (ret) if (ret)
return ret; return ret;
/* Allocate and Initialise AI Subdevice Structures */ /* Initialize the analog output subdevice */
s = &dev->subdevices[0]; s = &dev->subdevices[0];
s->type = COMEDI_SUBD_UNUSED;
/* Allocate and Initialise AO Subdevice Structures */
s = &dev->subdevices[1];
if (ao_n_chan) { if (ao_n_chan) {
s->type = COMEDI_SUBD_AO; s->type = COMEDI_SUBD_AO;
s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON;
...@@ -273,8 +268,8 @@ static int apci3501_auto_attach(struct comedi_device *dev, ...@@ -273,8 +268,8 @@ static int apci3501_auto_attach(struct comedi_device *dev,
s->type = COMEDI_SUBD_UNUSED; s->type = COMEDI_SUBD_UNUSED;
} }
/* Allocate and Initialise DI Subdevice Structures */ /* Initialize the digital input subdevice */
s = &dev->subdevices[2]; s = &dev->subdevices[1];
s->type = COMEDI_SUBD_DI; s->type = COMEDI_SUBD_DI;
s->subdev_flags = SDF_READABLE; s->subdev_flags = SDF_READABLE;
s->n_chan = 2; s->n_chan = 2;
...@@ -283,7 +278,7 @@ static int apci3501_auto_attach(struct comedi_device *dev, ...@@ -283,7 +278,7 @@ static int apci3501_auto_attach(struct comedi_device *dev,
s->insn_bits = apci3501_di_insn_bits; s->insn_bits = apci3501_di_insn_bits;
/* Initialize the digital output subdevice */ /* Initialize the digital output subdevice */
s = &dev->subdevices[3]; s = &dev->subdevices[2];
s->type = COMEDI_SUBD_DO; s->type = COMEDI_SUBD_DO;
s->subdev_flags = SDF_WRITEABLE; s->subdev_flags = SDF_WRITEABLE;
s->n_chan = 2; s->n_chan = 2;
...@@ -291,8 +286,8 @@ static int apci3501_auto_attach(struct comedi_device *dev, ...@@ -291,8 +286,8 @@ static int apci3501_auto_attach(struct comedi_device *dev,
s->range_table = &range_digital; s->range_table = &range_digital;
s->insn_bits = apci3501_do_insn_bits; s->insn_bits = apci3501_do_insn_bits;
/* Allocate and Initialise Timer Subdevice Structures */ /* Initialize the timer/watchdog subdevice */
s = &dev->subdevices[4]; s = &dev->subdevices[3];
s->type = COMEDI_SUBD_TIMER; s->type = COMEDI_SUBD_TIMER;
s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON;
s->n_chan = 1; s->n_chan = 1;
...@@ -303,12 +298,8 @@ static int apci3501_auto_attach(struct comedi_device *dev, ...@@ -303,12 +298,8 @@ static int apci3501_auto_attach(struct comedi_device *dev,
s->insn_read = i_APCI3501_ReadTimerCounterWatchdog; s->insn_read = i_APCI3501_ReadTimerCounterWatchdog;
s->insn_config = i_APCI3501_ConfigTimerCounterWatchdog; s->insn_config = i_APCI3501_ConfigTimerCounterWatchdog;
/* Allocate and Initialise TTL */ /* Initialize the eeprom subdevice */
s = &dev->subdevices[5]; s = &dev->subdevices[4];
s->type = COMEDI_SUBD_UNUSED;
/* EEPROM */
s = &dev->subdevices[6];
s->type = COMEDI_SUBD_MEMORY; s->type = COMEDI_SUBD_MEMORY;
s->subdev_flags = SDF_READABLE | SDF_INTERNAL; s->subdev_flags = SDF_READABLE | SDF_INTERNAL;
s->n_chan = 256; s->n_chan = 256;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment