diff options
author | H Hartley Sweeten <hsweeten@visionengravers.com> | 2013-12-10 02:31:16 +0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-12-17 22:02:14 +0400 |
commit | 5181886e781d0abf58b6f229c205238f17ec788b (patch) | |
tree | 3b23a50a0ae517ea562e539f5317481c2ab51f44 | |
parent | d7c41e83e2c3ae970d41187ae31fad50ccd63856 (diff) | |
download | linux-5181886e781d0abf58b6f229c205238f17ec788b.tar.xz |
staging: comedi: pcmmio: only hook up async command support if irq is available
Refactor the board attach so that the async commands support is only
hooked up if the irq is actually available.
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/pcmmio.c | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/drivers/staging/comedi/drivers/pcmmio.c b/drivers/staging/comedi/drivers/pcmmio.c index 055781dc7875..a5b81ef2771f 100644 --- a/drivers/staging/comedi/drivers/pcmmio.c +++ b/drivers/staging/comedi/drivers/pcmmio.c @@ -807,6 +807,16 @@ static int pcmmio_attach(struct comedi_device *dev, struct comedi_devconfig *it) return -ENOMEM; spin_lock_init(&devpriv->pagelock); + spin_lock_init(&devpriv->spinlock); + + pcmmio_reset(dev); + + if (it->options[1]) { + ret = request_irq(it->options[1], interrupt_pcmmio, 0, + dev->board_name, dev); + if (ret == 0) + dev->irq = it->options[1]; + } ret = comedi_alloc_subdevices(dev, 4); if (ret) @@ -851,18 +861,14 @@ static int pcmmio_attach(struct comedi_device *dev, struct comedi_devconfig *it) s->range_table = &range_digital; s->insn_bits = pcmmio_dio_insn_bits; s->insn_config = pcmmio_dio_insn_config; - - dev->read_subdev = s; - s->subdev_flags |= SDF_CMD_READ; - s->len_chanlist = s->n_chan; - s->cancel = pcmmio_cancel; - s->do_cmd = pcmmio_cmd; - s->do_cmdtest = pcmmio_cmdtest; - - devpriv->active = 0; - devpriv->stop_count = 0; - - spin_lock_init(&devpriv->spinlock); + if (dev->irq) { + dev->read_subdev = s; + s->subdev_flags |= SDF_CMD_READ; + s->len_chanlist = s->n_chan; + s->cancel = pcmmio_cancel; + s->do_cmd = pcmmio_cmd; + s->do_cmdtest = pcmmio_cmdtest; + } /* Digital I/O subdevice */ s = &dev->subdevices[3]; @@ -874,15 +880,6 @@ static int pcmmio_attach(struct comedi_device *dev, struct comedi_devconfig *it) s->insn_bits = pcmmio_dio_insn_bits; s->insn_config = pcmmio_dio_insn_config; - pcmmio_reset(dev); - - if (it->options[1]) { - ret = request_irq(it->options[1], interrupt_pcmmio, 0, - dev->board_name, dev); - if (ret == 0) - dev->irq = it->options[1]; - } - return 1; } |