]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/arm/mach-imx/dma.c
[ARM] replace remaining __FUNCTION__ occurrences
[linux-2.6-omap-h63xx.git] / arch / arm / mach-imx / dma.c
index 4ca51dcf13ac6966dbfc4357ad4dc10d1bfcf657..a59ff2987cb7c582b3ad469281dc899d901ebd41 100644 (file)
@@ -15,6 +15,9 @@
  *             Changed to support scatter gather DMA
  *             by taking Russell's code from RiscPC
  *
+ *  2006-05-31 Pavel Pisa <pisa@cmp.felk.cvut.cz>
+ *             Corrected error handling code.
+ *
  */
 
 #undef DEBUG
@@ -51,7 +54,7 @@ static inline int imx_dma_sg_next(imx_dmach_t dma_ch, unsigned int lastcount)
 
        if (!imxdma->name) {
                printk(KERN_CRIT "%s: called for  not allocated channel %d\n",
-                      __FUNCTION__, dma_ch);
+                      __func__, dma_ch);
                return 0;
        }
 
@@ -128,7 +131,7 @@ imx_dma_setup_sg_base(imx_dmach_t dma_ch,
  * The function setups DMA channel source and destination addresses for transfer
  * specified by provided parameters. The scatter-gather emulation is disabled,
  * because linear data block
- * form the physical address range is transfered.
+ * form the physical address range is transferred.
  * Return value: if incorrect parameters are provided -%EINVAL.
  *             Zero indicates success.
  */
@@ -189,7 +192,7 @@ imx_dma_setup_single(imx_dmach_t dma_ch, dma_addr_t dma_address,
  * @dmamode: DMA transfer mode, %DMA_MODE_READ from the device to the memory
  *           or %DMA_MODE_WRITE from memory to the device
  *
- * The function setups DMA channel state and registers to be ready for transfer
+ * The function sets up DMA channel state and registers to be ready for transfer
  * specified by provided parameters. The scatter-gather emulation is set up
  * according to the parameters.
  *
@@ -209,7 +212,7 @@ imx_dma_setup_single(imx_dmach_t dma_ch, dma_addr_t dma_address,
  *
  * %CCR_SMOD_LINEAR | %CCR_SSIZ_32 | %CCR_DMOD_FIFO | %CCR_DSIZ_x
  *
- * Be carefull there and do not mistakenly mix source and target device
+ * Be careful here and do not mistakenly mix source and target device
  * port sizes constants, they are really different:
  * %CCR_SSIZ_8, %CCR_SSIZ_16, %CCR_SSIZ_32,
  * %CCR_DSIZ_8, %CCR_DSIZ_16, %CCR_DSIZ_32
@@ -276,8 +279,8 @@ imx_dma_setup_sg(imx_dmach_t dma_ch,
  */
 int
 imx_dma_setup_handlers(imx_dmach_t dma_ch,
-                      void (*irq_handler) (int, void *, struct pt_regs *),
-                      void (*err_handler) (int, void *, struct pt_regs *),
+                      void (*irq_handler) (int, void *),
+                      void (*err_handler) (int, void *, int),
                       void *data)
 {
        struct imx_dma_channel *imxdma = &imx_dma_channels[dma_ch];
@@ -285,7 +288,7 @@ imx_dma_setup_handlers(imx_dmach_t dma_ch,
 
        if (!imxdma->name) {
                printk(KERN_CRIT "%s: called for  not allocated channel %d\n",
-                      __FUNCTION__, dma_ch);
+                      __func__, dma_ch);
                return -ENODEV;
        }
 
@@ -318,7 +321,7 @@ void imx_dma_enable(imx_dmach_t dma_ch)
 
        if (!imxdma->name) {
                printk(KERN_CRIT "%s: called for  not allocated channel %d\n",
-                      __FUNCTION__, dma_ch);
+                      __func__, dma_ch);
                return;
        }
 
@@ -362,7 +365,7 @@ int imx_dma_request(imx_dmach_t dma_ch, const char *name)
 
        if (dma_ch >= IMX_DMA_CHANNELS) {
                printk(KERN_CRIT "%s: called for  non-existed channel %d\n",
-                      __FUNCTION__, dma_ch);
+                      __func__, dma_ch);
                return -EINVAL;
        }
 
@@ -393,7 +396,7 @@ void imx_dma_free(imx_dmach_t dma_ch)
        if (!imxdma->name) {
                printk(KERN_CRIT
                       "%s: trying to free channel %d which is already freed\n",
-                      __FUNCTION__, dma_ch);
+                      __func__, dma_ch);
                return;
        }
 
@@ -453,58 +456,68 @@ imx_dma_request_by_prio(imx_dmach_t * pdma_ch, const char *name,
                }
        }
 
-       printk(KERN_ERR "%s: no free DMA channel found\n", __FUNCTION__);
+       printk(KERN_ERR "%s: no free DMA channel found\n", __func__);
 
        return -ENODEV;
 }
 
