From patchwork Thu Aug 16 11:41:45 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kachhap X-Patchwork-Id: 1330951 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 66FD840B1B for ; Thu, 16 Aug 2012 11:43:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753568Ab2HPLml (ORCPT ); Thu, 16 Aug 2012 07:42:41 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:41063 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753445Ab2HPLmk (ORCPT ); Thu, 16 Aug 2012 07:42:40 -0400 Received: by mail-pb0-f46.google.com with SMTP id rr13so1463091pbb.19 for ; Thu, 16 Aug 2012 04:42:38 -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; bh=/4Y51zSC7Qrn+xJWg92uuKiagDtr0OUeHXE5mGBN3eM=; b=wns8tBM4Fq2nY72hzbgk8BlcJIxfA/HNA0QQJV3o2Qll+oNCuGvrj54oJFrXk4CZmH JEL1Y6ZnKDbaBDF4SfThrDrbcPnQal3yyqpRvD4ZdRNWYYTGZJPF9E52jbT7ynaDqRkD Ev4B7lf8Jn0KjRYr4hjQMWUs5IxEQR5YIyiJVhmDus6dWE+zERwqakV2+Xl2+XlW+Ikg C7/g1etkGz94SQFme4HzZxSGrB1gUN3LKOi5ioaC/T/pels0YOHmPl4YJ7rPUxKzblCH FaUPossYDN6+17leRWC0GDv6T1W6kye0jRtsflp7vINQox+EJtIZLa8q69CA0+1/Q7V5 mLyw== Received: by 10.68.195.167 with SMTP id if7mr3013262pbc.50.1345117358497; Thu, 16 Aug 2012 04:42:38 -0700 (PDT) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id b4sm1725495pbw.28.2012.08.16.04.42.34 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 16 Aug 2012 04:42:37 -0700 (PDT) From: Amit Daniel Kachhap To: linux-pm@lists.linux-foundation.org, Andrew Morton , Zhang Rui , Len Brown Cc: linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, lm-sensors@lm-sensors.org, amit.kachhap@linaro.org Subject: [PATCH v6 6/6] thermal: exynos: Use devm_* functions Date: Thu, 16 Aug 2012 17:11:45 +0530 Message-Id: <1345117305-8299-7-git-send-email-amit.kachhap@linaro.org> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1345117305-8299-1-git-send-email-amit.kachhap@linaro.org> References: <1345117305-8299-1-git-send-email-amit.kachhap@linaro.org> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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 --- drivers/thermal/exynos_thermal.c | 45 +++++++------------------------------ 1 files 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; }