Пример #1
0
static int dio200_subdev_intr_cancel(struct comedi_device *dev,
                                     struct comedi_subdevice *s)
{
    struct dio200_subdev_intr *subpriv = s->private;
    unsigned long flags;

    spin_lock_irqsave(&subpriv->spinlock, flags);
    if (subpriv->active)
        dio200_stop_intr(dev, s);

    spin_unlock_irqrestore(&subpriv->spinlock, flags);

    return 0;
}
static void dio200_read_scan_intr(struct comedi_device *dev,
				  struct comedi_subdevice *s,
				  unsigned int triggered)
{
	struct dio200_subdev_intr *subpriv = s->private;
	struct comedi_cmd *cmd = &s->async->cmd;
	unsigned short val;
	unsigned int n, ch;

	val = 0;
	for (n = 0; n < cmd->chanlist_len; n++) {
		ch = CR_CHAN(cmd->chanlist[n]);
		if (triggered & (1U << ch))
			val |= (1U << n);
	}
	/* Write the scan to the buffer. */
	if (comedi_buf_put(s, val)) {
		s->async->events |= (COMEDI_CB_BLOCK | COMEDI_CB_EOS);
	} else {
		/* Error!  Stop acquisition.  */
		dio200_stop_intr(dev, s);
		s->async->events |= COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW;
		dev_err(dev->class_dev, "buffer overflow\n");
	}

	/* Check for end of acquisition. */
	if (cmd->stop_src == TRIG_COUNT) {
		if (subpriv->stopcount > 0) {
			subpriv->stopcount--;
			if (subpriv->stopcount == 0) {
				s->async->events |= COMEDI_CB_EOA;
				dio200_stop_intr(dev, s);
			}
		}
	}
}