ste_dma40: Rename a jump label in d40_alloc_mask_free()
[cascardo/linux.git] / drivers / dma / ste_dma40.c
index e4c5c8b..a4f965f 100644 (file)
@@ -1831,7 +1831,7 @@ static bool d40_alloc_mask_free(struct d40_phy_res *phy, bool is_src,
                phy->allocated_dst = D40_ALLOC_FREE;
                phy->allocated_src = D40_ALLOC_FREE;
                is_free = true;
-               goto out;
+               goto unlock;
        }
 
        /* Logical channel */
@@ -1847,8 +1847,7 @@ static bool d40_alloc_mask_free(struct d40_phy_res *phy, bool is_src,
 
        is_free = ((phy->allocated_src | phy->allocated_dst) ==
                   D40_ALLOC_FREE);
-
-out:
+ unlock:
        spin_unlock_irqrestore(&phy->lock, flags);
 
        return is_free;
@@ -2047,7 +2046,7 @@ static int d40_free_dma(struct d40_chan *d40c)
        res = d40_channel_execute_command(d40c, D40_DMA_STOP);
        if (res) {
                chan_err(d40c, "stop failed\n");
-               goto out;
+               goto mark_last_busy;
        }
 
        d40_alloc_mask_free(phy, is_src, chan_is_logical(d40c) ? event : 0);
@@ -2065,8 +2064,7 @@ static int d40_free_dma(struct d40_chan *d40c)
        d40c->busy = false;
        d40c->phy_chan = NULL;
        d40c->configured = false;
-out:
-
+ mark_last_busy:
        pm_runtime_mark_last_busy(d40c->base->dev);
        pm_runtime_put_autosuspend(d40c->base->dev);
        return res;
@@ -2094,8 +2092,7 @@ static bool d40_is_paused(struct d40_chan *d40c)
                        D40_CHAN_POS(d40c->phy_chan->num);
                if (status == D40_DMA_SUSPENDED || status == D40_DMA_STOP)
                        is_paused = true;
-
-               goto _exit;
+               goto unlock;
        }
 
        if (d40c->dma_cfg.dir == DMA_MEM_TO_DEV ||
@@ -2105,7 +2102,7 @@ static bool d40_is_paused(struct d40_chan *d40c)
                status = readl(chanbase + D40_CHAN_REG_SSLNK);
        } else {
                chan_err(d40c, "Unknown direction\n");
-               goto _exit;
+               goto unlock;
        }
 
        status = (status & D40_EVENTLINE_MASK(event)) >>
@@ -2113,7 +2110,7 @@ static bool d40_is_paused(struct d40_chan *d40c)
 
        if (status != D40_DMA_RUN)
                is_paused = true;
-_exit:
+ unlock:
        spin_unlock_irqrestore(&d40c->lock, flags);
        return is_paused;
 
