From patchwork Tue Jun 19 06:17:40 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 9426 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 BE46023DEB for ; Tue, 19 Jun 2012 06:29:32 +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 8DFF1A189D0 for ; Tue, 19 Jun 2012 06:29:32 +0000 (UTC) Received: by mail-yx0-f180.google.com with SMTP id q6so4852718yen.11 for ; Mon, 18 Jun 2012 23:29:32 -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=lSRr7kQmz+rqUx1KCn0mVqWQLlciSNsSuK4pZ3kPqsg=; b=TlP3uAVvUwFJ0yVSuQMX72dU9hcZbe+0Yo7RjAwFAtWyrQf5Q3hDW3qbKBkEycqhYj 5nj9+FfBWTXMI0Rb7/ABJsTKNk2Wm85B39FWHpywtqdTiu/XpHmYlXAJHfny3Rt/W74b Kf2mYA/VF9rmwNpwTtIwm/66eKyGcGrPGHpWwLD2oXrckWjHKbIe5we5MauySXxdq8OO I62dM0fwKz7xZctUwfWeVQtXRM8OKJUfTlnWwZvUHYwg3bpDOnmcdkEW8OqN6Rk781ab NQk0GDiRo8bjOthtudhRwjchH+I2gXb6h3lyNale4VcZoTJoDXf+QKLfGA1ESRJl3Y7y bSGA== Received: by 10.50.46.232 with SMTP id y8mr99285igm.57.1340087372203; Mon, 18 Jun 2012 23:29:32 -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 v20csp108738ibb; Mon, 18 Jun 2012 23:29:31 -0700 (PDT) Received: by 10.68.227.195 with SMTP id sc3mr5186598pbc.104.1340087371382; Mon, 18 Jun 2012 23:29:31 -0700 (PDT) Received: from mail-pb0-f50.google.com (mail-pb0-f50.google.com [209.85.160.50]) by mx.google.com with ESMTPS id tx7si28390399pbc.359.2012.06.18.23.29.31 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 18 Jun 2012 23:29:31 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) client-ip=209.85.160.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.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 pbbrr4 with SMTP id rr4so10677864pbb.37 for ; Mon, 18 Jun 2012 23:29:31 -0700 (PDT) Received: by 10.68.230.68 with SMTP id sw4mr1050438pbc.142.1340087370979; Mon, 18 Jun 2012 23:29:30 -0700 (PDT) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id os1sm26717449pbb.49.2012.06.18.23.29.28 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 18 Jun 2012 23:29:30 -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 2/3] drm/exynos: Use devm_* functions in exynos_hdmi.c Date: Tue, 19 Jun 2012 11:47:40 +0530 Message-Id: <1340086661-12388-2-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: ALoCoQk4/Y6qeCl5vK/OKcYqzv/F59Lf8mwc9oC0p7bXvCbKcFgQCrxfFHDFxFol3qeNjtKmyz1Y 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_hdmi.c | 36 ++++++--------------------------- 1 files changed, 7 insertions(+), 29 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c index a137e9e..5816b0f 100644 --- a/drivers/gpu/drm/exynos/exynos_hdmi.c +++ b/drivers/gpu/drm/exynos/exynos_hdmi.c @@ -63,7 +63,6 @@ struct hdmi_context { bool dvi_mode; struct mutex hdmi_mutex; - struct resource *regs_res; void __iomem *regs; unsigned int external_irq; unsigned int internal_irq; @@ -2280,16 +2279,17 @@ static int __devinit hdmi_probe(struct platform_device *pdev) return -EINVAL; } - 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; } - hdata = kzalloc(sizeof(struct hdmi_context), GFP_KERNEL); + hdata = devm_kzalloc(&pdev->dev, sizeof(struct hdmi_context), + GFP_KERNEL); if (!hdata) { DRM_ERROR("out of memory\n"); - kfree(drm_hdmi_ctx); return -ENOMEM; } @@ -2318,26 +2318,18 @@ static int __devinit hdmi_probe(struct platform_device *pdev) goto err_resource; } - hdata->regs_res = request_mem_region(res->start, resource_size(res), - dev_name(dev)); - if (!hdata->regs_res) { - DRM_ERROR("failed to claim register region\n"); - ret = -ENOENT; - goto err_resource; - } - - hdata->regs = ioremap(res->start, resource_size(res)); + hdata->regs = devm_request_and_ioremap(&pdev->dev, res); if (!hdata->regs) { DRM_ERROR("failed to map registers\n"); ret = -ENXIO; - goto err_req_region; + goto err_resource; } /* DDC i2c driver */ if (i2c_add_driver(&ddc_driver)) { DRM_ERROR("failed to register ddc i2c driver\n"); ret = -ENOENT; - goto err_iomap; + goto err_resource; } hdata->ddc_port = hdmi_ddc; @@ -2398,16 +2390,9 @@ err_hdmiphy: i2c_del_driver(&hdmiphy_driver); err_ddc: i2c_del_driver(&ddc_driver); -err_iomap: - iounmap(hdata->regs); -err_req_region: - release_mem_region(hdata->regs_res->start, - resource_size(hdata->regs_res)); err_resource: hdmi_resources_cleanup(hdata); err_data: - kfree(hdata); - kfree(drm_hdmi_ctx); return ret; } @@ -2425,18 +2410,11 @@ static int __devexit hdmi_remove(struct platform_device *pdev) hdmi_resources_cleanup(hdata); - iounmap(hdata->regs); - - release_mem_region(hdata->regs_res->start, - resource_size(hdata->regs_res)); - /* hdmiphy i2c driver */ i2c_del_driver(&hdmiphy_driver); /* DDC i2c driver */ i2c_del_driver(&ddc_driver); - kfree(hdata); - return 0; }