]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
OMAPDSS: cleanup probe functions
authorTomi Valkeinen <tomi.valkeinen@ti.com>
Wed, 25 Jan 2012 11:31:04 +0000 (13:31 +0200)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Tue, 21 Feb 2012 07:39:12 +0000 (09:39 +0200)
Now that dss is using devm_ functions for allocation in probe functions,
small reordering of the allocations allows us to clean up the probe
functions more.

This patch moves "unmanaged" allocations after the managed ones, and
uses plain returns instead of gotos where possible. This lets us remove
a bunch of goto labels, simplifying the probe's error handling.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
drivers/video/omap2/dss/dispc.c
drivers/video/omap2/dss/dsi.c
drivers/video/omap2/dss/dss.c
drivers/video/omap2/dss/rfbi.c
drivers/video/omap2/dss/venc.c

index f235798a7ba13e92cbb5019f65cee7d8327ed4c8..d8e044df3d40a20adaa960d476db7cc7eaafe7a0 100644 (file)
@@ -3341,15 +3341,6 @@ static int omap_dispchw_probe(struct platform_device *pdev)
 
        dispc.pdev = pdev;
 
-       clk = clk_get(&pdev->dev, "fck");
-       if (IS_ERR(clk)) {
-               DSSERR("can't get fck\n");
-               r = PTR_ERR(clk);
-               goto err_get_clk;
-       }
-
-       dispc.dss_clk = clk;
-
        spin_lock_init(&dispc.irq_lock);
 
 #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
@@ -3362,30 +3353,38 @@ static int omap_dispchw_probe(struct platform_device *pdev)
        dispc_mem = platform_get_resource(dispc.pdev, IORESOURCE_MEM, 0);
        if (!dispc_mem) {
                DSSERR("can't get IORESOURCE_MEM DISPC\n");
-               r = -EINVAL;
-               goto err_ioremap;
+               return -EINVAL;
        }
+
        dispc.base = devm_ioremap(&pdev->dev, dispc_mem->start,
                                  resource_size(dispc_mem));
        if (!dispc.base) {
                DSSERR("can't ioremap DISPC\n");
-               r = -ENOMEM;
-               goto err_ioremap;
+               return -ENOMEM;
        }
+
        dispc.irq = platform_get_irq(dispc.pdev, 0);
        if (dispc.irq < 0) {
                DSSERR("platform_get_irq failed\n");
-               r = -ENODEV;
-               goto err_ioremap;
+               return -ENODEV;
        }
 
        r = devm_request_irq(&pdev->dev, dispc.irq, omap_dispc_irq_handler,
                             IRQF_SHARED, "OMAP DISPC", dispc.pdev);
        if (r < 0) {
                DSSERR("request_irq failed\n");
-               goto err_ioremap;
+               return r;
+       }
+
+       clk = clk_get(&pdev->dev, "fck");
+       if (IS_ERR(clk)) {
+               DSSERR("can't get fck\n");
+               r = PTR_ERR(clk);
+               return r;
        }
 
+       dispc.dss_clk = clk;
+
        pm_runtime_enable(&pdev->dev);
 
        r = dispc_runtime_get();
@@ -3406,9 +3405,7 @@ static int omap_dispchw_probe(struct platform_device *pdev)
 
 err_runtime_get:
        pm_runtime_disable(&pdev->dev);
-err_ioremap:
        clk_put(dispc.dss_clk);
-err_get_clk:
        return r;
 }
 
index 0330216bd4ec1a5cacf8716e73a14d6ae52d1302..662d14f8c2c382c4bdbe569c33863256314c122a 100644 (file)
@@ -4688,10 +4688,8 @@ static int omap_dsihw_probe(struct platform_device *dsidev)
        struct dsi_data *dsi;
 
        dsi = devm_kzalloc(&dsidev->dev, sizeof(*dsi), GFP_KERNEL);
-       if (!dsi) {
-               r = -ENOMEM;
-               goto err_alloc;
-       }
+       if (!dsi)
+               return -ENOMEM;
 
        dsi->pdev = dsidev;
        dsi_pdev_map[dsi_module] = dsidev;
