From patchwork Wed Jul 4 03:21:36 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 9799 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 9D46023F3C for ; Wed, 4 Jul 2012 03:34:03 +0000 (UTC) Received: from mail-gh0-f180.google.com (mail-gh0-f180.google.com [209.85.160.180]) by fiordland.canonical.com (Postfix) with ESMTP id 23432A18751 for ; Wed, 4 Jul 2012 03:34:03 +0000 (UTC) Received: by ghbz12 with SMTP id z12so6575794ghb.11 for ; Tue, 03 Jul 2012 20:34:02 -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=BcZRl7Z4ohNn9eQZHEW4WjAraAo04AwXjSsQDNZ99gk=; b=Qpqy1taiYqQIB+aCNE2xzJdDYtYjfbx5PLrq+RMZtMigaeNcqHNPjNcaVn6Qz6+Ink 3zM8wJfUpfyQoBXdiZIaczkLlXHKfXxtr2VPGPU/pCJeGSkKrB6scuAfHriS2xPbwcRD F+I9n6xiBzy/8KNTsogF/PwRy/I443OoWmp7Qe5jBIOy4Ao2xBgwWWBAeU6CGkNWw1aN fKCSyv7EyMVcRC9mWnHV8nAS2KaLmurDZhEFKTy1djKi9RvpvMVGxWgT3UlwZWZiilHc XZPg3WcoLOnLVtbaYf7uDT17fpf9xVp9eKVhGJyr5VePYwHFXNRD0RO2cZRfNr1fxoVo ydeQ== Received: by 10.50.160.198 with SMTP id xm6mr10400824igb.0.1341372842290; Tue, 03 Jul 2012 20:34:02 -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 v20csp48792ibb; Tue, 3 Jul 2012 20:34:01 -0700 (PDT) Received: by 10.236.109.229 with SMTP id s65mr23986589yhg.10.1341372841315; Tue, 03 Jul 2012 20:34:01 -0700 (PDT) Received: from mail-gh0-f178.google.com (mail-gh0-f178.google.com [209.85.160.178]) by mx.google.com with ESMTPS id y22si14369379yhd.120.2012.07.03.20.34.01 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 03 Jul 2012 20:34:01 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.178 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) client-ip=209.85.160.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.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 ghbf1 with SMTP id f1so7122690ghb.37 for ; Tue, 03 Jul 2012 20:34:00 -0700 (PDT) Received: by 10.68.220.39 with SMTP id pt7mr13955230pbc.40.1341372840678; Tue, 03 Jul 2012 20:34:00 -0700 (PDT) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id wk3sm16808724pbc.21.2012.07.03.20.33.57 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 03 Jul 2012 20:33:59 -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, dg77.kim@samsung.com Subject: [PATCH][Resend] leds: Use devm_kzalloc in leds-max8997.c file Date: Wed, 4 Jul 2012 08:51:36 +0530 Message-Id: <1341372096-25618-1-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.4.1 X-Gm-Message-State: ALoCoQmzKKDl8r+2UUa3RYuK5sawshOo2QE0rG4Bcflwwk6PIqQilKKX8Lu3FG2jaOQjhjU/Iaos devm_kzalloc() makes code cleanup simpler. Signed-off-by: Sachin Kamat --- drivers/leds/leds-max8997.c | 21 ++++++--------------- 1 files changed, 6 insertions(+), 15 deletions(-) diff --git a/drivers/leds/leds-max8997.c b/drivers/leds/leds-max8997.c index f4c0e37..23143be 100644 --- a/drivers/leds/leds-max8997.c +++ b/drivers/leds/leds-max8997.c @@ -276,11 +276,9 @@ static int __devinit max8997_led_probe(struct platform_device *pdev) return -ENODEV; } - led = kzalloc(sizeof(*led), GFP_KERNEL); - if (led == NULL) { - ret = -ENOMEM; - goto err_mem; - } + led = devm_kzalloc(&pdev->dev, sizeof(*led), GFP_KERNEL); + if (led == NULL) + return -ENOMEM; led->id = pdev->id; snprintf(name, sizeof(name), "max8997-led%d", pdev->id); @@ -315,23 +313,17 @@ static int __devinit max8997_led_probe(struct platform_device *pdev) ret = led_classdev_register(&pdev->dev, &led->cdev); if (ret < 0) - goto err_led; + return ret; ret = device_create_file(led->cdev.dev, &dev_attr_mode); if (ret != 0) { dev_err(&pdev->dev, "failed to create file: %d\n", ret); - goto err_file; + led_classdev_unregister(&led->cdev); + return ret; } return 0; - -err_file: - led_classdev_unregister(&led->cdev); -err_led: - kfree(led); -err_mem: - return ret; } static int __devexit max8997_led_remove(struct platform_device *pdev) @@ -340,7 +332,6 @@ static int __devexit max8997_led_remove(struct platform_device *pdev) device_remove_file(led->cdev.dev, &dev_attr_mode); led_classdev_unregister(&led->cdev); - kfree(led); return 0; }