From: Inki Dae <inki.dae@samsung.com>
To: 'Sachin Kamat' <sachin.kamat@linaro.org>,
dri-devel@lists.freedesktop.org
Cc: patches@linaro.org
Subject: RE: [PATCH 5/5] drm/exynos: Use devm_* functions in exynos_drm_g2d.c file
Date: Wed, 08 Aug 2012 10:18:47 +0900 [thread overview]
Message-ID: <002801cd7503$cfde0c80$6f9a2580$%dae@samsung.com> (raw)
In-Reply-To: <1344235580-3030-6-git-send-email-sachin.kamat@linaro.org>
> -----Original Message-----
> From: Sachin Kamat [mailto:sachin.kamat@linaro.org]
> Sent: Monday, August 06, 2012 3:46 PM
> To: dri-devel@lists.freedesktop.org
> Cc: inki.dae@samsung.com; airlied@linux.ie; sachin.kamat@linaro.org;
> patches@linaro.org
> Subject: [PATCH 5/5] drm/exynos: Use devm_* functions in exynos_drm_g2d.c
> file
>
> devm_* functions are device managed functions and make error handling
> and cleanup cleaner and simpler.
>
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
> ---
> drivers/gpu/drm/exynos/exynos_drm_g2d.c | 50
++++++---------------------
> ---
> 1 files changed, 10 insertions(+), 40 deletions(-)
>
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_g2d.c
> b/drivers/gpu/drm/exynos/exynos_drm_g2d.c
> index d2d88f2..6adfa4e 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_g2d.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_g2d.c
> @@ -129,7 +129,6 @@ struct g2d_runqueue_node {
> struct g2d_data {
> struct device *dev;
> struct clk *gate_clk;
> - struct resource *regs_res;
> void __iomem *regs;
> int irq;
> struct workqueue_struct *g2d_workq;
> @@ -751,7 +750,7 @@ static int __devinit g2d_probe(struct platform_device
> *pdev)
> struct exynos_drm_subdrv *subdrv;
> int ret;
>
> - g2d = kzalloc(sizeof(*g2d), GFP_KERNEL);
> + g2d = devm_kzalloc(&pdev->dev, sizeof(*g2d), GFP_KERNEL);
> if (!g2d) {
> dev_err(dev, "failed to allocate driver data\n");
> return -ENOMEM;
> @@ -759,10 +758,8 @@ static int __devinit g2d_probe(struct platform_device
> *pdev)
>
> g2d->runqueue_slab = kmem_cache_create("g2d_runqueue_slab",
> sizeof(struct g2d_runqueue_node), 0, 0, NULL);
> - if (!g2d->runqueue_slab) {
> - ret = -ENOMEM;
> - goto err_free_mem;
> - }
> + if (!g2d->runqueue_slab)
> + return -ENOMEM;
>
> g2d->dev = dev;
>
> @@ -794,38 +791,26 @@ static int __devinit g2d_probe(struct
> platform_device *pdev)
> pm_runtime_enable(dev);
>
> res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> - if (!res) {
> - dev_err(dev, "failed to get I/O memory\n");
> - ret = -ENOENT;
> - goto err_put_clk;
> - }
>
> - g2d->regs_res = request_mem_region(res->start, resource_size(res),
> - dev_name(dev));
> - if (!g2d->regs_res) {
> - dev_err(dev, "failed to request I/O memory\n");
> - ret = -ENOENT;
> - goto err_put_clk;
> - }
> -
> - g2d->regs = ioremap(res->start, resource_size(res));
> + g2d->regs = devm_request_and_ioremap(&pdev->dev, res);
> if (!g2d->regs) {
> dev_err(dev, "failed to remap I/O memory\n");
> ret = -ENXIO;
> - goto err_release_res;
> + goto err_put_clk;
> }
>
> g2d->irq = platform_get_irq(pdev, 0);
> if (g2d->irq < 0) {
> dev_err(dev, "failed to get irq\n");
> ret = g2d->irq;
> - goto err_unmap_base;
> + goto err_put_clk;
> }
>
> - ret = request_irq(g2d->irq, g2d_irq_handler, 0, "drm_g2d", g2d);
> + ret = devm_request_irq(&pdev->dev, g2d->irq, g2d_irq_handler, 0,
> + "drm_g2d",
g2d);
> if (ret < 0) {
> dev_err(dev, "irq request failed\n");
> - goto err_unmap_base;
> + goto err_put_clk;
> }
>
> platform_set_drvdata(pdev, g2d);
> @@ -838,7 +823,7 @@ static int __devinit g2d_probe(struct platform_device
> *pdev)
> ret = exynos_drm_subdrv_register(subdrv);
> if (ret < 0) {
> dev_err(dev, "failed to register drm g2d device\n");
> - goto err_free_irq;
> + goto err_put_clk;
> }
>
> dev_info(dev, "The exynos g2d(ver %d.%d) successfully probed\n",
> @@ -846,13 +831,6 @@ static int __devinit g2d_probe(struct platform_device
> *pdev)
>
> return 0;
>
> -err_free_irq:
> - free_irq(g2d->irq, g2d);
> -err_unmap_base:
> - iounmap(g2d->regs);
> -err_release_res:
> - release_resource(g2d->regs_res);
> - kfree(g2d->regs_res);
> err_put_clk:
> pm_runtime_disable(dev);
> clk_put(g2d->gate_clk);
> @@ -862,8 +840,6 @@ err_destroy_workqueue:
> destroy_workqueue(g2d->g2d_workq);
> err_destroy_slab:
> kmem_cache_destroy(g2d->runqueue_slab);
> -err_free_mem:
> - kfree(g2d);
> return ret;
> }
>
> @@ -873,24 +849,18 @@ static int __devexit g2d_remove(struct
> platform_device *pdev)
>
> cancel_work_sync(&g2d->runqueue_work);
> exynos_drm_subdrv_unregister(&g2d->subdrv);
> - free_irq(g2d->irq, g2d);
>
> while (g2d->runqueue_node) {
> g2d_free_runqueue_node(g2d, g2d->runqueue_node);
> g2d->runqueue_node = g2d_get_runqueue_node(g2d);
> }
>
> - iounmap(g2d->regs);
> - release_resource(g2d->regs_res);
> - kfree(g2d->regs_res);
> -
> pm_runtime_disable(&pdev->dev);
> clk_put(g2d->gate_clk);
>
> g2d_fini_cmdlist(g2d);
> destroy_workqueue(g2d->g2d_workq);
> kmem_cache_destroy(g2d->runqueue_slab);
> - kfree(g2d);
>
> return 0;
> }
> --
> 1.7.4.1
Applied.
Thanks for your patch.
prev parent reply other threads:[~2012-08-08 1:18 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-06 6:46 [PATCH 0/5] drm/exynos: Use devm_* functions and cleanup Sachin Kamat
2012-08-06 6:46 ` [PATCH 1/5] drm/exynos: Remove redundant check in exynos_hdmi.c file Sachin Kamat
2012-08-08 1:05 ` Inki Dae
2012-08-06 6:46 ` [PATCH 2/5] drm/exynos: Remove redundant check in exynos_drm_fimd.c file Sachin Kamat
2012-08-08 1:07 ` Inki Dae
2012-08-06 6:46 ` [PATCH 3/5] drm/exynos: Use devm_kzalloc in exynos_drm_vidi.c file Sachin Kamat
2012-08-08 1:08 ` Inki Dae
2012-08-06 6:46 ` [PATCH 4/5] drm/exynos: Use devm_kzalloc in exynos_drm_hdmi.c file Sachin Kamat
2012-08-08 1:09 ` Inki Dae
2012-08-06 6:46 ` [PATCH 5/5] drm/exynos: Use devm_* functions in exynos_drm_g2d.c file Sachin Kamat
2012-08-08 1:18 ` Inki Dae [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='002801cd7503$cfde0c80$6f9a2580$%dae@samsung.com' \
--to=inki.dae@samsung.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=patches@linaro.org \
--cc=sachin.kamat@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox