drm/exynos: Use devm_* functions in exynos_mixer.c

devm_* functions are device managed functions and make error handling
and cleanup cleaner and simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Sachin Kamat <sachin.kamat@samsung.com>
Signed-off-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
This commit is contained in:
Sachin Kamat 2012-06-19 11:47:41 +05:30 committed by Inki Dae
parent a6e6507210
commit 9416dfa76a
1 changed files with 14 additions and 34 deletions

View File

@ -956,7 +956,8 @@ static int __devinit mixer_resources_init(struct exynos_drm_hdmi_context *ctx,
clk_set_parent(mixer_res->sclk_mixer, mixer_res->sclk_hdmi); clk_set_parent(mixer_res->sclk_mixer, mixer_res->sclk_hdmi);
mixer_res->mixer_regs = ioremap(res->start, resource_size(res)); mixer_res->mixer_regs = devm_ioremap(&pdev->dev, res->start,
resource_size(res));
if (mixer_res->mixer_regs == NULL) { if (mixer_res->mixer_regs == NULL) {
dev_err(dev, "register mapping failed.\n"); dev_err(dev, "register mapping failed.\n");
ret = -ENXIO; ret = -ENXIO;
@ -967,38 +968,34 @@ static int __devinit mixer_resources_init(struct exynos_drm_hdmi_context *ctx,
if (res == NULL) { if (res == NULL) {
dev_err(dev, "get memory resource failed.\n"); dev_err(dev, "get memory resource failed.\n");
ret = -ENXIO; ret = -ENXIO;
goto fail_mixer_regs; goto fail;
} }
mixer_res->vp_regs = ioremap(res->start, resource_size(res)); mixer_res->vp_regs = devm_ioremap(&pdev->dev, res->start,
resource_size(res));
if (mixer_res->vp_regs == NULL) { if (mixer_res->vp_regs == NULL) {
dev_err(dev, "register mapping failed.\n"); dev_err(dev, "register mapping failed.\n");
ret = -ENXIO; ret = -ENXIO;
goto fail_mixer_regs; goto fail;
} }
res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "irq"); res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "irq");
if (res == NULL) { if (res == NULL) {
dev_err(dev, "get interrupt resource failed.\n"); dev_err(dev, "get interrupt resource failed.\n");
ret = -ENXIO; ret = -ENXIO;
goto fail_vp_regs; goto fail;
} }
ret = request_irq(res->start, mixer_irq_handler, 0, "drm_mixer", ctx); ret = devm_request_irq(&pdev->dev, res->start, mixer_irq_handler,
0, "drm_mixer", ctx);
if (ret) { if (ret) {
dev_err(dev, "request interrupt failed.\n"); dev_err(dev, "request interrupt failed.\n");
goto fail_vp_regs; goto fail;
} }
mixer_res->irq = res->start; mixer_res->irq = res->start;
return 0; return 0;
fail_vp_regs:
iounmap(mixer_res->vp_regs);
fail_mixer_regs:
iounmap(mixer_res->mixer_regs);
fail: fail:
if (!IS_ERR_OR_NULL(mixer_res->sclk_dac)) if (!IS_ERR_OR_NULL(mixer_res->sclk_dac))
clk_put(mixer_res->sclk_dac); clk_put(mixer_res->sclk_dac);
@ -1013,16 +1010,6 @@ fail:
return ret; return ret;
} }
static void mixer_resources_cleanup(struct mixer_context *ctx)
{
struct mixer_resources *res = &ctx->mixer_res;
free_irq(res->irq, ctx);
iounmap(res->vp_regs);
iounmap(res->mixer_regs);
}
static int __devinit mixer_probe(struct platform_device *pdev) static int __devinit mixer_probe(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
@ -1032,16 +1019,16 @@ static int __devinit mixer_probe(struct platform_device *pdev)
dev_info(dev, "probe start\n"); dev_info(dev, "probe start\n");
drm_hdmi_ctx = kzalloc(sizeof(*drm_hdmi_ctx), GFP_KERNEL); drm_hdmi_ctx = devm_kzalloc(&pdev->dev, sizeof(*drm_hdmi_ctx),
GFP_KERNEL);
if (!drm_hdmi_ctx) { if (!drm_hdmi_ctx) {
DRM_ERROR("failed to allocate common hdmi context.\n"); DRM_ERROR("failed to allocate common hdmi context.\n");
return -ENOMEM; return -ENOMEM;
} }
ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
if (!ctx) { if (!ctx) {
DRM_ERROR("failed to alloc mixer context.\n"); DRM_ERROR("failed to alloc mixer context.\n");
kfree(drm_hdmi_ctx);
return -ENOMEM; return -ENOMEM;
} }
@ -1072,17 +1059,10 @@ fail:
static int mixer_remove(struct platform_device *pdev) static int mixer_remove(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev; dev_info(&pdev->dev, "remove successful\n");
struct exynos_drm_hdmi_context *drm_hdmi_ctx =
platform_get_drvdata(pdev);
struct mixer_context *ctx = drm_hdmi_ctx->ctx;
dev_info(dev, "remove successful\n");
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
mixer_resources_cleanup(ctx);
return 0; return 0;
} }