From patchwork Tue Jun 19 06:17:39 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 9425 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 F243623DEB for ; Tue, 19 Jun 2012 06:29:31 +0000 (UTC) Received: from mail-yx0-f180.google.com (mail-yx0-f180.google.com [209.85.213.180]) by fiordland.canonical.com (Postfix) with ESMTP id 7F72CA189DC for ; Tue, 19 Jun 2012 06:29:31 +0000 (UTC) Received: by yenq6 with SMTP id q6so4852718yen.11 for ; Mon, 18 Jun 2012 23:29:31 -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:x-gm-message-state; bh=FPPvWUbR3MH/LOr5xl26DUEF+9VVBC6juw3L95NT3ek=; b=ZfrVa0yAA0QOOcv9MSDq8VkP5Deh2f8+TNNJXG00d/gDSUQosWvtJuM4oq4Y01101H tcAj7ehV2NzLRaL3KrVnYiOJ3dfzckhvpCacYxOOu9qWVLvmfSAA+uAuECwzq3KP59+x YwJAr8o7jUqkFyflJ348Stld18WvB03SdG3IMXNd9u9Gf7BndhvKknwqYY8tpwGtSlDT V1M0nGnOSaznRoXWfUDKOYzMfxubL6oyJhCpp/3y+ZSLlnKfiXSjq0SKm+jF1TKo3cT0 bZECpFxKzzHqbljPljOPKvCxpNcPM3MkL5RFplUAh9ZnCr+vtnXz5Jzjk3ZftA/k/XKj Jv3w== Received: by 10.50.163.99 with SMTP id yh3mr95451igb.53.1340087370643; Mon, 18 Jun 2012 23:29:30 -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 v20csp108736ibb; Mon, 18 Jun 2012 23:29:29 -0700 (PDT) Received: by 10.68.241.228 with SMTP id wl4mr59372171pbc.51.1340087368672; Mon, 18 Jun 2012 23:29:28 -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.28 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 18 Jun 2012 23:29:28 -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 danh15 with SMTP id h15so9028443dan.37 for ; Mon, 18 Jun 2012 23:29:28 -0700 (PDT) Received: by 10.68.240.69 with SMTP id vy5mr30121169pbc.156.1340087368045; Mon, 18 Jun 2012 23:29:28 -0700 (PDT) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id os1sm26717449pbb.49.2012.06.18.23.29.25 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 18 Jun 2012 23:29:27 -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 1/3] drm/exynos: Use devm_* functions in exynos_drm_fimd.c Date: Tue, 19 Jun 2012 11:47:39 +0530 Message-Id: <1340086661-12388-1-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.4.1 X-Gm-Message-State: ALoCoQkAauN8qU3h0flAV4qsqhQww108bzsMxST+sdH75I7DfaOwJ6ebda2FmRfa44afc7PVlRHU 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_drm_fimd.c | 40 ++++++------------------------ 1 files changed, 8 insertions(+), 32 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c index 29fdbfe..a68d2b3 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c +++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c @@ -78,7 +78,6 @@ struct fimd_context { struct drm_crtc *crtc; struct clk *bus_clk; struct clk *lcd_clk; - struct resource *regs_res; void __iomem *regs; struct fimd_win_data win_data[WINDOWS_NR]; unsigned int clkdiv; @@ -813,7 +812,7 @@ static int __devinit fimd_probe(struct platform_device *pdev) return -EINVAL; } - ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); + ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL); if (!ctx) return -ENOMEM; @@ -838,33 +837,26 @@ static int __devinit fimd_probe(struct platform_device *pdev) goto err_clk; } - ctx->regs_res = request_mem_region(res->start, resource_size(res), - dev_name(dev)); - if (!ctx->regs_res) { - dev_err(dev, "failed to claim register region\n"); - ret = -ENOENT; - goto err_clk; - } - - ctx->regs = ioremap(res->start, resource_size(res)); + ctx->regs = devm_request_and_ioremap(&pdev->dev, res); if (!ctx->regs) { dev_err(dev, "failed to map registers\n"); ret = -ENXIO; - goto err_req_region_io; + goto err_clk; } res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); if (!res) { dev_err(dev, "irq request failed.\n"); - goto err_req_region_irq; + goto err_clk; } ctx->irq = res->start; - ret = request_irq(ctx->irq, fimd_irq_handler, 0, "drm_fimd", ctx); - if (ret < 0) { + ret = devm_request_irq(&pdev->dev, ctx->irq, fimd_irq_handler, + 0, "drm_fimd", ctx); + if (ret) { dev_err(dev, "irq request failed.\n"); - goto err_req_irq; + goto err_clk; } ctx->vidcon0 = pdata->vidcon0; @@ -899,14 +891,6 @@ static int __devinit fimd_probe(struct platform_device *pdev) return 0; -err_req_irq: -err_req_region_irq: - iounmap(ctx->regs); - -err_req_region_io: - release_resource(ctx->regs_res); - kfree(ctx->regs_res); - err_clk: clk_disable(ctx->lcd_clk); clk_put(ctx->lcd_clk); @@ -916,7 +900,6 @@ err_bus_clk: clk_put(ctx->bus_clk); err_clk_get: - kfree(ctx); return ret; } @@ -944,13 +927,6 @@ out: clk_put(ctx->lcd_clk); clk_put(ctx->bus_clk); - iounmap(ctx->regs); - release_resource(ctx->regs_res); - kfree(ctx->regs_res); - free_irq(ctx->irq, ctx); - - kfree(ctx); - return 0; }