From de91bb97254cec30f24b4f770e10eab7da3f6be1 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 20 Jun 2014 13:12:49 -0700 Subject: [PATCH] staging: comedi: dt282x: tidy up dt282x_ai_dma_interrupt() The main interrupt handler already has the comedi_subdevice pointer needed in this function. Pass that subdevice pointer so that it does not need to be fetched as a local variable. Tidy up the function a bit. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt282x.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/drivers/staging/comedi/drivers/dt282x.c b/drivers/staging/comedi/drivers/dt282x.c index 40c5794ec5c4..d4164ced8185 100644 --- a/drivers/staging/comedi/drivers/dt282x.c +++ b/drivers/staging/comedi/drivers/dt282x.c @@ -484,24 +484,20 @@ static void dt282x_ao_dma_interrupt(struct comedi_device *dev, } } -static void dt282x_ai_dma_interrupt(struct comedi_device *dev) +static void dt282x_ai_dma_interrupt(struct comedi_device *dev, + struct comedi_subdevice *s) { struct dt282x_private *devpriv = dev->private; - struct comedi_subdevice *s = dev->read_subdev; - void *ptr; - int size; - int i; + int cur_dma = devpriv->current_dma_index; + void *ptr = devpriv->dma[cur_dma].buf; + int size = devpriv->dma[cur_dma].size; int ret; outw(devpriv->supcsr | DT2821_CLRDMADNE, dev->iobase + DT2821_SUPCSR); - i = devpriv->current_dma_index; - ptr = devpriv->dma[i].buf; - size = devpriv->dma[i].size; - - disable_dma(devpriv->dma[i].chan); + disable_dma(devpriv->dma[cur_dma].chan); - devpriv->current_dma_index = 1 - i; + devpriv->current_dma_index = 1 - cur_dma; dt282x_munge(dev, s, ptr, size); ret = cfc_write_array_to_buffer(s, ptr, size); @@ -509,8 +505,8 @@ static void dt282x_ai_dma_interrupt(struct comedi_device *dev) s->async->events |= COMEDI_CB_OVERFLOW; return; } - devpriv->nread -= size / 2; + devpriv->nread -= size / 2; if (devpriv->nread < 0) { dev_info(dev->class_dev, "nread off by one\n"); devpriv->nread = 0; @@ -528,7 +524,7 @@ static void dt282x_ai_dma_interrupt(struct comedi_device *dev) } #endif /* restart the channel */ - dt282x_prep_ai_dma(dev, i, 0); + dt282x_prep_ai_dma(dev, cur_dma, 0); } static irqreturn_t dt282x_interrupt(int irq, void *d) @@ -550,7 +546,7 @@ static irqreturn_t dt282x_interrupt(int irq, void *d) supcsr = inw(dev->iobase + DT2821_SUPCSR); if (supcsr & DT2821_DMAD) { if (devpriv->dma_dir == DMA_MODE_READ) - dt282x_ai_dma_interrupt(dev); + dt282x_ai_dma_interrupt(dev, s); else dt282x_ao_dma_interrupt(dev, s_ao); handled = 1; -- 2.30.2