From patchwork Tue Aug 7 11:21:05 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 10563 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 94F2B24058 for ; Tue, 7 Aug 2012 11:22:43 +0000 (UTC) Received: from mail-yw0-f52.google.com (mail-yw0-f52.google.com [209.85.213.52]) by fiordland.canonical.com (Postfix) with ESMTP id 47DD2A18120 for ; Tue, 7 Aug 2012 11:22:43 +0000 (UTC) Received: by yhpp61 with SMTP id p61so1651682yhp.11 for ; Tue, 07 Aug 2012 04:22:42 -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=HGnEMjvLxw0KcluanjtixcddgZOZ0f/MEvJbkkz9q3k=; b=YKKQcF9o963jc3OF224DaqmmGQe5ap94ojeC3r8/IdypQN1JpRAd1hf/dAGQRYkhr8 RNnqLHlE6NAN5im/4bFkqo2juakqANVFMPiVMEPaVRs9M7ju1kNmt2HqztyrDUc3RGWO S3C58xhm3yxgoa1JC7KkMfqrgz45pB2uWcDhgI/w7XK1Wvj2yvf/c1ysx9I6ANksraJw P2TOHlGkua4SDbL+uDJ68uilEn/WarXIxvh3wCUgjUqjxEQFpNv198sLPrkzN9TDyjwE sQtAYSM/+Jb6ke68cs8oxiVGl2CBV9GoJsMafGV55lPtrGHgZ8Az0kDhTWdrnvogx6aW X94w== Received: by 10.50.163.5 with SMTP id ye5mr8199421igb.51.1344338562578; Tue, 07 Aug 2012 04:22:42 -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.50.87.40 with SMTP id u8csp492353igz; Tue, 7 Aug 2012 04:22:42 -0700 (PDT) Received: by 10.236.180.8 with SMTP id i8mr2126295yhm.112.1344338561920; Tue, 07 Aug 2012 04:22:41 -0700 (PDT) Received: from mail-yw0-f50.google.com (mail-yw0-f50.google.com [209.85.213.50]) by mx.google.com with ESMTPS id j6si11427873yhe.76.2012.08.07.04.22.41 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 07 Aug 2012 04:22:41 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.213.50 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) client-ip=209.85.213.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.213.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-yw0-f50.google.com with SMTP id j63so4081863yhj.37 for ; Tue, 07 Aug 2012 04:22:41 -0700 (PDT) Received: by 10.66.78.9 with SMTP id x9mr25331646paw.84.1344338561286; Tue, 07 Aug 2012 04:22:41 -0700 (PDT) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id rs4sm7585392pbc.0.2012.08.07.04.22.38 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 07 Aug 2012 04:22:40 -0700 (PDT) From: Sachin Kamat To: linux-kernel@vger.kernel.org Cc: amit.kachhap@linaro.org, dg77.kim@samsung.com, guenter.roeck@ericsson.com, akpm@linux-foundation.org, sachin.kamat@linaro.org, patches@linaro.org Subject: [PATCH 3/3] thermal: Exynos: Use devm_* functions Date: Tue, 7 Aug 2012 16:51:05 +0530 Message-Id: <1344338465-15478-3-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1344338465-15478-1-git-send-email-sachin.kamat@linaro.org> References: <1344338465-15478-1-git-send-email-sachin.kamat@linaro.org> X-Gm-Message-State: ALoCoQncvcImMDIXIhTLgI6KqCdNXWXj5240K1Kd8s/u2UdW9Y6HMVD2idKVZdNW/O/YxIJiJXkH devm_* functions are used to replace kzalloc, request_mem_region, ioremap and request_irq functions in probe call. With the usage of devm_* functions explicit freeing and unmapping is not required. Signed-off-by: Sachin Kamat Signed-off-by: Sachin Kamat --- drivers/thermal/exynos_thermal.c | 51 +++++++------------------------------ 1 files changed, 10 insertions(+), 41 deletions(-) diff --git a/drivers/thermal/exynos_thermal.c b/drivers/thermal/exynos_thermal.c index 3a7a068..86e4e9f 100644 --- a/drivers/thermal/exynos_thermal.c +++ b/drivers/thermal/exynos_thermal.c @@ -780,7 +780,9 @@ static int __devinit exynos_tmu_probe(struct platform_device *pdev) dev_err(&pdev->dev, "No platform init data supplied.\n"); return -ENODEV; } - data = kzalloc(sizeof(struct exynos_tmu_data), GFP_KERNEL); + + data = devm_kzalloc(&pdev->dev, sizeof(struct exynos_tmu_data), + GFP_KERNEL); if (!data) { dev_err(&pdev->dev, "Failed to allocate driver structure\n"); return -ENOMEM; @@ -788,47 +790,29 @@ static int __devinit exynos_tmu_probe(struct platform_device *pdev) data->irq = platform_get_irq(pdev, 0); if (data->irq < 0) { - ret = data->irq; dev_err(&pdev->dev, "Failed to get platform irq\n"); - goto err_free; + return data->irq; } INIT_WORK(&data->irq_work, exynos_tmu_work); data->mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!data->mem) { - ret = -ENOENT; - dev_err(&pdev->dev, "Failed to get platform resource\n"); - goto err_free; - } - data->mem = request_mem_region(data->mem->start, - resource_size(data->mem), pdev->name); - if (!data->mem) { - ret = -ENODEV; - dev_err(&pdev->dev, "Failed to request memory region\n"); - goto err_free; - } - - data->base = ioremap(data->mem->start, resource_size(data->mem)); - if (!data->base) { - ret = -ENODEV; - dev_err(&pdev->dev, "Failed to ioremap memory\n"); - goto err_mem_region; - } + data->base = devm_request_and_ioremap(&pdev->dev, data->mem); + if (!data->base) + return -ENODEV; - ret = request_irq(data->irq, exynos_tmu_irq, + ret = devm_request_irq(&pdev->dev, data->irq, exynos_tmu_irq, IRQF_TRIGGER_RISING, "exynos-tmu", data); if (ret) { dev_err(&pdev->dev, "Failed to request irq: %d\n", data->irq); - goto err_io_remap; + return ret; } data->clk = clk_get(NULL, "tmu_apbif"); if (IS_ERR(data->clk)) { - ret = PTR_ERR(data->clk); dev_err(&pdev->dev, "Failed to get clock\n"); - goto err_irq; + return PTR_ERR(data->clk); } if (pdata->type == SOC_ARCH_EXYNOS5 || @@ -880,14 +864,6 @@ static int __devinit exynos_tmu_probe(struct platform_device *pdev) err_clk: platform_set_drvdata(pdev, NULL); clk_put(data->clk); -err_irq: - free_irq(data->irq, data); -err_io_remap: - iounmap(data->base); -err_mem_region: - release_mem_region(data->mem->start, resource_size(data->mem)); -err_free: - kfree(data); return ret; } @@ -902,15 +878,8 @@ static int __devexit exynos_tmu_remove(struct platform_device *pdev) clk_put(data->clk); - free_irq(data->irq, data); - - iounmap(data->base); - release_mem_region(data->mem->start, resource_size(data->mem)); - platform_set_drvdata(pdev, NULL); - kfree(data); - return 0; }