Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ed7a693f authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman
Browse files

staging: comedi: das1800: tidy up irq request



This driver only needs an irq in order to support async commands.
If the irq is not available the driver will still function for
single analog input reads.

Tidy up the code that does the irq requests so that the driver
will still attach if it is not avaliable.

Remove the noise about the irq during the attach.

Only hook up the async commands support if the irq is available.
Remove the then unnecessary sanity check in das1800_ai_do_cmd().

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 2d856648
Loading
Loading
Loading
Loading
+37 −49
Original line number Diff line number Diff line
@@ -1150,12 +1150,6 @@ static int das1800_ai_do_cmd(struct comedi_device *dev,
	struct comedi_async *async = s->async;
	const struct comedi_cmd *cmd = &async->cmd;

	if (!dev->irq) {
		comedi_error(dev,
			     "no irq assigned for das-1800, cannot do hardware conversions");
		return -1;
	}

	/* disable dma on TRIG_WAKE_EOS, or TRIG_RT
	 * (because dma in handler is unsafe at hard real-time priority) */
	if (cmd->flags & (TRIG_WAKE_EOS | TRIG_RT))
@@ -1522,21 +1516,14 @@ static int das1800_attach(struct comedi_device *dev,
		devpriv->iobase2 = iobase2;
	}

	/* grab our IRQ */
	if (irq) {
		if (request_irq(irq, das1800_interrupt, 0,
				dev->driver->driver_name, dev)) {
			dev_dbg(dev->class_dev, "unable to allocate irq %u\n",
				irq);
			return -EINVAL;
		}
	}
	if (irq == 3 || irq == 5 || irq == 7 || irq == 10 || irq == 11 ||
	    irq == 15) {
		ret = request_irq(irq, das1800_interrupt, 0,
				  dev->board_name, dev);
		if (ret == 0) {
			dev->irq = irq;

	/*  set bits that tell card which irq to use */
			switch (irq) {
	case 0:
		break;
			case 3:
				devpriv->irq_dma_bits |= 0x8;
				break;
@@ -1555,10 +1542,8 @@ static int das1800_attach(struct comedi_device *dev,
			case 15:
				devpriv->irq_dma_bits |= 0x38;
				break;
	default:
		dev_err(dev->class_dev, "irq out of range\n");
		return -EINVAL;
		break;
			}
		}
	}

	ret = das1800_init_dma(dev, dma0, dma1);
@@ -1578,20 +1563,23 @@ static int das1800_attach(struct comedi_device *dev,

	/* analog input subdevice */
	s = &dev->subdevices[0];
	dev->read_subdev = s;
	s->type = COMEDI_SUBD_AI;
	s->subdev_flags = SDF_READABLE | SDF_DIFF | SDF_GROUND | SDF_CMD_READ;
	s->subdev_flags = SDF_READABLE | SDF_DIFF | SDF_GROUND;
	if (thisboard->common)
		s->subdev_flags |= SDF_COMMON;
	s->n_chan = thisboard->qram_len;
	s->len_chanlist = thisboard->qram_len;
	s->maxdata = (1 << thisboard->resolution) - 1;
	s->range_table = thisboard->range_ai;
	s->insn_read = das1800_ai_rinsn;
	if (dev->irq) {
		dev->read_subdev = s;
		s->subdev_flags |= SDF_CMD_READ;
		s->len_chanlist = s->n_chan;
		s->do_cmd = das1800_ai_do_cmd;
		s->do_cmdtest = das1800_ai_do_cmdtest;
	s->insn_read = das1800_ai_rinsn;
		s->poll = das1800_ai_poll;
		s->cancel = das1800_cancel;
	}

	/* analog out */
	s = &dev->subdevices[1];