From 7c9fc34ea3ed02d7d8356094ac179e1c63ae443b Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 17 Apr 2014 10:07:48 -0700 Subject: [PATCH] staging: comedi: addi_apci_3xxx: fix ai subdevice 'len_chanlist' Due to a driver limitation, the (*do_cmdtest) for the analog input subdevice overrides the cmd->chanlist_len to force single channel chanlists. But, the cmd->scan_end_arg was already validated before this happens. Instead of fixing the (*do_cmdtest) just set the subdevice len_chanlist to 1 to limit the chanlist size. Move the comment also. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/addi_apci_3xxx.c | 40 +++++++++---------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_3xxx.c b/drivers/staging/comedi/drivers/addi_apci_3xxx.c index 6dc11c407f57..64c37b65ba27 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3xxx.c +++ b/drivers/staging/comedi/drivers/addi_apci_3xxx.c @@ -573,26 +573,6 @@ static int apci3xxx_ai_cmdtest(struct comedi_device *dev, /* step 4: fix up any arguments */ - /* - * FIXME: The hardware supports multiple scan modes but the original - * addi-data driver only supported reading a single channel with - * interrupts. Need a proper datasheet to fix this. - * - * The following scan modes are supported by the hardware: - * 1) Single software scan - * 2) Single hardware triggered scan - * 3) Continuous software scan - * 4) Continuous software scan with timer delay - * 5) Continuous hardware triggered scan - * 6) Continuous hardware triggered scan with timer delay - * - * For now, limit the chanlist to a single channel. - */ - if (cmd->chanlist_len > 1) { - cmd->chanlist_len = 1; - err |= -EINVAL; - } - tmp = cmd->convert_arg; err |= apci3xxx_ai_ns_to_timer(dev, &cmd->convert_arg, cmd->flags & TRIG_ROUND_MASK); @@ -842,12 +822,30 @@ static int apci3xxx_auto_attach(struct comedi_device *dev, s->subdev_flags = SDF_READABLE | board->ai_subdev_flags; s->n_chan = board->ai_n_chan; s->maxdata = board->ai_maxdata; - s->len_chanlist = s->n_chan; s->range_table = &apci3xxx_ai_range; s->insn_read = apci3xxx_ai_insn_read; if (dev->irq) { + /* + * FIXME: The hardware supports multiple scan modes + * but the original addi-data driver only supported + * reading a single channel with interrupts. Need a + * proper datasheet to fix this. + * + * The following scan modes are supported by the + * hardware: + * 1) Single software scan + * 2) Single hardware triggered scan + * 3) Continuous software scan + * 4) Continuous software scan with timer delay + * 5) Continuous hardware triggered scan + * 6) Continuous hardware triggered scan with timer + * delay + * + * For now, limit the chanlist to a single channel. + */ dev->read_subdev = s; s->subdev_flags |= SDF_CMD_READ; + s->len_chanlist = 1; s->do_cmdtest = apci3xxx_ai_cmdtest; s->do_cmd = apci3xxx_ai_cmd; s->cancel = apci3xxx_ai_cancel; -- 2.20.1