From patchwork Wed Jul 4 03:35:44 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 9800 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 1FDC723E47 for ; Wed, 4 Jul 2012 03:48:05 +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 E1698A18533 for ; Wed, 4 Jul 2012 03:48:04 +0000 (UTC) Received: by mail-yw0-f52.google.com with SMTP id p61so7436220yhp.11 for ; Tue, 03 Jul 2012 20:48:04 -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=Q2xoxMjWIAgYKQRlB98C9VqowWMnC0xu1fLBJQ5Jynw=; b=Icb16+UEwk33rDbLLxrMHxeTjLnr/L19nGwaFoiJPf35ZHuFg8Td8jIUqIDglmAUQh qhGZJZOb6fdeG6GqpsVqLDAVlb+L0WCxLqBD9X2XOr1QIPOZx2MIYfM+qVKVLyjaNjR3 snr7tvGM1VdiptyuZTgul7/QVCvK1iAV8ZrcpaAvr1/ykibXItOu2cA7/16/ncQ78qb6 rFjLJl3cPHhyP2SAG7idyrh8zUzTeg0Z5qsSugXBNJ3ivBjtFB3CAqXFfPMbvpkQeM4P k5/ylypOIbTgfjSF2Da+mv9jDNq/cZ3hGgNLGeoh01qtfK7u6O/23KKmXxpt1jB0N6Gd w0Og== Received: by 10.50.57.167 with SMTP id j7mr10186041igq.53.1341373684612; Tue, 03 Jul 2012 20:48:04 -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 v20csp48865ibb; Tue, 3 Jul 2012 20:48:04 -0700 (PDT) Received: by 10.68.220.231 with SMTP id pz7mr13638309pbc.110.1341373683999; Tue, 03 Jul 2012 20:48:03 -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 tm4si11493967pbc.92.2012.07.03.20.48.03 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 03 Jul 2012 20:48:03 -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 pbbrr4 with SMTP id rr4so12222219pbb.37 for ; Tue, 03 Jul 2012 20:48:03 -0700 (PDT) Received: by 10.68.242.7 with SMTP id wm7mr13718638pbc.98.1341373683281; Tue, 03 Jul 2012 20:48:03 -0700 (PDT) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id he9sm16813718pbc.68.2012.07.03.20.47.59 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 03 Jul 2012 20:48:02 -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, raph@8d.com, tpiepho@freescale.com Subject: [PATCH][Resend] leds: Use devm_kzalloc in leds-gpio.c file Date: Wed, 4 Jul 2012 09:05:44 +0530 Message-Id: <1341372944-27145-1-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.4.1 X-Gm-Message-State: ALoCoQkqZVkAuXYrku5WguerKQSW7tJIFEN6jYscs0KUp9vSFR5ZwAtVkNiRtIOl13ssHbPqHIL7 devm_kzalloc() makes cleanup simpler. Signed-off-by: Sachin Kamat --- drivers/leds/leds-gpio.c | 11 +++++------ 1 files changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c index f4c470a..c032b21 100644 --- a/drivers/leds/leds-gpio.c +++ b/drivers/leds/leds-gpio.c @@ -178,7 +178,8 @@ static struct gpio_leds_priv * __devinit gpio_leds_create_of(struct platform_dev if (!count) return NULL; - priv = kzalloc(sizeof_gpio_leds_priv(count), GFP_KERNEL); + priv = devm_kzalloc(&pdev->dev, sizeof_gpio_leds_priv(count), + GFP_KERNEL); if (!priv) return NULL; @@ -215,7 +216,6 @@ static struct gpio_leds_priv * __devinit gpio_leds_create_of(struct platform_dev err: for (count = priv->num_leds - 2; count >= 0; count--) delete_gpio_led(&priv->leds[count]); - kfree(priv); return NULL; } @@ -239,8 +239,9 @@ static int __devinit gpio_led_probe(struct platform_device *pdev) int i, ret = 0; if (pdata && pdata->num_leds) { - priv = kzalloc(sizeof_gpio_leds_priv(pdata->num_leds), - GFP_KERNEL); + priv = devm_kzalloc(&pdev->dev, + sizeof_gpio_leds_priv(pdata->num_leds), + GFP_KERNEL); if (!priv) return -ENOMEM; @@ -253,7 +254,6 @@ static int __devinit gpio_led_probe(struct platform_device *pdev) /* On failure: unwind the led creations */ for (i = i - 1; i >= 0; i--) delete_gpio_led(&priv->leds[i]); - kfree(priv); return ret; } } @@ -277,7 +277,6 @@ static int __devexit gpio_led_remove(struct platform_device *pdev) delete_gpio_led(&priv->leds[i]); dev_set_drvdata(&pdev->dev, NULL); - kfree(priv); return 0; }