MLK-14314-9 dma: pxp-v3: refine pxp interrupt init code
authorFancy Fang <chen.fang@nxp.com>
Thu, 13 Apr 2017 10:37:23 +0000 (18:37 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 20:22:09 +0000 (15:22 -0500)
The PXP interrupt functions in V3 is relatively complex.
So do the interrupt initalization in a sperate function
to make the pxp_probe() more clear.

Signed-off-by: Fancy Fang <chen.fang@nxp.com>
(cherry picked from commit 2fa43d26f81cf0331820b41bc198adbb414c0c37)

drivers/dma/pxp/pxp_dma_v3.c

index f489881..e7a88f2 100644 (file)
@@ -5155,25 +5155,59 @@ static int pxp_dispatch_thread(void *argv)
        return 0;
 }
 
+static int pxp_init_interrupt(struct platform_device *pdev)
+{
+       int legacy_irq, std_irq, err;
+       struct pxps *pxp = platform_get_drvdata(pdev);
+
+       legacy_irq = platform_get_irq(pdev, 0);
+       if (legacy_irq < 0) {
+               dev_err(&pdev->dev, "failed to get pxp legacy irq: %d\n",
+                       legacy_irq);
+               return legacy_irq;
+       }
+
+       std_irq = platform_get_irq(pdev, 1);
+       if (std_irq < 0) {
+               dev_err(&pdev->dev, "failed to get pxp standard irq: %d\n",
+                       std_irq);
+               return std_irq;
+       }
+
+       err = devm_request_irq(&pdev->dev, legacy_irq, pxp_irq, 0,
+                               "pxp-dmaengine-legacy", pxp);
+       if (err) {
+               dev_err(&pdev->dev, "Request pxp legacy irq failed: %d\n", err);
+               return err;
+       }
+
+       err = devm_request_irq(&pdev->dev, std_irq, pxp_irq, 0,
+                               "pxp-dmaengine-std", pxp);
+       if (err) {
+               dev_err(&pdev->dev, "Request pxp standard irq failed: %d\n", err);
+               return err;
+       }
+
+       pxp->irq = legacy_irq;
+
+       /* enable all the possible irq raised by PXP */
+       __raw_writel(0xffff, pxp->base + HW_PXP_IRQ_MASK);
+
+       return 0;
+}
+
 static int pxp_probe(struct platform_device *pdev)
 {
        const struct of_device_id *of_id =
                        of_match_device(imx_pxpdma_dt_ids, &pdev->dev);
        struct pxps *pxp;
        struct resource *res;
-       int irq, std_irq;
        int err = 0;
 
        if (of_id)
                pdev->id_entry = of_id->data;
 
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       irq = platform_get_irq(pdev, 0);
-       std_irq = platform_get_irq(pdev, 1);
-       if (!res || irq < 0 || std_irq < 0) {
-               err = -ENODEV;
-               goto exit;
-       }
 
        pxp = devm_kzalloc(&pdev->dev, sizeof(*pxp), GFP_KERNEL);
        if (!pxp) {
@@ -5185,7 +5219,6 @@ static int pxp_probe(struct platform_device *pdev)
        pxp->dev = &pdev->dev;
 
        platform_set_drvdata(pdev, pxp);
-       pxp->irq = irq;
 
        spin_lock_init(&pxp->lock);
        mutex_init(&pxp->clk_mutex);
@@ -5210,14 +5243,9 @@ static int pxp_probe(struct platform_device *pdev)
                goto exit;
        }
 
-       err = devm_request_irq(&pdev->dev, pxp->irq, pxp_irq, 0,
-                               "pxp-dmaengine", pxp);
-       if (err)
-               goto exit;
-
-       err = devm_request_irq(&pdev->dev, std_irq, pxp_irq, 0,
-                               "pxp-dmaengine-std", pxp);
-       if (err)
+       /* Initialize PXP Interrupt */
+       err = pxp_init_interrupt(pdev);
+       if (err < 0)
                goto exit;
 
        /* Initialize DMA engine */
@@ -5236,8 +5264,6 @@ static int pxp_probe(struct platform_device *pdev)
        pxp_soft_reset(pxp);
        if (pxp->devdata && pxp->devdata->pxp_data_path_config)
                pxp->devdata->pxp_data_path_config(pxp);
-       /* enable all the possible irq raised by PXP */
-       __raw_writel(0xffff, pxp->base + HW_PXP_IRQ_MASK);
 
        dump_pxp_reg(pxp);
        pxp_clk_disable(pxp);