From patchwork Tue Jun 19 06:17:41 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 9427 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 56BDE23DEB for ; Tue, 19 Jun 2012 06:29:36 +0000 (UTC) Received: from mail-ob0-f180.google.com (mail-ob0-f180.google.com [209.85.214.180]) by fiordland.canonical.com (Postfix) with ESMTP id 01C02A189D3 for ; Tue, 19 Jun 2012 06:29:35 +0000 (UTC) Received: by obbuo19 with SMTP id uo19so30870obb.11 for ; Mon, 18 Jun 2012 23:29:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=RxKfx5s3eucPrmJRyCXrvRgSZaeKAyLXc6XkH5bM9Dg=; b=YaA/F+Kvs2ZyJdk3h64ut1KiLNGF6MSgM/bbrVkWBaVKTkSYuMxDsSyh0H1lalMJvK bj2P5wmo7xnytzMMltmzdKenDpx2v8XMPBJKurc+qoDZEmT4qwDyqCyvLzbaG3Xeoolr j8A5nBYUMQsiqzObUFTQ5iDS0uowXk36n8Ij8M+Wcj4YliC3EZUNYkWB9zXr+jRDXZYn je/gOKE6YEdXyaUmESWyFdiGp059zOiMFNA/MtwyhKqtlCm5k8DyZUQXrRR4Pcoi0CTO jJtUXmxmg/sjHUjAmRwJ1xVRRy2HvTODkOKuX2LWczclxpuPsdoycACwsMToqusIuCrm T03w== Received: by 10.50.40.193 with SMTP id z1mr161138igk.0.1340087375228; Mon, 18 Jun 2012 23:29:35 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.24.148 with SMTP id v20csp108741ibb; Mon, 18 Jun 2012 23:29:34 -0700 (PDT) Received: by 10.68.217.166 with SMTP id oz6mr60538595pbc.136.1340087374289; Mon, 18 Jun 2012 23:29:34 -0700 (PDT) Received: from mail-pz0-f50.google.com (mail-pz0-f50.google.com [209.85.210.50]) by mx.google.com with ESMTPS id ss6si31318700pbc.93.2012.06.18.23.29.34 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 18 Jun 2012 23:29:34 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.210.50 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) client-ip=209.85.210.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.210.50 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) smtp.mail=sachin.kamat@linaro.org Received: by mail-pz0-f50.google.com with SMTP id h15so9028443dan.37 for ; Mon, 18 Jun 2012 23:29:34 -0700 (PDT) Received: by 10.68.232.103 with SMTP id tn7mr60129605pbc.86.1340087373848; Mon, 18 Jun 2012 23:29:33 -0700 (PDT) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id os1sm26717449pbb.49.2012.06.18.23.29.31 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 18 Jun 2012 23:29:33 -0700 (PDT) From: Sachin Kamat To: dri-devel@lists.freedesktop.org Cc: inki.dae@samsung.com, airlied@linux.ie, sachin.kamat@linaro.org, patches@linaro.org Subject: [PATCH 3/3] drm/exynos: Use devm_* functions in exynos_mixer.c Date: Tue, 19 Jun 2012 11:47:41 +0530 Message-Id: <1340086661-12388-3-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1340086661-12388-1-git-send-email-sachin.kamat@linaro.org> References: <1340086661-12388-1-git-send-email-sachin.kamat@linaro.org> X-Gm-Message-State: ALoCoQn3pC+tmeVtdgUKnSKTFeJ0vuqHLibQ8uIh5tRzAEzcyRVIv+dR4UWHIDCxf9FAq5SoD9X/ devm_* functions are device managed functions and make error handling and cleanup cleaner and simpler. Signed-off-by: Sachin Kamat Signed-off-by: Sachin Kamat --- drivers/gpu/drm/exynos/exynos_mixer.c | 48 +++++++++----------------------- 1 files changed, 14 insertions(+), 34 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c index e2147a2..30fcc12 100644 --- a/drivers/gpu/drm/exynos/exynos_mixer.c +++ b/drivers/gpu/drm/exynos/exynos_mixer.c @@ -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); - 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) { dev_err(dev, "register mapping failed.\n"); ret = -ENXIO; @@ -967,38 +968,34 @@ static int __devinit mixer_resources_init(struct exynos_drm_hdmi_context *ctx, if (res == NULL) { dev_err(dev, "get memory resource failed.\n"); 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) { dev_err(dev, "register mapping failed.\n"); ret = -ENXIO; - goto fail_mixer_regs; + goto fail; } res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "irq"); if (res == NULL) { dev_err(dev, "get interrupt resource failed.\n"); 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) { dev_err(dev, "request interrupt failed.\n"); - goto fail_vp_regs; + goto fail; } mixer_res->irq = res->start; return 0; -fail_vp_regs: - iounmap(mixer_res->vp_regs); - -fail_mixer_regs: - iounmap(mixer_res->mixer_regs); - fail: if (!IS_ERR_OR_NULL(mixer_res->sclk_dac)) clk_put(mixer_res->sclk_dac); @@ -1013,16 +1010,6 @@ fail: 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) { struct device *dev = &pdev->dev; @@ -1032,16 +1019,16 @@ static int __devinit mixer_probe(struct platform_device *pdev) 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) { DRM_ERROR("failed to allocate common hdmi context.\n"); return -ENOMEM; } - ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); + ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL); if (!ctx) { DRM_ERROR("failed to alloc mixer context.\n"); - kfree(drm_hdmi_ctx); return -ENOMEM; } @@ -1072,17 +1059,10 @@ fail: static int mixer_remove(struct platform_device *pdev) { - struct device *dev = &pdev->dev; - 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"); + dev_info(&pdev->dev, "remove successful\n"); pm_runtime_disable(&pdev->dev); - mixer_resources_cleanup(ctx); - return 0; }