From patchwork Tue Aug 21 10:05:32 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 10828 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 66B7423E00 for ; Tue, 21 Aug 2012 10:08:08 +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 C5EA5A18499 for ; Tue, 21 Aug 2012 10:07:59 +0000 (UTC) Received: by yhpp61 with SMTP id p61so5982710yhp.11 for ; Tue, 21 Aug 2012 03:08:07 -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=9czJJUBX+pka2Eu3wt665LjtmpYn4kuugZcEJ4MkUpI=; b=gPjCpLuro6Bu8TsmiD2sW+A6iK4qiYdLIeI0JSn4EMSg5e9D/TEN4WFEa6Oh/GcUXS vv9SYLfTyFNcp/coqqlK0pSBp/VxO/mNljmjs7aLwkJNcQ2TwvSmHu+SBCR4L+C62b7J HTWHG7JUSzdn/gTp61ZXlYUDtlKLCGWY0jG2TttzcARJ5pjGft5Y+eN/8we/ryIPNMm8 UHOauTdsGAqauaTk5Gvkp/1NUilmuhdTdOrCk8u7LEHTCeO9B8QYAZenex+o19WGHhot hJnuKSCSogy+NrmVmpjSo5KMvWjHBlsAIbqNSiRklVIZeYMVI8M274zUdjhaiG8hEsFc fulQ== Received: by 10.50.182.162 with SMTP id ef2mr12718284igc.43.1345543686904; Tue, 21 Aug 2012 03:08:06 -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.184.232 with SMTP id ex8csp136300igc; Tue, 21 Aug 2012 03:08:06 -0700 (PDT) Received: by 10.68.218.72 with SMTP id pe8mr37547706pbc.33.1345543686259; Tue, 21 Aug 2012 03:08:06 -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 ip5si2378616pbc.228.2012.08.21.03.08.05 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 21 Aug 2012 03:08:06 -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 pbcmd12 with SMTP id md12so9151207pbc.37 for ; Tue, 21 Aug 2012 03:08:05 -0700 (PDT) Received: by 10.68.132.230 with SMTP id ox6mr27436936pbb.116.1345543685810; Tue, 21 Aug 2012 03:08:05 -0700 (PDT) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id io1sm1134747pbc.67.2012.08.21.03.08.03 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 21 Aug 2012 03:08:05 -0700 (PDT) From: Sachin Kamat To: linux-kernel@vger.kernel.org Cc: myungjoo.ham@samsung.com, sachin.kamat@linaro.org, patches@linaro.org Subject: [PATCH] PM/devfreq: Use devm_* functions in exynos4_bus.c Date: Tue, 21 Aug 2012 15:35:32 +0530 Message-Id: <1345543532-6714-1-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.4.1 X-Gm-Message-State: ALoCoQlIwQVUeNv/x1aLamQRg7wugrrGBwSU4ra1yLOaq3pf3WsaxljQOeNJk0WgZ7th7RkiFkJl devm_* functions are device managed functions and make cleanup code simpler and smaller. devm_kzalloc and devm_regulator_get functions are used. Signed-off-by: Sachin Kamat --- drivers/devfreq/exynos4_bus.c | 41 +++++++++++------------------------------ 1 files changed, 11 insertions(+), 30 deletions(-) diff --git a/drivers/devfreq/exynos4_bus.c b/drivers/devfreq/exynos4_bus.c index 88ddc77..6814531 100644 --- a/drivers/devfreq/exynos4_bus.c +++ b/drivers/devfreq/exynos4_bus.c @@ -987,7 +987,7 @@ static __devinit int exynos4_busfreq_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; int err = 0; - data = kzalloc(sizeof(struct busfreq_data), GFP_KERNEL); + data = devm_kzalloc(&pdev->dev, sizeof(struct busfreq_data), GFP_KERNEL); if (data == NULL) { dev_err(dev, "Cannot allocate memory.\n"); return -ENOMEM; @@ -1012,22 +1012,18 @@ static __devinit int exynos4_busfreq_probe(struct platform_device *pdev) err = -EINVAL; } if (err) - goto err_regulator; + return err; - data->vdd_int = regulator_get(dev, "vdd_int"); + data->vdd_int = devm_regulator_get(dev, "vdd_int"); if (IS_ERR(data->vdd_int)) { dev_err(dev, "Cannot get the regulator \"vdd_int\"\n"); - err = PTR_ERR(data->vdd_int); - goto err_regulator; + return PTR_ERR(data->vdd_int); } if (data->type == TYPE_BUSF_EXYNOS4x12) { - data->vdd_mif = regulator_get(dev, "vdd_mif"); + data->vdd_mif = devm_regulator_get(dev, "vdd_mif"); if (IS_ERR(data->vdd_mif)) { dev_err(dev, "Cannot get the regulator \"vdd_mif\"\n"); - err = PTR_ERR(data->vdd_mif); - regulator_put(data->vdd_int); - goto err_regulator; - + return PTR_ERR(data->vdd_mif); } } @@ -1035,8 +1031,7 @@ static __devinit int exynos4_busfreq_probe(struct platform_device *pdev) if (IS_ERR(opp)) { dev_err(dev, "Invalid initial frequency %lu kHz.\n", exynos4_devfreq_profile.initial_freq); - err = PTR_ERR(opp); - goto err_opp_add; + return PTR_ERR(opp); } data->curr_opp = opp; @@ -1046,29 +1041,19 @@ static __devinit int exynos4_busfreq_probe(struct platform_device *pdev) data->devfreq = devfreq_add_device(dev, &exynos4_devfreq_profile, &devfreq_simple_ondemand, NULL); - if (IS_ERR(data->devfreq)) { - err = PTR_ERR(data->devfreq); - goto err_opp_add; - } + if (IS_ERR(data->devfreq)) + return PTR_ERR(data->devfreq); devfreq_register_opp_notifier(dev, data->devfreq); err = register_pm_notifier(&data->pm_notifier); if (err) { dev_err(dev, "Failed to setup pm notifier\n"); - goto err_devfreq_add; + devfreq_remove_device(data->devfreq); + return err; } return 0; -err_devfreq_add: - devfreq_remove_device(data->devfreq); -err_opp_add: - if (data->vdd_mif) - regulator_put(data->vdd_mif); - regulator_put(data->vdd_int); -err_regulator: - kfree(data); - return err; } static __devexit int exynos4_busfreq_remove(struct platform_device *pdev) @@ -1077,10 +1062,6 @@ static __devexit int exynos4_busfreq_remove(struct platform_device *pdev) unregister_pm_notifier(&data->pm_notifier); devfreq_remove_device(data->devfreq); - regulator_put(data->vdd_int); - if (data->vdd_mif) - regulator_put(data->vdd_mif); - kfree(data); return 0; }