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

staging: comedi: comedi_parport: don't fail attach if irq is not available

Interrupt support in this driver is optional. Don't fail the attach of the
board if the request_irq() fails.

Only allocate and setup the subdevice for the interrupt if the request_irq()
was successful.
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 b6ede054
...@@ -250,25 +250,20 @@ static int parport_attach(struct comedi_device *dev, ...@@ -250,25 +250,20 @@ static int parport_attach(struct comedi_device *dev,
struct comedi_devconfig *it) struct comedi_devconfig *it)
{ {
struct comedi_subdevice *s; struct comedi_subdevice *s;
unsigned int irq;
int ret; int ret;
ret = comedi_request_region(dev, it->options[0], 0x03); ret = comedi_request_region(dev, it->options[0], 0x03);
if (ret) if (ret)
return ret; return ret;
irq = it->options[1]; if (it->options[1]) {
if (irq) { ret = request_irq(it->options[1], parport_interrupt, 0,
ret = request_irq(irq, parport_interrupt, 0, dev->board_name, dev->board_name, dev);
dev); if (ret == 0)
if (ret < 0) { dev->irq = it->options[1];
dev_err(dev->class_dev, "irq not available\n");
return -EINVAL;
}
dev->irq = irq;
} }
ret = comedi_alloc_subdevices(dev, 4); ret = comedi_alloc_subdevices(dev, dev->irq ? 4 : 3);
if (ret) if (ret)
return ret; return ret;
...@@ -297,8 +292,8 @@ static int parport_attach(struct comedi_device *dev, ...@@ -297,8 +292,8 @@ static int parport_attach(struct comedi_device *dev,
s->range_table = &range_digital; s->range_table = &range_digital;
s->insn_bits = parport_ctrl_reg_insn_bits; s->insn_bits = parport_ctrl_reg_insn_bits;
if (dev->irq) {
s = &dev->subdevices[3]; s = &dev->subdevices[3];
if (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;
...@@ -309,8 +304,6 @@ static int parport_attach(struct comedi_device *dev, ...@@ -309,8 +304,6 @@ static int parport_attach(struct comedi_device *dev,
s->do_cmdtest = parport_intr_cmdtest; s->do_cmdtest = parport_intr_cmdtest;
s->do_cmd = parport_intr_cmd; s->do_cmd = parport_intr_cmd;
s->cancel = parport_intr_cancel; s->cancel = parport_intr_cancel;
} else {
s->type = COMEDI_SUBD_UNUSED;
} }
outb(0, dev->iobase + PARPORT_DATA_REG); outb(0, dev->iobase + PARPORT_DATA_REG);
......
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