From patchwork Fri Jul 13 08:46:27 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 9977 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 2585B23E57 for ; Fri, 13 Jul 2012 08:46:49 +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 CE5F7A181D7 for ; Fri, 13 Jul 2012 08:46:48 +0000 (UTC) Received: by yhpp61 with SMTP id p61so3745023yhp.11 for ; Fri, 13 Jul 2012 01:46:48 -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=UXz/X9IVdcszgIRRZAqPOZCoYQZI6q5sWVzeQbuMeX8=; b=KALZX3Wjbqzhr5mJt9HzGQl8iXzhKJyJPIIWjOAlyidsrKI4TjNkAIqBBDqwIZzqc/ 5XjZzPVIt+z7EZKEfbrhHKvDbs837TtN9bS6+Rd0PORLyi44faPPmUNrFqolAhDEkMo2 HW4eM6q483VPYPrpwvL6UPvJxxismfpTzuRRPEkAgeLA9IiFhxM3qSuF0V6qaAp7bZSM hifSXzHhpHxv1dINq+d9JY/EOyWx2Y9VJTLYEZXtooT7d/BSm5ruhd/TNnrGmy76m4Ff hExLztUyF+qUAQdUCVqDaANQ/KWe02p4/G31gAUQRvmL5dHq2YiNmD07xZW5Ny7YKB6U mdNQ== Received: by 10.42.155.73 with SMTP id t9mr117217icw.48.1342169208097; Fri, 13 Jul 2012 01:46:48 -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.241.2 with SMTP id lc2csp12931ibb; Fri, 13 Jul 2012 01:46:47 -0700 (PDT) Received: by 10.236.80.34 with SMTP id j22mr207997yhe.82.1342169207131; Fri, 13 Jul 2012 01:46:47 -0700 (PDT) Received: from mail-yx0-f178.google.com (mail-yx0-f178.google.com [209.85.213.178]) by mx.google.com with ESMTPS id i49si6558420yhn.128.2012.07.13.01.46.46 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 13 Jul 2012 01:46:47 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.213.178 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) client-ip=209.85.213.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.213.178 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) smtp.mail=sachin.kamat@linaro.org Received: by yenl6 with SMTP id l6so3894080yen.37 for ; Fri, 13 Jul 2012 01:46:46 -0700 (PDT) Received: by 10.68.194.169 with SMTP id hx9mr2284245pbc.8.1342169206402; Fri, 13 Jul 2012 01:46:46 -0700 (PDT) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id od6sm3659348pbb.44.2012.07.13.01.46.44 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 13 Jul 2012 01:46:46 -0700 (PDT) From: Sachin Kamat To: lm-sensors@lm-sensors.org Cc: khali@linux-fr.org, linux@roeck-us.net, sachin.kamat@linaro.org, patches@linaro.org Subject: [PATCH] hwmon: exynos4_tmu: Use devm_* functions Date: Fri, 13 Jul 2012 14:16:27 +0530 Message-Id: <1342169187-3209-1-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.4.1 X-Gm-Message-State: ALoCoQnOClPjBi80IQ0Yo/YZkjyzLHQmdBEiSK2INQifvA2SzX9ZkKalw79RKKxArfrpTkncyOld 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 --- drivers/hwmon/exynos4_tmu.c | 44 ++++++++---------------------------------- 1 files changed, 9 insertions(+), 35 deletions(-) diff --git a/drivers/hwmon/exynos4_tmu.c b/drivers/hwmon/exynos4_tmu.c index e912059..ee6e26c 100644 --- a/drivers/hwmon/exynos4_tmu.c +++ b/drivers/hwmon/exynos4_tmu.c @@ -356,7 +356,8 @@ static int __devinit exynos4_tmu_probe(struct platform_device *pdev) return -ENODEV; } - data = kzalloc(sizeof(struct exynos4_tmu_data), GFP_KERNEL); + data = devm_kzalloc(&pdev->dev, sizeof(struct exynos4_tmu_data), + GFP_KERNEL); if (!data) { dev_err(&pdev->dev, "Failed to allocate driver structure\n"); return -ENOMEM; @@ -364,48 +365,36 @@ static int __devinit exynos4_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, exynos4_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, exynos4_tmu_irq, + ret = devm_request_irq(&pdev->dev, data->irq, exynos4_tmu_irq, IRQF_TRIGGER_RISING, "exynos4-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); } data->pdata = pdata; @@ -440,14 +429,6 @@ err_create_group: 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; } @@ -463,15 +444,8 @@ static int __devexit exynos4_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; }