summaryrefslogtreecommitdiff
path: root/drivers/staging/comedi/drivers/pcl711.c
diff options
context:
space:
mode:
authorH Hartley Sweeten <hsweeten@visionengravers.com>2013-09-20 16:37:05 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-09-25 15:59:57 -0700
commitb9a8bbf911450f3ef4a86e72afa1190cfed8217d (patch)
tree7a52d3a4a700f567984d5420830f17ffc3a0c80b /drivers/staging/comedi/drivers/pcl711.c
parentbca757ad539aa4f826f4d335f4fcc670e85dcc9b (diff)
staging: comedi: pcl711: save the irq for the pcl711b only when used
Move the storing of the irq in the mode register for the pcl711b board so it's only done when the irq is actually used by the driver. 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>
Diffstat (limited to 'drivers/staging/comedi/drivers/pcl711.c')
-rw-r--r--drivers/staging/comedi/drivers/pcl711.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/drivers/staging/comedi/drivers/pcl711.c b/drivers/staging/comedi/drivers/pcl711.c
index 9f48b02ae7f9..c606052b05bd 100644
--- a/drivers/staging/comedi/drivers/pcl711.c
+++ b/drivers/staging/comedi/drivers/pcl711.c
@@ -474,8 +474,12 @@ static int pcl711_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
const struct pcl711_board *board = comedi_board(dev);
struct pcl711_private *devpriv;
- int ret;
struct comedi_subdevice *s;
+ int ret;
+
+ devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
+ if (!devpriv)
+ return -ENOMEM;
ret = comedi_request_region(dev, it->options[0], 0x10);
if (ret)
@@ -484,18 +488,22 @@ static int pcl711_attach(struct comedi_device *dev, struct comedi_devconfig *it)
if (it->options[1] && it->options[1] <= board->maxirq) {
ret = request_irq(it->options[1], pcl711_interrupt, 0,
dev->board_name, dev);
- if (ret == 0)
+ if (ret == 0) {
dev->irq = it->options[1];
+
+ /*
+ * The PCL711b needs the irq number in the
+ * mode register.
+ */
+ if (board->is_pcl711b)
+ devpriv->mode = (dev->irq << 4);
+ }
}
ret = comedi_alloc_subdevices(dev, 4);
if (ret)
return ret;
- devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
- if (!devpriv)
- return -ENOMEM;
-
/* Analog Input subdevice */
s = &dev->subdevices[0];
s->type = COMEDI_SUBD_AI;
@@ -540,13 +548,6 @@ static int pcl711_attach(struct comedi_device *dev, struct comedi_devconfig *it)
s->range_table = &range_digital;
s->insn_bits = pcl711_do_insn_bits;
- /*
- this is the "base value" for the mode register, which is
- used for the irq on the PCL711
- */
- if (board->is_pcl711b)
- devpriv->mode = (dev->irq << 4);
-
/* clear DAC */
outb(0, dev->iobase + PCL711_DA0_LO);
outb(0, dev->iobase + PCL711_DA0_HI);