From patchwork Tue Oct 9 05:54:13 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Len Brown X-Patchwork-Id: 1568391 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 7512C3FE80 for ; Tue, 9 Oct 2012 06:06:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751726Ab2JIGGA (ORCPT ); Tue, 9 Oct 2012 02:06:00 -0400 Received: from mail-qa0-f46.google.com ([209.85.216.46]:49201 "EHLO mail-qa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753155Ab2JIGDe (ORCPT ); Tue, 9 Oct 2012 02:03:34 -0400 Received: by mail-qa0-f46.google.com with SMTP id c26so2928969qad.19 for ; Mon, 08 Oct 2012 23:03:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:in-reply-to:references:reply-to:organization; bh=sS4OthrqZ7/Yp6Z1AAxERaZF9hS0+qWJSWOZQOYHHEc=; b=VWg8AkCR2PtDoeuY0/JQFwecoEzCCbPPisJeXgndFiGWr8LWAIIwpNS5MzrjqiawC9 6NgrJhTbTEUDGhmJkuH5MeG1zrtOWK1d6rVamMgLhVTIgTlMdcqeEgh+JMZnugDMp1/w KMWIw0oilAbCwfyriYEMQ2EaUHeG1I3cdzHoZu7N6S/gsZ6bdQlNpd9zIj51Z8Hsm1jv bK9Z+JXHgNK3a2QRhEiZL+EtjSkXpPL5rE5W7NG4BSRyQvaAeC1bK30jxW+q5GNfLOgL 0TX6UubmBd3+gAKSKBIdTeqeKhN7QCuaH05VrLeXjFZdUst/vpnUsSJPpqn+xGCdL+lO 2X3Q== Received: by 10.49.129.201 with SMTP id ny9mr46328215qeb.37.1349762613718; Mon, 08 Oct 2012 23:03:33 -0700 (PDT) Received: from x980.localdomain6 (pool-74-104-146-186.bstnma.fios.verizon.net. [74.104.146.186]) by mx.google.com with ESMTPS id ck11sm20206037qab.17.2012.10.08.23.03.32 (version=SSLv3 cipher=OTHER); Mon, 08 Oct 2012 23:03:33 -0700 (PDT) From: Len Brown To: linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Amit Daniel Kachhap , Sachin Kamat , Sachin Kamat , Zhang Rui Subject: [PATCH 23/30] thermal: exynos: Use devm_* functions Date: Tue, 9 Oct 2012 01:54:13 -0400 Message-Id: <79e093c3fe9de9fe0743a53e4809f481d2719060.1349761836.git.len.brown@intel.com> X-Mailer: git-send-email 1.8.0.rc1 In-Reply-To: <1349762060-25334-1-git-send-email-lenb@kernel.org> References: <1349762060-25334-1-git-send-email-lenb@kernel.org> In-Reply-To: References: Reply-To: Len Brown Organization: Intel Open Source Technology Center Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Amit Daniel Kachhap 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 Signed-off-by: Amit Daniel Kachhap Signed-off-by: Zhang Rui --- drivers/thermal/exynos_thermal.c | 45 ++++++++-------------------------------- 1 file changed, 9 insertions(+), 36 deletions(-) diff --git a/drivers/thermal/exynos_thermal.c b/drivers/thermal/exynos_thermal.c index 03a99e4..e84acde 100644 --- a/drivers/thermal/exynos_thermal.c +++ b/drivers/thermal/exynos_thermal.c @@ -842,7 +842,8 @@ 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; @@ -850,47 +851,35 @@ 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; + return -ENOENT; } - 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)); + data->base = devm_request_and_ioremap(&pdev->dev, data->mem); if (!data->base) { - ret = -ENODEV; dev_err(&pdev->dev, "Failed to ioremap memory\n"); - goto err_mem_region; + 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_EXYNOS || @@ -942,15 +931,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; } @@ -964,15 +944,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; }