Skip to content

Commit

Permalink
OMAPDSS: use devm_ functions
Browse files Browse the repository at this point in the history
The various devm_ functions allocate memory that is released when a driver
detaches.  This patch uses these functions for data that is allocated in
the probe function of a platform device and is only freed in the remove
function.

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
  • Loading branch information
Julia Lawall authored and Tomi Valkeinen committed Jan 25, 2012
1 parent cc1d3e0 commit 6e2a14d
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 43 deletions.
16 changes: 6 additions & 10 deletions drivers/video/omap2/dss/dispc.c
Original file line number Diff line number Diff line change
Expand Up @@ -3322,7 +3322,8 @@ static int omap_dispchw_probe(struct platform_device *pdev)
r = -EINVAL;
goto err_ioremap;
}
dispc.base = ioremap(dispc_mem->start, resource_size(dispc_mem));
dispc.base = devm_ioremap(&pdev->dev, dispc_mem->start,
resource_size(dispc_mem));
if (!dispc.base) {
DSSERR("can't ioremap DISPC\n");
r = -ENOMEM;
Expand All @@ -3332,14 +3333,14 @@ static int omap_dispchw_probe(struct platform_device *pdev)
if (dispc.irq < 0) {
DSSERR("platform_get_irq failed\n");
r = -ENODEV;
goto err_irq;
goto err_ioremap;
}

r = request_irq(dispc.irq, omap_dispc_irq_handler, IRQF_SHARED,
"OMAP DISPC", dispc.pdev);
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_irq;
goto err_ioremap;
}

pm_runtime_enable(&pdev->dev);
Expand All @@ -3362,9 +3363,6 @@ static int omap_dispchw_probe(struct platform_device *pdev)

err_runtime_get:
pm_runtime_disable(&pdev->dev);
free_irq(dispc.irq, dispc.pdev);
err_irq:
iounmap(dispc.base);
err_ioremap:
clk_put(dispc.dss_clk);
err_get_clk:
Expand All @@ -3377,8 +3375,6 @@ static int omap_dispchw_remove(struct platform_device *pdev)

clk_put(dispc.dss_clk);

free_irq(dispc.irq, dispc.pdev);
iounmap(dispc.base);
return 0;
}

Expand Down
28 changes: 9 additions & 19 deletions drivers/video/omap2/dss/dsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -4695,7 +4695,7 @@ static int omap_dsihw_probe(struct platform_device *dsidev)
struct resource *dsi_mem;
struct dsi_data *dsi;

dsi = kzalloc(sizeof(*dsi), GFP_KERNEL);
dsi = devm_kzalloc(&dsidev->dev, sizeof(*dsi), GFP_KERNEL);
if (!dsi) {
r = -ENOMEM;
goto err_alloc;
Expand Down Expand Up @@ -4724,7 +4724,7 @@ static int omap_dsihw_probe(struct platform_device *dsidev)

r = dsi_get_clocks(dsidev);
if (r)
goto err_get_clk;
goto err_alloc;

pm_runtime_enable(&dsidev->dev);

Expand All @@ -4742,7 +4742,8 @@ static int omap_dsihw_probe(struct platform_device *dsidev)
r = -EINVAL;
goto err_ioremap;
}
dsi->base = ioremap(dsi_mem->start, resource_size(dsi_mem));
dsi->base = devm_ioremap(&dsidev->dev, dsi_mem->start,
resource_size(dsi_mem));
if (!dsi->base) {
DSSERR("can't ioremap DSI\n");
r = -ENOMEM;
Expand All @@ -4752,14 +4753,14 @@ static int omap_dsihw_probe(struct platform_device *dsidev)
if (dsi->irq < 0) {
DSSERR("platform_get_irq failed\n");
r = -ENODEV;
goto err_get_irq;
goto err_ioremap;
}

r = request_irq(dsi->irq, omap_dsi_irq_handler, IRQF_SHARED,
dev_name(&dsidev->dev), dsi->pdev);
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_get_irq;
goto err_ioremap;
}

/* DSI VCs initialization */
Expand All @@ -4773,7 +4774,7 @@ static int omap_dsihw_probe(struct platform_device *dsidev)

r = dsi_runtime_get(dsidev);
if (r)
goto err_get_dsi;
goto err_ioremap;

