From patchwork Tue Jul 3 11:47:54 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 9791 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 A7B6623E2F for ; Tue, 3 Jul 2012 12:00:29 +0000 (UTC) Received: from mail-gg0-f180.google.com (mail-gg0-f180.google.com [209.85.161.180]) by fiordland.canonical.com (Postfix) with ESMTP id 75FB3A183D3 for ; Tue, 3 Jul 2012 12:00:29 +0000 (UTC) Received: by mail-gg0-f180.google.com with SMTP id f1so5586936ggn.11 for ; Tue, 03 Jul 2012 05:00:29 -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=/qpKR90826EFeshbyV3CVvVP2XNsJXVPDF7AolZPLDI=; b=jyhshKkoe9bD0NaNydjxzlpLBJyARvr+gACCT22OoLWfRX6PDtHm3iOgUa42DkRnD9 Vdc5xuu9mNCKTC0/6Sd+v9e24eU/8KJU3HcdDScmWmPKxFwMGH+HzGv9aPiZMlufEQxN FidnCHfRDe1oNHZOVBVYVhcZ78px0OfWa9oHpmGWb+lNPTgsykWZjHve9XeOneu0pDs2 kT9n3taa7lq6DemebGbNyeKz/2gK47hXdMAyHXOzOBCGceepZY9HiHhyxKsyRf6h+grf XKQ+gaRQlOzJV9tSLM6Dc6rMisLjeSqGL0ymIjJA2o28h5GDFQIedAl+obiGqZLyb/K/ X1Bw== Received: by 10.50.203.39 with SMTP id kn7mr9793059igc.53.1341316828985; Tue, 03 Jul 2012 05:00:28 -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.24.148 with SMTP id v20csp38796ibb; Tue, 3 Jul 2012 05:00:28 -0700 (PDT) Received: by 10.66.73.70 with SMTP id j6mr28811492pav.5.1341316828282; Tue, 03 Jul 2012 05:00:28 -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 ms9si23919143pbb.102.2012.07.03.05.00.28 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 03 Jul 2012 05:00:28 -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 mail-pb0-f50.google.com with SMTP id rr4so10881159pbb.37 for ; Tue, 03 Jul 2012 05:00:28 -0700 (PDT) Received: by 10.68.217.226 with SMTP id pb2mr6129758pbc.105.1341316828059; Tue, 03 Jul 2012 05:00:28 -0700 (PDT) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id oo6sm15466531pbc.22.2012.07.03.05.00.25 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 03 Jul 2012 05:00:27 -0700 (PDT) From: Sachin Kamat To: linux-leds@vger.kernel.org Cc: bryan.wu@canonical.com, rpurdie@rpsys.net, sachin.kamat@linaro.org, patches@linaro.org Subject: [PATCH 5/5] leds: Use devm_kzalloc in leds-regulator.c file Date: Tue, 3 Jul 2012 17:17:54 +0530 Message-Id: <1341316074-14886-5-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1341316074-14886-1-git-send-email-sachin.kamat@linaro.org> References: <1341316074-14886-1-git-send-email-sachin.kamat@linaro.org> X-Gm-Message-State: ALoCoQnYy9cWjqKxtN36/oiLtXiY5HAkS8L2fTi63fB1ZkqerXlQYpcc+wE7I8uB/7gwcGOOeOZs devm_kzalloc() makes cleanup simpler. Signed-off-by: Sachin Kamat --- drivers/leds/leds-regulator.c | 9 +++------ 1 files changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/leds/leds-regulator.c b/drivers/leds/leds-regulator.c index df7e963..25d382d 100644 --- a/drivers/leds/leds-regulator.c +++ b/drivers/leds/leds-regulator.c @@ -158,7 +158,7 @@ static int __devinit regulator_led_probe(struct platform_device *pdev) return PTR_ERR(vcc); } - led = kzalloc(sizeof(*led), GFP_KERNEL); + led = devm_kzalloc(&pdev->dev, sizeof(*led), GFP_KERNEL); if (led == NULL) { ret = -ENOMEM; goto err_vcc; @@ -169,7 +169,7 @@ static int __devinit regulator_led_probe(struct platform_device *pdev) dev_err(&pdev->dev, "Invalid default brightness %d\n", pdata->brightness); ret = -EINVAL; - goto err_led; + goto err_vcc; } led->value = pdata->brightness; @@ -190,7 +190,7 @@ static int __devinit regulator_led_probe(struct platform_device *pdev) ret = led_classdev_register(&pdev->dev, &led->cdev); if (ret < 0) { cancel_work_sync(&led->work); - goto err_led; + goto err_vcc; } /* to expose the default value to userspace */ @@ -201,8 +201,6 @@ static int __devinit regulator_led_probe(struct platform_device *pdev) return 0; -err_led: - kfree(led); err_vcc: regulator_put(vcc); return ret; @@ -216,7 +214,6 @@ static int __devexit regulator_led_remove(struct platform_device *pdev) cancel_work_sync(&led->work); regulator_led_disable(led); regulator_put(led->vcc); - kfree(led); return 0; }