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

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

staging: comedi: s626: factor eos interrupt handling from s626_irq_handler()



Factor the code that handles the end of scan interrupt out of
s626_irq_handler().

Remove the printk noise when cfc_write_to_buffer() fails. The user
can't do anything about it anyway.

Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 3b00b857
Loading
Loading
Loading
Loading
+59 −44
Original line number Original line Diff line number Diff line
@@ -727,64 +727,41 @@ static void check_dio_interrupts(struct comedi_device *dev)
	}
	}
}
}


static irqreturn_t s626_irq_handler(int irq, void *d)
static bool handle_eos_interrupt(struct comedi_device *dev)
{
{
	struct comedi_device *dev = d;
	struct s626_private *devpriv = dev->private;
	struct s626_private *devpriv = dev->private;
	struct comedi_subdevice *s = dev->read_subdev;
	struct comedi_subdevice *s = dev->read_subdev;
	struct comedi_async *async = s->async;
	struct comedi_async *async = s->async;
	struct comedi_cmd *cmd = &async->cmd;
	struct comedi_cmd *cmd = &async->cmd;
	struct enc_private *k;
	/*
	unsigned long flags;
	 * Init ptr to DMA buffer that holds new ADC data.  We skip the
	int32_t *readaddr;
	 * first uint16_t in the buffer because it contains junk data
	uint32_t irqtype, irqstatus;
	 * from the final ADC of the previous poll list scan.
	int i = 0;
	short tempdata;
	uint16_t irqbit;

	if (!dev->attached)
		return IRQ_NONE;
	/*  lock to avoid race with comedi_poll */
	spin_lock_irqsave(&dev->spinlock, flags);

	/* save interrupt enable register state */
	irqstatus = readl(devpriv->base_addr + P_IER);

	/* read interrupt type */
	irqtype = readl(devpriv->base_addr + P_ISR);

	/* disable master interrupt */
	writel(0, devpriv->base_addr + P_IER);

	/* clear interrupt */
	writel(irqtype, devpriv->base_addr + P_ISR);

	switch (irqtype) {
	case IRQ_RPS1:		/*  end_of_scan occurs */
		/* Init ptr to DMA buffer that holds new ADC data.  We skip the
		 * first uint16_t in the buffer because it contains junk data from
		 * the final ADC of the previous poll list scan.
	 */
	 */
		readaddr = (int32_t *) devpriv->ANABuf.LogicalBase + 1;
	int32_t *readaddr = (int32_t *)devpriv->ANABuf.LogicalBase + 1;
	bool finished = false;
	int i;


	/* get the data and hand it over to comedi */
	/* get the data and hand it over to comedi */
	for (i = 0; i < cmd->chanlist_len; i++) {
	for (i = 0; i < cmd->chanlist_len; i++) {
			/*  Convert ADC data to 16-bit integer values and copy to application */
		short tempdata;
			/*  buffer. */

		/*
		 * Convert ADC data to 16-bit integer values and copy
		 * to application buffer.
		 */
		tempdata = s626_ai_reg_to_uint((int)*readaddr);
		tempdata = s626_ai_reg_to_uint((int)*readaddr);
		readaddr++;
		readaddr++;


		/* put data into read buffer */
		/* put data into read buffer */
		/* comedi_buf_put(async, tempdata); */
		/* comedi_buf_put(async, tempdata); */
			if (cfc_write_to_buffer(s, tempdata) == 0)
		cfc_write_to_buffer(s, tempdata);
				printk
				    ("s626_irq_handler: cfc_write_to_buffer error!\n");
	}
	}


	/* end of scan occurs */
	/* end of scan occurs */
	async->events |= COMEDI_CB_EOS;
	async->events |= COMEDI_CB_EOS;


		if (!(devpriv->ai_continous))
	if (!devpriv->ai_continous)
		devpriv->ai_sample_count--;
		devpriv->ai_sample_count--;
	if (devpriv->ai_sample_count <= 0) {
	if (devpriv->ai_sample_count <= 0) {
		devpriv->ai_cmd_running = 0;
		devpriv->ai_cmd_running = 0;
@@ -796,13 +773,51 @@ static irqreturn_t s626_irq_handler(int irq, void *d)
		async->events |= COMEDI_CB_EOA;
		async->events |= COMEDI_CB_EOA;


		/* disable master interrupt */
		/* disable master interrupt */
			irqstatus = 0;
		finished = true;
	}
	}


	if (devpriv->ai_cmd_running && cmd->scan_begin_src == TRIG_EXT)
	if (devpriv->ai_cmd_running && cmd->scan_begin_src == TRIG_EXT)
		s626_dio_set_irq(dev, cmd->scan_begin_arg);
		s626_dio_set_irq(dev, cmd->scan_begin_arg);

	/* tell comedi that data is there */
	/* tell comedi that data is there */
	comedi_event(dev, s);
	comedi_event(dev, s);

	return finished;
}

static irqreturn_t s626_irq_handler(int irq, void *d)
{
	struct comedi_device *dev = d;
	struct s626_private *devpriv = dev->private;
	struct comedi_subdevice *s = dev->read_subdev;
	struct comedi_async *async = s->async;
	struct comedi_cmd *cmd = &async->cmd;
	struct enc_private *k;
	unsigned long flags;
	uint32_t irqtype, irqstatus;
	uint16_t irqbit;

	if (!dev->attached)
		return IRQ_NONE;
	/*  lock to avoid race with comedi_poll */
	spin_lock_irqsave(&dev->spinlock, flags);

	/* save interrupt enable register state */
	irqstatus = readl(devpriv->base_addr + P_IER);

	/* read interrupt type */
	irqtype = readl(devpriv->base_addr + P_ISR);

	/* disable master interrupt */
	writel(0, devpriv->base_addr + P_IER);

	/* clear interrupt */
	writel(irqtype, devpriv->base_addr + P_ISR);

	switch (irqtype) {
	case IRQ_RPS1:		/*  end_of_scan occurs */
		if (handle_eos_interrupt(dev))
			irqstatus = 0;
		break;
		break;
	case IRQ_GPIO3:	/* check dio and conter interrupt */
	case IRQ_GPIO3:	/* check dio and conter interrupt */
		/* s626_dio_clear_irq(dev); */
		/* s626_dio_clear_irq(dev); */