rev = dsi_read_reg(dsidev, DSI_REVISION);
dev_dbg(&dsidev->dev, "OMAP DSI rev %d.%d\n",
Expand All @@ -4791,14 +4792,8 @@ static int omap_dsihw_probe(struct platform_device *dsidev)

return 0;

err_get_dsi:
free_irq(dsi->irq, dsi->pdev);
err_get_irq:
iounmap(dsi->base);
err_ioremap:
pm_runtime_disable(&dsidev->dev);
err_get_clk:
kfree(dsi);
err_alloc:
return r;
}
Expand All @@ -4823,11 +4818,6 @@ static int omap_dsihw_remove(struct platform_device *dsidev)
dsi->vdds_dsi_reg = NULL;
}

free_irq(dsi->irq, dsi->pdev);
iounmap(dsi->base);

kfree(dsi);

return 0;
}

Expand Down
9 changes: 3 additions & 6 deletions drivers/video/omap2/dss/dss.c
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,8 @@ static int omap_dsshw_probe(struct platform_device *pdev)
r = -EINVAL;
goto err_ioremap;
}
dss.base = ioremap(dss_mem->start, resource_size(dss_mem));
dss.base = devm_ioremap(&pdev->dev, dss_mem->start,
resource_size(dss_mem));
if (!dss.base) {
DSSERR("can't ioremap DSS\n");
r = -ENOMEM;
Expand All @@ -760,7 +761,7 @@ static int omap_dsshw_probe(struct platform_device *pdev)

r = dss_get_clocks();
if (r)
goto err_clocks;
goto err_ioremap;

pm_runtime_enable(&pdev->dev);

Expand Down Expand Up @@ -808,8 +809,6 @@ static int omap_dsshw_probe(struct platform_device *pdev)
err_runtime_get:
pm_runtime_disable(&pdev->dev);
dss_put_clocks();
err_clocks:
iounmap(dss.base);
err_ioremap:
return r;
}
Expand All @@ -819,8 +818,6 @@ static int omap_dsshw_remove(struct platform_device *pdev)
dpi_exit();
sdi_exit();

iounmap(dss.base);

pm_runtime_disable(&pdev->dev);

dss_put_clocks();
Expand Down
5 changes: 2 additions & 3 deletions drivers/video/omap2/dss/rfbi.c
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,8 @@ static int omap_rfbihw_probe(struct platform_device *pdev)
r = -EINVAL;
goto err_ioremap;
}
rfbi.base = ioremap(rfbi_mem->start, resource_size(rfbi_mem));
rfbi.base = devm_ioremap(&pdev->dev, rfbi_mem->start,
resource_size(rfbi_mem));
if (!rfbi.base) {
DSSERR("can't ioremap RFBI\n");
r = -ENOMEM;
Expand Down Expand Up @@ -963,15 +964,13 @@ static int omap_rfbihw_probe(struct platform_device *pdev)
rfbi_runtime_put();
err_get_rfbi:
pm_runtime_disable(&pdev->dev);
iounmap(rfbi.base);
err_ioremap:
return r;
}

static int omap_rfbihw_remove(struct platform_device *pdev)
{
pm_runtime_disable(&pdev->dev);
iounmap(rfbi.base);
return 0;
}

Expand Down
8 changes: 3 additions & 5 deletions drivers/video/omap2/dss/venc.c
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,8 @@ static int omap_venchw_probe(struct platform_device *pdev)
r = -EINVAL;
goto err_ioremap;
}
venc.base = ioremap(venc_mem->start, resource_size(venc_mem));
venc.base = devm_ioremap(&pdev->dev, venc_mem->start,
resource_size(venc_mem));
if (!venc.base) {
DSSERR("can't ioremap VENC\n");
r = -ENOMEM;
Expand All @@ -807,7 +808,7 @@ static int omap_venchw_probe(struct platform_device *pdev)

r = venc_get_clocks(pdev);
if (r)
goto err_get_clk;
goto err_ioremap;

pm_runtime_enable(&pdev->dev);

Expand All @@ -825,8 +826,6 @@ static int omap_venchw_probe(struct platform_device *pdev)
err_get_venc:
pm_runtime_disable(&pdev->dev);
venc_put_clocks();
err_get_clk:
iounmap(venc.base);
err_ioremap:
return r;
}
Expand All @@ -842,7 +841,6 @@ static int omap_venchw_remove(struct platform_device *pdev)
pm_runtime_disable(&pdev->dev);
venc_put_clocks();

iounmap(venc.base);
return 0;
}

Expand Down

0 comments on commit 6e2a14d

Please sign in to comment.