-static irqreturn_t dma_err_handler(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t dma_err_handler(int irq, void *dev_id)
 {
        int i, disr = DISR;
        struct imx_dma_channel *channel;
        unsigned int err_mask = DBTOSR | DRTOSR | DSESR | DBOSR;
+       int errcode;
 
-       DISR = disr;
+       DISR = disr & err_mask;
        for (i = 0; i < IMX_DMA_CHANNELS; i++) {
-               channel = &imx_dma_channels[i];
-
-               if ((err_mask & 1 << i) && channel->name
-                   && channel->err_handler) {
-                       channel->err_handler(i, channel->data, regs);
+               if(!(err_mask & (1 << i)))
                        continue;
-               }
-
-               imx_dma_channels[i].sg = NULL;
+               channel = &imx_dma_channels[i];
+               errcode = 0;
 
                if (DBTOSR & (1 << i)) {
-                       printk(KERN_WARNING
-                              "Burst timeout on channel %d (%s)\n",
-                              i, channel->name);
-                       DBTOSR |= (1 << i);
+                       DBTOSR = (1 << i);
+                       errcode |= IMX_DMA_ERR_BURST;
                }
                if (DRTOSR & (1 << i)) {
-                       printk(KERN_WARNING
-                              "Request timeout on channel %d (%s)\n",
-                              i, channel->name);
-                       DRTOSR |= (1 << i);
+                       DRTOSR = (1 << i);
+                       errcode |= IMX_DMA_ERR_REQUEST;
                }
                if (DSESR & (1 << i)) {
-                       printk(KERN_WARNING
-                              "Transfer timeout on channel %d (%s)\n",
-                              i, channel->name);
-                       DSESR |= (1 << i);
+                       DSESR = (1 << i);
+                       errcode |= IMX_DMA_ERR_TRANSFER;
                }
                if (DBOSR & (1 << i)) {
-                       printk(KERN_WARNING
-                              "Buffer overflow timeout on channel %d (%s)\n",
-                              i, channel->name);
-                       DBOSR |= (1 << i);
+                       DBOSR = (1 << i);
+                       errcode |= IMX_DMA_ERR_BUFFER;
                }
+
+               /*
+                * The cleaning of @sg field would be questionable
+                * there, because its value can help to compute
+                * remaining/transferred bytes count in the handler
+                */
+               /*imx_dma_channels[i].sg = NULL;*/
+
+               if (channel->name && channel->err_handler) {
+                       channel->err_handler(i, channel->data, errcode);
+                       continue;
+               }
+
+               imx_dma_channels[i].sg = NULL;
+
+               printk(KERN_WARNING
+                      "DMA timeout on channel %d (%s) -%s%s%s%s\n",
+                      i, channel->name,
+                      errcode&IMX_DMA_ERR_BURST?    " burst":"",
+                      errcode&IMX_DMA_ERR_REQUEST?  " request":"",
+                      errcode&IMX_DMA_ERR_TRANSFER? " transfer":"",
+                      errcode&IMX_DMA_ERR_BUFFER?   " buffer":"");
        }
        return IRQ_HANDLED;
 }
 
-static irqreturn_t dma_irq_handler(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t dma_irq_handler(int irq, void *dev_id)
 {
        int i, disr = DISR;
 
@@ -523,7 +536,7 @@ static irqreturn_t dma_irq_handler(int irq, void *dev_id, struct pt_regs *regs)
                                } else {
                                        if (channel->irq_handler)
                                                channel->irq_handler(i,
-                                                       channel->data, regs);
+                                                       channel->data);
                                }
                        } else {
                                /*