Commit cd3b3449 authored by Tomi Valkeinen's avatar Tomi Valkeinen

OMAPDSS: cleanup probe functions

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: default avatarTomi Valkeinen <tomi.valkeinen@ti.com>
parent 3f60db4b
...@@ -3341,15 +3341,6 @@ static int omap_dispchw_probe(struct platform_device *pdev) ...@@ -3341,15 +3341,6 @@ static int omap_dispchw_probe(struct platform_device *pdev)
dispc.pdev = 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); spin_lock_init(&dispc.irq_lock);
#ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
...@@ -3362,30 +3353,38 @@ static int omap_dispchw_probe(struct platform_device *pdev) ...@@ -3362,30 +3353,38 @@ static int omap_dispchw_probe(struct platform_device *pdev)
dispc_mem = platform_get_resource(dispc.pdev, IORESOURCE_MEM, 0); dispc_mem = platform_get_resource(dispc.pdev, IORESOURCE_MEM, 0);
if (!dispc_mem) { if (!dispc_mem) {
DSSERR("can't get IORESOURCE_MEM DISPC\n"); DSSERR("can't get IORESOURCE_MEM DISPC\n");
r = -EINVAL; return -EINVAL;
goto err_ioremap;
} }
dispc.base = devm_ioremap(&pdev->dev, dispc_mem->start, dispc.base = devm_ioremap(&pdev->dev, dispc_mem->start,
resource_size(dispc_mem)); resource_size(dispc_mem));
if (!dispc.base) { if (!dispc.base) {
DSSERR("can't ioremap DISPC\n"); DSSERR("can't ioremap DISPC\n");
r = -ENOMEM; return -ENOMEM;
goto err_ioremap;
} }
dispc.irq = platform_get_irq(dispc.pdev, 0); dispc.irq = platform_get_irq(dispc.pdev, 0);
if (dispc.irq < 0) { if (dispc.irq < 0) {
DSSERR("platform_get_irq failed\n"); DSSERR("platform_get_irq failed\n");
r = -ENODEV; return -ENODEV;
goto err_ioremap;
} }
r = devm_request_irq(&pdev->dev, dispc.irq, omap_dispc_irq_handler, r = devm_request_irq(&pdev->dev, dispc.irq, omap_dispc_irq_handler,
IRQF_SHARED, "OMAP DISPC", dispc.pdev); IRQF_SHARED, "OMAP DISPC", dispc.pdev);
if (r < 0) { if (r < 0) {
DSSERR("request_irq failed\n"); 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); pm_runtime_enable(&pdev->dev);
r = dispc_runtime_get(); r = dispc_runtime_get();
...@@ -3406,9 +3405,7 @@ static int omap_dispchw_probe(struct platform_device *pdev) ...@@ -3406,9 +3405,7 @@ static int omap_dispchw_probe(struct platform_device *pdev)
err_runtime_get: err_runtime_get:
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
err_ioremap:
clk_put(dispc.dss_clk); clk_put(dispc.dss_clk);
err_get_clk:
return r; return r;
} }
......
...@@ -4688,10 +4688,8 @@ static int omap_dsihw_probe(struct platform_device *dsidev) ...@@ -4688,10 +4688,8 @@ static int omap_dsihw_probe(struct platform_device *dsidev)
struct dsi_data *dsi; struct dsi_data *dsi;
dsi = devm_kzalloc(&dsidev->dev, sizeof(*dsi), GFP_KERNEL); dsi = devm_kzalloc(&dsidev->dev, sizeof(*dsi), GFP_KERNEL);
if (!dsi) { if (!dsi)
r = -ENOMEM; return -ENOMEM;
goto err_alloc;
}
dsi->pdev = dsidev; dsi->pdev = dsidev;
dsi_pdev_map[dsi_module] = dsidev; dsi_pdev_map[dsi_module] = dsidev;
...@@ -4714,12 +4712,6 @@ static int omap_dsihw_probe(struct platform_device *dsidev) ...@@ -4714,12 +4712,6 @@ static int omap_dsihw_probe(struct platform_device *dsidev)
mutex_init(&dsi->lock); mutex_init(&dsi->lock);
sema_init(&dsi->bus_lock, 1); 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, INIT_DELAYED_WORK_DEFERRABLE(&dsi->framedone_timeout_work,
dsi_framedone_timeout_work_callback); dsi_framedone_timeout_work_callback);
...@@ -4731,28 +4723,27 @@ static int omap_dsihw_probe(struct platform_device *dsidev) ...@@ -4731,28 +4723,27 @@ static int omap_dsihw_probe(struct platform_device *dsidev)
dsi_mem = platform_get_resource(dsi->pdev, IORESOURCE_MEM, 0); dsi_mem = platform_get_resource(dsi->pdev, IORESOURCE_MEM, 0);
if (!dsi_mem) { if (!dsi_mem) {
DSSERR("can't get IORESOURCE_MEM DSI\n"); DSSERR("can't get IORESOURCE_MEM DSI\n");
r = -EINVAL; return -EINVAL;
goto err_ioremap;
} }
dsi->base = devm_ioremap(&dsidev->dev, dsi_mem->start, dsi->base = devm_ioremap(&dsidev->dev, dsi_mem->start,
resource_size(dsi_mem)); resource_size(dsi_mem));
if (!dsi->base) { if (!dsi->base) {
DSSERR("can't ioremap DSI\n"); DSSERR("can't ioremap DSI\n");
r = -ENOMEM; return -ENOMEM;
goto err_ioremap;
} }
dsi->irq = platform_get_irq(dsi->pdev, 0); dsi->irq = platform_get_irq(dsi->pdev, 0);
if (dsi->irq < 0) { if (dsi->irq < 0) {
DSSERR("platform_get_irq failed\n"); DSSERR("platform_get_irq failed\n");
r = -ENODEV; return -ENODEV;
goto err_ioremap;
} }
r = devm_request_irq(&dsidev->dev, dsi->irq, omap_dsi_irq_handler, r = devm_request_irq(&dsidev->dev, dsi->irq, omap_dsi_irq_handler,
IRQF_SHARED, dev_name(&dsidev->dev), dsi->pdev); IRQF_SHARED, dev_name(&dsidev->dev), dsi->pdev);
if (r < 0) { if (r < 0) {
DSSERR("request_irq failed\n"); DSSERR("request_irq failed\n");
goto err_ioremap; return r;
} }
/* DSI VCs initialization */ /* DSI VCs initialization */
...@@ -4764,9 +4755,15 @@ static int omap_dsihw_probe(struct platform_device *dsidev) ...@@ -4764,9 +4755,15 @@ static int omap_dsihw_probe(struct platform_device *dsidev)
dsi_calc_clock_param_ranges(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); r = dsi_runtime_get(dsidev);
if (r) if (r)
goto err_ioremap; goto err_runtime_get;
rev = dsi_read_reg(dsidev, DSI_REVISION); rev = dsi_read_reg(dsidev, DSI_REVISION);
dev_dbg(&dsidev->dev, "OMAP DSI rev %d.%d\n", dev_dbg(&dsidev->dev, "OMAP DSI rev %d.%d\n",
...@@ -4784,9 +4781,9 @@ static int omap_dsihw_probe(struct platform_device *dsidev) ...@@ -4784,9 +4781,9 @@ static int omap_dsihw_probe(struct platform_device *dsidev)
return 0; return 0;
err_ioremap: err_runtime_get:
pm_runtime_disable(&dsidev->dev); pm_runtime_disable(&dsidev->dev);
err_alloc: dsi_put_clocks(dsidev);
return r; return r;
} }
......
...@@ -748,20 +748,19 @@ static int omap_dsshw_probe(struct platform_device *pdev) ...@@ -748,20 +748,19 @@ static int omap_dsshw_probe(struct platform_device *pdev)
dss_mem = platform_get_resource(dss.pdev, IORESOURCE_MEM, 0); dss_mem = platform_get_resource(dss.pdev, IORESOURCE_MEM, 0);
if (!dss_mem) { if (!dss_mem) {
DSSERR("can't get IORESOURCE_MEM DSS\n"); DSSERR("can't get IORESOURCE_MEM DSS\n");
r = -EINVAL; return -EINVAL;
goto err_ioremap;
} }
dss.base = devm_ioremap(&pdev->dev, dss_mem->start, dss.base = devm_ioremap(&pdev->dev, dss_mem->start,
resource_size(dss_mem)); resource_size(dss_mem));
if (!dss.base) { if (!dss.base) {
DSSERR("can't ioremap DSS\n"); DSSERR("can't ioremap DSS\n");
r = -ENOMEM; return -ENOMEM;
goto err_ioremap;
} }
r = dss_get_clocks(); r = dss_get_clocks();
if (r) if (r)
goto err_ioremap; return r;
pm_runtime_enable(&pdev->dev); pm_runtime_enable(&pdev->dev);
...@@ -809,7 +808,6 @@ static int omap_dsshw_probe(struct platform_device *pdev) ...@@ -809,7 +808,6 @@ static int omap_dsshw_probe(struct platform_device *pdev)
err_runtime_get: err_runtime_get:
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
dss_put_clocks(); dss_put_clocks();
err_ioremap:
return r; return r;
} }
......
...@@ -922,36 +922,34 @@ static int omap_rfbihw_probe(struct platform_device *pdev) ...@@ -922,36 +922,34 @@ static int omap_rfbihw_probe(struct platform_device *pdev)
rfbi_mem = platform_get_resource(rfbi.pdev, IORESOURCE_MEM, 0); rfbi_mem = platform_get_resource(rfbi.pdev, IORESOURCE_MEM, 0);
if (!rfbi_mem) { if (!rfbi_mem) {
DSSERR("can't get IORESOURCE_MEM RFBI\n"); DSSERR("can't get IORESOURCE_MEM RFBI\n");
r = -EINVAL; return -EINVAL;
goto err_ioremap;
} }
rfbi.base = devm_ioremap(&pdev->dev, rfbi_mem->start, rfbi.base = devm_ioremap(&pdev->dev, rfbi_mem->start,
resource_size(rfbi_mem)); resource_size(rfbi_mem));
if (!rfbi.base) { if (!rfbi.base) {
DSSERR("can't ioremap RFBI\n"); DSSERR("can't ioremap RFBI\n");
r = -ENOMEM; return -ENOMEM;
goto err_ioremap;
} }
pm_runtime_enable(&pdev->dev);
r = rfbi_runtime_get();
if (r)
goto err_get_rfbi;
msleep(10);
clk = clk_get(&pdev->dev, "ick"); clk = clk_get(&pdev->dev, "ick");
if (IS_ERR(clk)) { if (IS_ERR(clk)) {
DSSERR("can't get ick\n"); DSSERR("can't get ick\n");
r = PTR_ERR(clk); return PTR_ERR(clk);
goto err_get_ick;
} }
rfbi.l4_khz = clk_get_rate(clk) / 1000; rfbi.l4_khz = clk_get_rate(clk) / 1000;
clk_put(clk); 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); rev = rfbi_read_reg(RFBI_REVISION);
dev_dbg(&pdev->dev, "OMAP RFBI rev %d.%d\n", dev_dbg(&pdev->dev, "OMAP RFBI rev %d.%d\n",
FLD_GET(rev, 7, 4), FLD_GET(rev, 3, 0)); FLD_GET(rev, 7, 4), FLD_GET(rev, 3, 0));
...@@ -960,11 +958,8 @@ static int omap_rfbihw_probe(struct platform_device *pdev) ...@@ -960,11 +958,8 @@ static int omap_rfbihw_probe(struct platform_device *pdev)
return 0; return 0;
err_get_ick: err_runtime_get:
rfbi_runtime_put();
err_get_rfbi:
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
err_ioremap:
return r; return r;
} }
......
...@@ -795,38 +795,41 @@ static int omap_venchw_probe(struct platform_device *pdev) ...@@ -795,38 +795,41 @@ static int omap_venchw_probe(struct platform_device *pdev)
venc_mem = platform_get_resource(venc.pdev, IORESOURCE_MEM, 0); venc_mem = platform_get_resource(venc.pdev, IORESOURCE_MEM, 0);
if (!venc_mem) { if (!venc_mem) {
DSSERR("can't get IORESOURCE_MEM VENC\n"); DSSERR("can't get IORESOURCE_MEM VENC\n");
r = -EINVAL; return -EINVAL;
goto err_ioremap;
} }
venc.base = devm_ioremap(&pdev->dev, venc_mem->start, venc.base = devm_ioremap(&pdev->dev, venc_mem->start,
resource_size(venc_mem)); resource_size(venc_mem));
if (!venc.base) { if (!venc.base) {
DSSERR("can't ioremap VENC\n"); DSSERR("can't ioremap VENC\n");
r = -ENOMEM; return -ENOMEM;
goto err_ioremap;
} }
r = venc_get_clocks(pdev); r = venc_get_clocks(pdev);
if (r) if (r)
goto err_ioremap; return r;
pm_runtime_enable(&pdev->dev); pm_runtime_enable(&pdev->dev);
r = venc_runtime_get(); r = venc_runtime_get();
if (r) if (r)
goto err_get_venc; goto err_runtime_get;
rev_id = (u8)(venc_read_reg(VENC_REV_ID) & 0xff); rev_id = (u8)(venc_read_reg(VENC_REV_ID) & 0xff);
dev_dbg(&pdev->dev, "OMAP VENC rev %d\n", rev_id); dev_dbg(&pdev->dev, "OMAP VENC rev %d\n", rev_id);
venc_runtime_put(); 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); pm_runtime_disable(&pdev->dev);
venc_put_clocks(); venc_put_clocks();
err_ioremap:
return r; return r;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment