diff options
author | H Hartley Sweeten <hsweeten@visionengravers.com> | 2015-01-20 21:53:07 (GMT) |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-01-25 11:59:10 (GMT) |
commit | 87abf660912c75c08a8eeb501a4770b9e9126750 (patch) | |
tree | 7d0d7767c3ab8b6b20a8d4e4878c4122d0b56cab | |
parent | 7bd428c43437ddd401af6b3214051f89628ac12f (diff) | |
download | linux-87abf660912c75c08a8eeb501a4770b9e9126750.tar.xz |
staging: comedi: adv_pci1710: change boardinfo 'n_aochan' to 'has_ao'
Some of the boards supported by this driver have analog outputs. The pci1720
board has 4 analog output channels and the others have 2.
For aesthetics, change the 'n_aochan' member to a bit-field flag 'has_ao' and
refactor the board attach accordingly. Remove the unnecessary initialization
of the subdevice 'len_chanlist'. That member is only used by subdevices that
support async commands.
Also, remove the unnecessary 'number of channels' check in pci171x_reset().
The boards that used this function, and have analog outputs, always have 2
channels.
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>
-rw-r--r-- | drivers/staging/comedi/drivers/adv_pci1710.c | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index 14aaa1e..ced13e9 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -193,13 +193,13 @@ struct boardtype { const char *name; /* board name */ char cardtype; /* 0=1710& co. 2=1713, ... */ int n_aichan; /* num of A/D chans */ - int n_aochan; /* num of D/A chans */ const struct comedi_lrange *rangelist_ai; /* rangelist for A/D */ const char *rangecode_ai; /* range codes for programming */ const struct comedi_lrange *rangelist_ao; /* rangelist for D/A */ unsigned int has_irq:1; unsigned int has_large_fifo:1; /* 4K or 1K FIFO */ unsigned int has_diff_ai:1; + unsigned int has_ao:1; unsigned int has_di_do:1; unsigned int has_counter:1; }; @@ -209,13 +209,13 @@ static const struct boardtype boardtypes[] = { .name = "pci1710", .cardtype = TYPE_PCI171X, .n_aichan = 16, - .n_aochan = 2, .rangelist_ai = &range_pci1710_3, .rangecode_ai = range_codes_pci1710_3, .rangelist_ao = &range_pci171x_da, .has_irq = 1, .has_large_fifo = 1, .has_diff_ai = 1, + .has_ao = 1, .has_di_do = 1, .has_counter = 1, }, @@ -223,13 +223,13 @@ static const struct boardtype boardtypes[] = { .name = "pci1710hg", .cardtype = TYPE_PCI171X, .n_aichan = 16, - .n_aochan = 2, .rangelist_ai = &range_pci1710hg, .rangecode_ai = range_codes_pci1710hg, .rangelist_ao = &range_pci171x_da, .has_irq = 1, .has_large_fifo = 1, .has_diff_ai = 1, + .has_ao = 1, .has_di_do = 1, .has_counter = 1, }, @@ -237,11 +237,11 @@ static const struct boardtype boardtypes[] = { .name = "pci1711", .cardtype = TYPE_PCI171X, .n_aichan = 16, - .n_aochan = 2, .rangelist_ai = &range_pci17x1, .rangecode_ai = range_codes_pci17x1, .rangelist_ao = &range_pci171x_da, .has_irq = 1, + .has_ao = 1, .has_di_do = 1, .has_counter = 1, }, @@ -258,8 +258,8 @@ static const struct boardtype boardtypes[] = { [BOARD_PCI1720] = { .name = "pci1720", .cardtype = TYPE_PCI1720, - .n_aochan = 4, .rangelist_ao = &range_pci1720, + .has_ao = 1, }, [BOARD_PCI1731] = { .name = "pci1731", @@ -1008,15 +1008,13 @@ static int pci171x_reset(struct comedi_device *dev) outb(0, dev->iobase + PCI171x_CLRINT); /* clear INT request */ pci171x_start_pacer(dev, false); devpriv->da_ranges = 0; - if (this_board->n_aochan) { + if (this_board->has_ao) { /* set DACs to 0..5V */ outb(devpriv->da_ranges, dev->iobase + PCI171x_DAREF); outw(0, dev->iobase + PCI171x_DA1); /* set DA outputs to 0V */ devpriv->ao_data[0] = 0x0000; - if (this_board->n_aochan > 1) { - outw(0, dev->iobase + PCI171x_DA2); - devpriv->ao_data[1] = 0x0000; - } + outw(0, dev->iobase + PCI171x_DA2); + devpriv->ao_data[1] = 0x0000; } outw(0, dev->iobase + PCI171x_DO); /* digital outputs to 0 */ outb(0, dev->iobase + PCI171x_CLRFIFO); /* clear FIFO */ @@ -1091,7 +1089,7 @@ static int pci1710_auto_attach(struct comedi_device *dev, n_subdevices = 0; if (this_board->n_aichan) n_subdevices++; - if (this_board->n_aochan) + if (this_board->has_ao) n_subdevices++; if (this_board->has_di_do) n_subdevices += 2; @@ -1134,19 +1132,19 @@ static int pci1710_auto_attach(struct comedi_device *dev, subdev++; } - if (this_board->n_aochan) { + if (this_board->has_ao) { s = &dev->subdevices[subdev]; s->type = COMEDI_SUBD_AO; s->subdev_flags = SDF_WRITABLE | SDF_GROUND | SDF_COMMON; - s->n_chan = this_board->n_aochan; s->maxdata = 0x0fff; - s->len_chanlist = this_board->n_aochan; s->range_table = this_board->rangelist_ao; switch (this_board->cardtype) { case TYPE_PCI1720: + s->n_chan = 4; s->insn_write = pci1720_insn_write_ao; break; default: + s->n_chan = 2; s->insn_write = pci171x_insn_write_ao; break; } |