@@ -4714,12 +4712,6 @@ static int omap_dsihw_probe(struct platform_device *dsidev)
        mutex_init(&dsi->lock);
        sema_init(&dsi->bus_lock, 1);
 
-       r = dsi_get_clocks(dsidev);
-       if (r)
-               goto err_alloc;
-
-       pm_runtime_enable(&dsidev->dev);
-
        INIT_DELAYED_WORK_DEFERRABLE(&dsi->framedone_timeout_work,
                        dsi_framedone_timeout_work_callback);
 
@@ -4731,28 +4723,27 @@ static int omap_dsihw_probe(struct platform_device *dsidev)
        dsi_mem = platform_get_resource(dsi->pdev, IORESOURCE_MEM, 0);
        if (!dsi_mem) {
                DSSERR("can't get IORESOURCE_MEM DSI\n");
-               r = -EINVAL;
-               goto err_ioremap;
+               return -EINVAL;
        }
+
        dsi->base = devm_ioremap(&dsidev->dev, dsi_mem->start,
                                 resource_size(dsi_mem));
        if (!dsi->base) {
                DSSERR("can't ioremap DSI\n");
-               r = -ENOMEM;
-               goto err_ioremap;
+               return -ENOMEM;
        }
+
        dsi->irq = platform_get_irq(dsi->pdev, 0);
        if (dsi->irq < 0) {
                DSSERR("platform_get_irq failed\n");
-               r = -ENODEV;
-               goto err_ioremap;
+               return -ENODEV;
        }
 
        r = devm_request_irq(&dsidev->dev, dsi->irq, omap_dsi_irq_handler,
                             IRQF_SHARED, dev_name(&dsidev->dev), dsi->pdev);
        if (r < 0) {
                DSSERR("request_irq failed\n");
-               goto err_ioremap;
+               return r;
        }
 
        /* DSI VCs initialization */
@@ -4764,9 +4755,15 @@ static int omap_dsihw_probe(struct platform_device *dsidev)
 
        dsi_calc_clock_param_ranges(dsidev);
 
+       r = dsi_get_clocks(dsidev);
+       if (r)
+               return r;
+
+       pm_runtime_enable(&dsidev->dev);
+
        r = dsi_runtime_get(dsidev);
        if (r)
-               goto err_ioremap;
+               goto err_runtime_get;
 
        rev = dsi_read_reg(dsidev, DSI_REVISION);
        dev_dbg(&dsidev->dev, "OMAP DSI rev %d.%d\n",
@@ -4784,9 +4781,9 @@ static int omap_dsihw_probe(struct platform_device *dsidev)
 
        return 0;
 
-err_ioremap:
+err_runtime_get:
        pm_runtime_disable(&dsidev->dev);
-err_alloc:
+       dsi_put_clocks(dsidev);
        return r;
 }
 
index aa2e08968649123811ba6203443b680405f0cd97..4a6b5eeef6a798b2a4dbd060e603a6a8f235ecb9 100644 (file)
@@ -748,20 +748,19 @@ static int omap_dsshw_probe(struct platform_device *pdev)
        dss_mem = platform_get_resource(dss.pdev, IORESOURCE_MEM, 0);
        if (!dss_mem) {
                DSSERR("can't get IORESOURCE_MEM DSS\n");
-               r = -EINVAL;
-               goto err_ioremap;
+               return -EINVAL;
        }
+
        dss.base = devm_ioremap(&pdev->dev, dss_mem->start,
                                resource_size(dss_mem));
        if (!dss.base) {
                DSSERR("can't ioremap DSS\n");
-               r = -ENOMEM;
-               goto err_ioremap;
+               return -ENOMEM;
        }
 
        r = dss_get_clocks();
        if (r)
-               goto err_ioremap;
+               return r;
 
        pm_runtime_enable(&pdev->dev);
 
@@ -809,7 +808,6 @@ err_dpi:
 err_runtime_get:
        pm_runtime_disable(&pdev->dev);
        dss_put_clocks();