@@ -2198,7 +2195,7 @@ static struct d40_desc *
 d40_prep_desc(struct d40_chan *chan, struct scatterlist *sg,
              unsigned int sg_len, unsigned long dma_flags)
 {
-       struct stedma40_chan_cfg *cfg = &chan->dma_cfg;
+       struct stedma40_chan_cfg *cfg;
        struct d40_desc *desc;
        int ret;
 
@@ -2206,17 +2203,18 @@ d40_prep_desc(struct d40_chan *chan, struct scatterlist *sg,
        if (!desc)
                return NULL;
 
+       cfg = &chan->dma_cfg;
        desc->lli_len = d40_sg_2_dmalen(sg, sg_len, cfg->src_info.data_width,
                                        cfg->dst_info.data_width);
        if (desc->lli_len < 0) {
                chan_err(chan, "Unaligned size\n");
-               goto err;
+               goto free_desc;
        }
 
        ret = d40_pool_lli_alloc(chan, desc, desc->lli_len);
        if (ret < 0) {
                chan_err(chan, "Could not allocate lli\n");
-               goto err;
+               goto free_desc;
        }
 
        desc->lli_current = 0;
@@ -2226,8 +2224,7 @@ d40_prep_desc(struct d40_chan *chan, struct scatterlist *sg,
        dma_async_tx_descriptor_init(&desc->txd, &chan->chan);
 
        return desc;
-
-err:
+ free_desc:
        d40_desc_free(chan, desc);
        return NULL;
 }
@@ -2238,8 +2235,8 @@ d40_prep_sg(struct dma_chan *dchan, struct scatterlist *sg_src,
            enum dma_transfer_direction direction, unsigned long dma_flags)
 {
        struct d40_chan *chan = container_of(dchan, struct d40_chan, chan);
-       dma_addr_t src_dev_addr = 0;
-       dma_addr_t dst_dev_addr = 0;
+       dma_addr_t src_dev_addr;
+       dma_addr_t dst_dev_addr;
        struct d40_desc *desc;
        unsigned long flags;
        int ret;
@@ -2253,11 +2250,13 @@ d40_prep_sg(struct dma_chan *dchan, struct scatterlist *sg_src,
 
        desc = d40_prep_desc(chan, sg_src, sg_len, dma_flags);
        if (desc == NULL)
-               goto err;
+               goto unlock;
 
        if (sg_next(&sg_src[sg_len - 1]) == sg_src)
                desc->cyclic = true;
 
+       src_dev_addr = 0;
+       dst_dev_addr = 0;
        if (direction == DMA_DEV_TO_MEM)
                src_dev_addr = chan->runtime_addr;
        else if (direction == DMA_MEM_TO_DEV)
@@ -2273,7 +2272,7 @@ d40_prep_sg(struct dma_chan *dchan, struct scatterlist *sg_src,
        if (ret) {
                chan_err(chan, "Failed to prepare %s sg job: %d\n",
                         chan_is_logical(chan) ? "log" : "phy", ret);
-               goto err;
+               goto free_desc;
        }
 
        /*
@@ -2285,10 +2284,9 @@ d40_prep_sg(struct dma_chan *dchan, struct scatterlist *sg_src,
        spin_unlock_irqrestore(&chan->lock, flags);
 
        return &desc->txd;
-
-err:
-       if (desc)
-               d40_desc_free(chan, desc);
+ free_desc:
+       d40_desc_free(chan, desc);
+ unlock:
        spin_unlock_irqrestore(&chan->lock, flags);
        return NULL;
 }
@@ -2426,7 +2424,7 @@ static int d40_alloc_chan_resources(struct dma_chan *chan)
                err = d40_config_memcpy(d40c);
                if (err) {
                        chan_err(d40c, "Failed to configure memcpy channel\n");
-                       goto fail;
+                       goto mark_last_busy;
                }
        }
 
@@ -2434,7 +2432,7 @@ static int d40_alloc_chan_resources(struct dma_chan *chan)
        if (err) {
                chan_err(d40c, "Failed to allocate channel\n");
                d40c->configured = false;
-               goto fail;
+               goto mark_last_busy;
        }
 
        pm_runtime_get_sync(d40c->base->dev);
@@ -2468,7 +2466,7 @@ static int d40_alloc_chan_resources(struct dma_chan *chan)
         */
        if (is_free_phy)
                d40_config_write(d40c);
-fail:
+ mark_last_busy:
        pm_runtime_mark_last_busy(d40c->base->dev);
        pm_runtime_put_autosuspend(d40c->base->dev);
        spin_unlock_irqrestore(&d40c->lock, flags);
@@ -2891,7 +2889,7 @@ static int __init d40_dmaengine_init(struct d40_base *base,
 
        if (err) {
                d40_err(base->dev, "Failed to register slave channels\n");
-               goto failure1;
+               goto exit;
        }
 
        d40_chan_init(base, &base->dma_memcpy, base->log_chans,
@@ -2908,7 +2906,7 @@ static int __init d40_dmaengine_init(struct d40_base *base,
        if (err) {
                d40_err(base->dev,
                        "Failed to register memcpy only channels\n");
-               goto failure2;
+               goto unregister_slave;
        }
 
        d40_chan_init(base, &base->dma_both, base->phy_chans,
@@ -2926,14 +2924,14 @@ static int __init d40_dmaengine_init(struct d40_base *base,
        if (err) {
                d40_err(base->dev,
                        "Failed to register logical and physical capable channels\n");
-               goto failure3;
+               goto unregister_memcpy;
        }
        return 0;
-failure3:
+ unregister_memcpy:
        dma_async_device_unregister(&base->dma_memcpy);
-failure2:
+ unregister_slave:
        dma_async_device_unregister(&base->dma_slave);
-failure1:
+ exit:
        return err;
 }
 
@@ -3144,11 +3142,11 @@ static int __init d40_phy_res_init(struct d40_base *base)
 static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev)
 {
        struct stedma40_platform_data *plat_data = dev_get_platdata(&pdev->dev);
-       struct clk *clk = NULL;
-       void __iomem *virtbase = NULL;
-       struct resource *res = NULL;
-       struct d40_base *base = NULL;
-       int num_log_chans = 0;
+       struct clk *clk;
+       void __iomem *virtbase;
+       struct resource *res;
+       struct d40_base *base;
+       int num_log_chans;
        int num_phy_chans;
        int num_memcpy_chans;
        int clk_ret = -EINVAL;
@@ -3572,7 +3570,7 @@ static int __init d40_probe(struct platform_device *pdev)
        if (!res) {
                ret = -ENOENT;
                d40_err(&pdev->dev, "No \"lcpa\" memory resource\n");
-               goto failure;
+               goto destroy_cache;
        }
        base->lcpa_size = resource_size(res);
        base->phy_lcpa = res->start;
@@ -3581,7 +3579,7 @@ static int __init d40_probe(struct platform_device *pdev)
                               D40_NAME " I/O lcpa") == NULL) {
                ret = -EBUSY;
                d40_err(&pdev->dev, "Failed to request LCPA region %pR\n", res);
-               goto failure;
+               goto destroy_cache;
        }
 
        /* We make use of ESRAM memory for this. */
@@ -3597,7 +3595,7 @@ static int __init d40_probe(struct platform_device *pdev)
        if (!base->lcpa_base) {
                ret = -ENOMEM;
                d40_err(&pdev->dev, "Failed to ioremap LCPA region\n");
-               goto failure;
+               goto destroy_cache;
        }
        /* If lcla has to be located in ESRAM we don't need to allocate */
        if (base->plat_data->use_esram_lcla) {
@@ -3607,14 +3605,14 @@ static int __init d40_probe(struct platform_device *pdev)
                        ret = -ENOENT;
                        d40_err(&pdev->dev,
                                "No \"lcla_esram\" memory resource\n");
-                       goto failure;
+                       goto destroy_cache;
                }
                base->lcla_pool.base = ioremap(res->start,
                                                resource_size(res));
                if (!base->lcla_pool.base) {
                        ret = -ENOMEM;
                        d40_err(&pdev->dev, "Failed to ioremap LCLA region\n");
-                       goto failure;
+                       goto destroy_cache;
                }
                writel(res->start, base->virtbase + D40_DREG_LCLA);
 
@@ -3622,7 +3620,7 @@ static int __init d40_probe(struct platform_device *pdev)
                ret = d40_lcla_allocate(base);
                if (ret) {
                        d40_err(&pdev->dev, "Failed to allocate LCLA area\n");
-                       goto failure;
+                       goto destroy_cache;
                }
        }
 
@@ -3633,7 +3631,7 @@ static int __init d40_probe(struct platform_device *pdev)
        ret = request_irq(base->irq, d40_handle_interrupt, 0, D40_NAME, base);
        if (ret) {
                d40_err(&pdev->dev, "No IRQ defined\n");
-               goto failure;
+               goto destroy_cache;
        }
 
        if (base->plat_data->use_esram_lcla) {
@@ -3643,7 +3641,7 @@ static int __init d40_probe(struct platform_device *pdev)
                        d40_err(&pdev->dev, "Failed to get lcpa_regulator\n");
                        ret = PTR_ERR(base->lcpa_regulator);
                        base->lcpa_regulator = NULL;
-                       goto failure;
+                       goto destroy_cache;
                }
 
                ret = regulator_enable(base->lcpa_regulator);
@@ -3652,7 +3650,7 @@ static int __init d40_probe(struct platform_device *pdev)
                                "Failed to enable lcpa_regulator\n");
                        regulator_put(base->lcpa_regulator);
                        base->lcpa_regulator = NULL;
-                       goto failure;
+                       goto destroy_cache;
                }
        }
 
@@ -3667,13 +3665,13 @@ static int __init d40_probe(struct platform_device *pdev)
 
        ret = d40_dmaengine_init(base, num_reserved_chans);
        if (ret)
-               goto failure;
+               goto destroy_cache;
 
        base->dev->dma_parms = &base->dma_parms;
        ret = dma_set_max_seg_size(base->dev, STEDMA40_MAX_SEG_SIZE);
        if (ret) {
                d40_err(&pdev->dev, "Failed to set dma max seg size\n");
-               goto failure;
+               goto destroy_cache;
        }
 
        d40_hw_init(base);
@@ -3687,8 +3685,7 @@ static int __init d40_probe(struct platform_device *pdev)
 
        dev_info(base->dev, "initialized\n");
        return 0;
-
-failure:
+ destroy_cache:
        kmem_cache_destroy(base->desc_slab);
        if (base->virtbase)
                iounmap(base->virtbase);
@@ -3730,7 +3727,7 @@ failure:
        kfree(base->lookup_phy_chans);
        kfree(base->phy_res);
        kfree(base);
-report_failure:
+ report_failure:
        d40_err(&pdev->dev, "probe failed\n");
        return ret;
 }