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

staging: comedi: ni_atmio16d: tidy up the irq support in atmio16d_attach()

Tidy up the code that does the request_irq().

Only hookup the commad support if the irq was sucessfully requested.
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 d4bdba2f
...@@ -631,7 +631,6 @@ static int atmio16d_attach(struct comedi_device *dev, ...@@ -631,7 +631,6 @@ static int atmio16d_attach(struct comedi_device *dev,
const struct atmio16_board_t *board = comedi_board(dev); const struct atmio16_board_t *board = comedi_board(dev);
struct atmio16d_private *devpriv; struct atmio16d_private *devpriv;
struct comedi_subdevice *s; struct comedi_subdevice *s;
unsigned int irq;
int ret; int ret;
ret = comedi_request_region(dev, it->options[0], ATMIO16D_SIZE); ret = comedi_request_region(dev, it->options[0], ATMIO16D_SIZE);
...@@ -649,19 +648,11 @@ static int atmio16d_attach(struct comedi_device *dev, ...@@ -649,19 +648,11 @@ static int atmio16d_attach(struct comedi_device *dev,
/* reset the atmio16d hardware */ /* reset the atmio16d hardware */
reset_atmio16d(dev); reset_atmio16d(dev);
/* check if our interrupt is available and get it */ if (it->options[1]) {
irq = it->options[1]; ret = request_irq(it->options[1], atmio16d_interrupt, 0,
if (irq) { dev->board_name, dev);
if (ret == 0)
ret = request_irq(irq, atmio16d_interrupt, 0, "atmio16d", dev); dev->irq = it->options[1];
if (ret < 0) {
printk(KERN_INFO "failed to allocate irq %u\n", irq);
return ret;
}
dev->irq = irq;
printk(KERN_INFO "( irq = %u )\n", irq);
} else {
printk(KERN_INFO "( no irq )");
} }
/* set device options */ /* set device options */
...@@ -677,16 +668,11 @@ static int atmio16d_attach(struct comedi_device *dev, ...@@ -677,16 +668,11 @@ static int atmio16d_attach(struct comedi_device *dev,
/* setup sub-devices */ /* setup sub-devices */
s = &dev->subdevices[0]; s = &dev->subdevices[0];
dev->read_subdev = s;
/* ai subdevice */ /* ai subdevice */
s->type = COMEDI_SUBD_AI; s->type = COMEDI_SUBD_AI;
s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_CMD_READ; s->subdev_flags = SDF_READABLE | SDF_GROUND;
s->n_chan = (devpriv->adc_mux ? 16 : 8); s->n_chan = (devpriv->adc_mux ? 16 : 8);
s->len_chanlist = 16;
s->insn_read = atmio16d_ai_insn_read; s->insn_read = atmio16d_ai_insn_read;
s->do_cmdtest = atmio16d_ai_cmdtest;
s->do_cmd = atmio16d_ai_cmd;
s->cancel = atmio16d_ai_cancel;
s->maxdata = 0xfff; /* 4095 decimal */ s->maxdata = 0xfff; /* 4095 decimal */
switch (devpriv->adc_range) { switch (devpriv->adc_range) {
case adc_bipolar10: case adc_bipolar10:
...@@ -699,6 +685,14 @@ static int atmio16d_attach(struct comedi_device *dev, ...@@ -699,6 +685,14 @@ static int atmio16d_attach(struct comedi_device *dev,
s->range_table = &range_atmio16d_ai_unipolar; s->range_table = &range_atmio16d_ai_unipolar;
break; break;
} }
if (dev->irq) {
dev->read_subdev = s;
s->subdev_flags |= SDF_CMD_READ;
s->len_chanlist = 16;
s->do_cmdtest = atmio16d_ai_cmdtest;
s->do_cmd = atmio16d_ai_cmd;
s->cancel = atmio16d_ai_cancel;
}
/* ao subdevice */ /* ao subdevice */
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