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

staging: comedi: ni_6527: tidy up the interrupt subdevice

Do the request_irq() before setting up the subdevices. Only initialize
the interrupt subdevice if the irq is actually available.

Tidy up the whitespace in the subdevice init.
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 5dfbd505
...@@ -381,6 +381,11 @@ static int ni6527_auto_attach(struct comedi_device *dev, ...@@ -381,6 +381,11 @@ static int ni6527_auto_attach(struct comedi_device *dev,
ni6527_reset(dev); ni6527_reset(dev);
ret = request_irq(pcidev->irq, ni6527_interrupt, IRQF_SHARED,
dev->board_name, dev);
if (ret == 0)
dev->irq = pcidev->irq;
ret = comedi_alloc_subdevices(dev, 3); ret = comedi_alloc_subdevices(dev, 3);
if (ret) if (ret)
return ret; return ret;
...@@ -402,25 +407,23 @@ static int ni6527_auto_attach(struct comedi_device *dev, ...@@ -402,25 +407,23 @@ static int ni6527_auto_attach(struct comedi_device *dev,
s->maxdata = 1; s->maxdata = 1;
s->insn_bits = ni6527_do_insn_bits; s->insn_bits = ni6527_do_insn_bits;
/* Edge detection interrupt subdevice */
s = &dev->subdevices[2]; s = &dev->subdevices[2];
if (dev->irq) {
dev->read_subdev = s; dev->read_subdev = s;
s->type = COMEDI_SUBD_DI; s->type = COMEDI_SUBD_DI;
s->subdev_flags = SDF_READABLE | SDF_CMD_READ; s->subdev_flags = SDF_READABLE | SDF_CMD_READ;
s->n_chan = 1; s->n_chan = 1;
s->range_table = &range_unknown;
s->maxdata = 1; s->maxdata = 1;
s->range_table = &range_digital;
s->insn_config = ni6527_intr_insn_config;
s->insn_bits = ni6527_intr_insn_bits;
s->do_cmdtest = ni6527_intr_cmdtest; s->do_cmdtest = ni6527_intr_cmdtest;
s->do_cmd = ni6527_intr_cmd; s->do_cmd = ni6527_intr_cmd;
s->cancel = ni6527_intr_cancel; s->cancel = ni6527_intr_cancel;
s->insn_bits = ni6527_intr_insn_bits; } else {
s->insn_config = ni6527_intr_insn_config; s->type = COMEDI_SUBD_UNUSED;
}
ret = request_irq(pcidev->irq, ni6527_interrupt,
IRQF_SHARED, dev->board_name, dev);
if (ret < 0)
dev_warn(dev->class_dev, "irq not available\n");
else
dev->irq = pcidev->irq;
return 0; return 0;
} }
......
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