-err_ioremap:
        return r;
 }
 
index 7370482b726fb8815e0abb39785f51597100bc05..788a0ef6323aef6e2784244b1825c5b72965abc5 100644 (file)
@@ -922,36 +922,34 @@ static int omap_rfbihw_probe(struct platform_device *pdev)
        rfbi_mem = platform_get_resource(rfbi.pdev, IORESOURCE_MEM, 0);
        if (!rfbi_mem) {
                DSSERR("can't get IORESOURCE_MEM RFBI\n");
-               r = -EINVAL;
-               goto err_ioremap;
+               return -EINVAL;
        }
+
        rfbi.base = devm_ioremap(&pdev->dev, rfbi_mem->start,
                                 resource_size(rfbi_mem));
        if (!rfbi.base) {
                DSSERR("can't ioremap RFBI\n");
-               r = -ENOMEM;
-               goto err_ioremap;
+               return -ENOMEM;
        }
 
-       pm_runtime_enable(&pdev->dev);
-
-       r = rfbi_runtime_get();
-       if (r)
-               goto err_get_rfbi;
-
-       msleep(10);
-
        clk = clk_get(&pdev->dev, "ick");
        if (IS_ERR(clk)) {
                DSSERR("can't get ick\n");
-               r = PTR_ERR(clk);
-               goto err_get_ick;
+               return PTR_ERR(clk);
        }
 
        rfbi.l4_khz = clk_get_rate(clk) / 1000;
 
        clk_put(clk);
 
+       pm_runtime_enable(&pdev->dev);
+
+       r = rfbi_runtime_get();
+       if (r)
+               goto err_runtime_get;
+
+       msleep(10);
+
        rev = rfbi_read_reg(RFBI_REVISION);
        dev_dbg(&pdev->dev, "OMAP RFBI rev %d.%d\n",
               FLD_GET(rev, 7, 4), FLD_GET(rev, 3, 0));
@@ -960,11 +958,8 @@ static int omap_rfbihw_probe(struct platform_device *pdev)
 
        return 0;
 
-err_get_ick:
-       rfbi_runtime_put();
-err_get_rfbi:
+err_runtime_get:
        pm_runtime_disable(&pdev->dev);
-err_ioremap:
        return r;
 }
 
index 967d4432c67bcdf6578e3f2e5e31f7c1a2ceb9ec..9c3daf71750c769057d3a03f05019e950a3b5ed8 100644 (file)
@@ -795,38 +795,41 @@ static int omap_venchw_probe(struct platform_device *pdev)
        venc_mem = platform_get_resource(venc.pdev, IORESOURCE_MEM, 0);
        if (!venc_mem) {
                DSSERR("can't get IORESOURCE_MEM VENC\n");
-               r = -EINVAL;
-               goto err_ioremap;
+               return -EINVAL;
        }
+
        venc.base = devm_ioremap(&pdev->dev, venc_mem->start,
                                 resource_size(venc_mem));
        if (!venc.base) {
                DSSERR("can't ioremap VENC\n");
-               r = -ENOMEM;
-               goto err_ioremap;
+               return -ENOMEM;
        }
 
        r = venc_get_clocks(pdev);
        if (r)
-               goto err_ioremap;
+               return r;
 
        pm_runtime_enable(&pdev->dev);
 
        r = venc_runtime_get();
        if (r)
-               goto err_get_venc;
+               goto err_runtime_get;
 
        rev_id = (u8)(venc_read_reg(VENC_REV_ID) & 0xff);
        dev_dbg(&pdev->dev, "OMAP VENC rev %d\n", rev_id);
 
        venc_runtime_put();
 
-       return omap_dss_register_driver(&venc_driver);
+       r = omap_dss_register_driver(&venc_driver);
+       if (r)
+               goto err_reg_panel_driver;
+
+       return 0;
 
-err_get_venc:
+err_reg_panel_driver:
+err_runtime_get:
        pm_runtime_disable(&pdev->dev);
        venc_put_clocks();
-err_ioremap:
        return r;
 }