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

staging: comedi: das1800: tidy up irq request

This driver only needs an irq in order to support async commands.
If the irq is not available the driver will still function for
single analog input reads.

Tidy up the code that does the irq requests so that the driver
will still attach if it is not avaliable.

Remove the noise about the irq during the attach.

Only hook up the async commands support if the irq is available.
Remove the then unnecessary sanity check in das1800_ai_do_cmd().
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 2d856648
...@@ -1150,12 +1150,6 @@ static int das1800_ai_do_cmd(struct comedi_device *dev, ...@@ -1150,12 +1150,6 @@ static int das1800_ai_do_cmd(struct comedi_device *dev,
struct comedi_async *async = s->async; struct comedi_async *async = s->async;
const struct comedi_cmd *cmd = &async->cmd; const struct comedi_cmd *cmd = &async->cmd;
if (!dev->irq) {
comedi_error(dev,
"no irq assigned for das-1800, cannot do hardware conversions");
return -1;
}
/* disable dma on TRIG_WAKE_EOS, or TRIG_RT /* disable dma on TRIG_WAKE_EOS, or TRIG_RT
* (because dma in handler is unsafe at hard real-time priority) */ * (because dma in handler is unsafe at hard real-time priority) */
if (cmd->flags & (TRIG_WAKE_EOS | TRIG_RT)) if (cmd->flags & (TRIG_WAKE_EOS | TRIG_RT))
...@@ -1522,43 +1516,34 @@ static int das1800_attach(struct comedi_device *dev, ...@@ -1522,43 +1516,34 @@ static int das1800_attach(struct comedi_device *dev,
devpriv->iobase2 = iobase2; devpriv->iobase2 = iobase2;
} }
/* grab our IRQ */ if (irq == 3 || irq == 5 || irq == 7 || irq == 10 || irq == 11 ||
if (irq) { irq == 15) {
if (request_irq(irq, das1800_interrupt, 0, ret = request_irq(irq, das1800_interrupt, 0,
dev->driver->driver_name, dev)) { dev->board_name, dev);
dev_dbg(dev->class_dev, "unable to allocate irq %u\n", if (ret == 0) {
irq); dev->irq = irq;
return -EINVAL;
}
}
dev->irq = irq;
/* set bits that tell card which irq to use */ switch (irq) {
switch (irq) { case 3:
case 0: devpriv->irq_dma_bits |= 0x8;
break; break;
case 3: case 5:
devpriv->irq_dma_bits |= 0x8; devpriv->irq_dma_bits |= 0x10;
break; break;
case 5: case 7:
devpriv->irq_dma_bits |= 0x10; devpriv->irq_dma_bits |= 0x18;
break; break;
case 7: case 10:
devpriv->irq_dma_bits |= 0x18; devpriv->irq_dma_bits |= 0x28;
break; break;
case 10: case 11:
devpriv->irq_dma_bits |= 0x28; devpriv->irq_dma_bits |= 0x30;
break; break;
case 11: case 15:
devpriv->irq_dma_bits |= 0x30; devpriv->irq_dma_bits |= 0x38;
break; break;
case 15: }
devpriv->irq_dma_bits |= 0x38; }
break;
default:
dev_err(dev->class_dev, "irq out of range\n");
return -EINVAL;
break;
} }
ret = das1800_init_dma(dev, dma0, dma1); ret = das1800_init_dma(dev, dma0, dma1);
...@@ -1578,20 +1563,23 @@ static int das1800_attach(struct comedi_device *dev, ...@@ -1578,20 +1563,23 @@ static int das1800_attach(struct comedi_device *dev,
/* analog input subdevice */ /* analog input subdevice */
s = &dev->subdevices[0]; s = &dev->subdevices[0];
dev->read_subdev = s;
s->type = COMEDI_SUBD_AI; s->type = COMEDI_SUBD_AI;
s->subdev_flags = SDF_READABLE | SDF_DIFF | SDF_GROUND | SDF_CMD_READ; s->subdev_flags = SDF_READABLE | SDF_DIFF | SDF_GROUND;
if (thisboard->common) if (thisboard->common)
s->subdev_flags |= SDF_COMMON; s->subdev_flags |= SDF_COMMON;
s->n_chan = thisboard->qram_len; s->n_chan = thisboard->qram_len;
s->len_chanlist = thisboard->qram_len;
s->maxdata = (1 << thisboard->resolution) - 1; s->maxdata = (1 << thisboard->resolution) - 1;
s->range_table = thisboard->range_ai; s->range_table = thisboard->range_ai;
s->do_cmd = das1800_ai_do_cmd;
s->do_cmdtest = das1800_ai_do_cmdtest;
s->insn_read = das1800_ai_rinsn; s->insn_read = das1800_ai_rinsn;
s->poll = das1800_ai_poll; if (dev->irq) {
s->cancel = das1800_cancel; dev->read_subdev = s;
s->subdev_flags |= SDF_CMD_READ;
s->len_chanlist = s->n_chan;
s->do_cmd = das1800_ai_do_cmd;
s->do_cmdtest = das1800_ai_do_cmdtest;
s->poll = das1800_ai_poll;
s->cancel = das1800_cancel;
}
/* analog out */ /* analog out */
s = &dev->subdevices[1]; s = &dev->subdevices[1];
......
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