提交 72998850 编写于 作者: H H Hartley Sweeten 提交者: Greg Kroah-Hartman

staging: comedi: das16m1: tidy up the irq support in das16m1_attach()

An irq is only needed by this driver in order to support async commands.
Since it is optional, modify the attach so that if an invalid irq is
selected by the user, or the request_irq() fails, the attach does not
fail.

Remove all the printk noise about the irq.

Only hookup the async command support if the request_irq() was successful.

Tidy up das16m1_irq_bits() a bit. This helper returns the value that needs
to be written to the DAS16M1_INTR_CONTROL register to setup the irq routing.
Signed-off-by: NH Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: NIan Abbott <abbotti@mev.co.uk>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 b8cd7941
...@@ -508,38 +508,26 @@ static irqreturn_t das16m1_interrupt(int irq, void *d) ...@@ -508,38 +508,26 @@ static irqreturn_t das16m1_interrupt(int irq, void *d)
static int das16m1_irq_bits(unsigned int irq) static int das16m1_irq_bits(unsigned int irq)
{ {
int ret;
switch (irq) { switch (irq) {
case 10: case 10:
ret = 0x0; return 0x0;
break;
case 11: case 11:
ret = 0x1; return 0x1;
break;
case 12: case 12:
ret = 0x2; return 0x2;
break;
case 15: case 15:
ret = 0x3; return 0x3;
break;
case 2: case 2:
ret = 0x4; return 0x4;
break;
case 3: case 3:
ret = 0x5; return 0x5;
break;
case 5: case 5:
ret = 0x6; return 0x6;
break;
case 7: case 7:
ret = 0x7; return 0x7;
break;
default: default:
return -1; return 0x0;
break;
} }
return ret << 4;
} }
/* /*
...@@ -553,7 +541,6 @@ static int das16m1_attach(struct comedi_device *dev, ...@@ -553,7 +541,6 @@ static int das16m1_attach(struct comedi_device *dev,
struct das16m1_private_struct *devpriv; struct das16m1_private_struct *devpriv;
struct comedi_subdevice *s; struct comedi_subdevice *s;
int ret; int ret;
unsigned int irq;
devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
if (!devpriv) if (!devpriv)
...@@ -569,24 +556,12 @@ static int das16m1_attach(struct comedi_device *dev, ...@@ -569,24 +556,12 @@ static int das16m1_attach(struct comedi_device *dev,
return ret; return ret;
devpriv->extra_iobase = dev->iobase + DAS16M1_82C55; devpriv->extra_iobase = dev->iobase + DAS16M1_82C55;
/* now for the irq */ /* only irqs 2, 3, 4, 5, 6, 7, 10, 11, 12, 14, and 15 are valid */
irq = it->options[1]; if ((1 << it->options[1]) & 0xdcfc) {
/* make sure it is valid */ ret = request_irq(it->options[1], das16m1_interrupt, 0,
if (das16m1_irq_bits(irq) >= 0) { dev->board_name, dev);
ret = request_irq(irq, das16m1_interrupt, 0, if (ret == 0)
dev->driver->driver_name, dev); dev->irq = it->options[1];
if (ret < 0)
return ret;
dev->irq = irq;
printk
("irq %u\n", irq);
} else if (irq == 0) {
printk
(", no irq\n");
} else {
comedi_error(dev, "invalid irq\n"
" valid irqs are 2, 3, 5, 7, 10, 11, 12, or 15\n");
return -EINVAL;
} }
ret = comedi_alloc_subdevices(dev, 4); ret = comedi_alloc_subdevices(dev, 4);
...@@ -594,20 +569,22 @@ static int das16m1_attach(struct comedi_device *dev, ...@@ -594,20 +569,22 @@ static int das16m1_attach(struct comedi_device *dev,
return ret; return ret;
s = &dev->subdevices[0]; s = &dev->subdevices[0];
dev->read_subdev = s;
/* ai */ /* ai */
s->type = COMEDI_SUBD_AI; s->type = COMEDI_SUBD_AI;
s->subdev_flags = SDF_READABLE | SDF_CMD_READ; s->subdev_flags = SDF_READABLE | SDF_DIFF;
s->n_chan = 8; s->n_chan = 8;
s->subdev_flags = SDF_DIFF;
s->len_chanlist = 256;
s->maxdata = (1 << 12) - 1; s->maxdata = (1 << 12) - 1;
s->range_table = &range_das16m1; s->range_table = &range_das16m1;
s->insn_read = das16m1_ai_rinsn; s->insn_read = das16m1_ai_rinsn;
s->do_cmdtest = das16m1_cmd_test; if (dev->irq) {
s->do_cmd = das16m1_cmd_exec; dev->read_subdev = s;
s->cancel = das16m1_cancel; s->subdev_flags |= SDF_CMD_READ;
s->poll = das16m1_poll; s->len_chanlist = 256;
s->do_cmdtest = das16m1_cmd_test;
s->do_cmd = das16m1_cmd_exec;
s->cancel = das16m1_cancel;
s->poll = das16m1_poll;
}
s = &dev->subdevices[1]; s = &dev->subdevices[1];
/* di */ /* di */
...@@ -640,10 +617,7 @@ static int das16m1_attach(struct comedi_device *dev, ...@@ -640,10 +617,7 @@ static int das16m1_attach(struct comedi_device *dev,
outb(0, dev->iobase + DAS16M1_DIO); outb(0, dev->iobase + DAS16M1_DIO);
/* set the interrupt level */ /* set the interrupt level */
if (dev->irq) devpriv->control_state = das16m1_irq_bits(dev->irq) << 4;
devpriv->control_state = das16m1_irq_bits(dev->irq);
else
devpriv->control_state = 0;
outb(devpriv->control_state, dev->iobase + DAS16M1_INTR_CONTROL); outb(devpriv->control_state, dev->iobase + DAS16M1_INTR_CONTROL);
return 0; return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册