From patchwork Mon Nov 26 04:09:31 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 13171 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 454FA23E17 for ; Mon, 26 Nov 2012 04:16:25 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id E86CEA1834A for ; Mon, 26 Nov 2012 04:16:24 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id c10so4007790ieb.11 for ; Sun, 25 Nov 2012 20:16:24 -0800 (PST) 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=8tevyDDYW/dTifPcALhIT/XS7eHg4wM0ArsaJzunjaY=; b=b5gfQF7qjkvCAGWcMrVaFImTJd+KXDvnKqYLzMrwxLRHfQ1LhbgIOOMObXWiZoFJD7 44XNuGtoU5tht4RE2IrLYhHHWBjQGfRP0M2wsR31IX/qGsm62/1nL2jnyofhiqX8MTjl bTDdFOrUWkC7x1+8QfRYoFaNV51CHoqqXe88zf/JQsNdOoClvbhUPfn2tECJBivNH4x8 IJ53Jk8cYE518SlBy4ckvlRmwJt2DZs/8tlPFuLTCmkmj90sTbBjZ+JYzI1gQmW8Ear3 3eyagR/g0JsclrpFzQTnOQoacERB6/axuWZJa2INUVJSW4afdOlHKVQQ+zZFtgQVHk0T u6Xg== Received: by 10.43.125.133 with SMTP id gs5mr8705089icc.54.1353903384688; Sun, 25 Nov 2012 20:16:24 -0800 (PST) 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.67.148 with SMTP id n20csp197673igt; Sun, 25 Nov 2012 20:16:24 -0800 (PST) Received: by 10.68.242.9 with SMTP id wm9mr33730848pbc.7.1353903384104; Sun, 25 Nov 2012 20:16:24 -0800 (PST) Received: from mail-pa0-f49.google.com (mail-pa0-f49.google.com [209.85.220.49]) by mx.google.com with ESMTPS id d3si4120534paw.41.2012.11.25.20.16.23 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 25 Nov 2012 20:16:24 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.49 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) client-ip=209.85.220.49; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.49 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-pa0-f49.google.com with SMTP id bi1so5170348pad.22 for ; Sun, 25 Nov 2012 20:16:23 -0800 (PST) Received: by 10.66.85.129 with SMTP id h1mr29494899paz.14.1353903383864; Sun, 25 Nov 2012 20:16:23 -0800 (PST) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id yi9sm8036353pbc.39.2012.11.25.20.16.20 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 25 Nov 2012 20:16:23 -0800 (PST) From: Sachin Kamat To: linux-leds@vger.kernel.org Cc: cooloney@gmail.com, rpurdie@rpsys.net, patches@linaro.org, sachin.kamat@linaro.org, Simon Guinot Subject: [PATCH 03/16] leds: leds-ns2: use devm_gpio_request_one Date: Mon, 26 Nov 2012 09:39:31 +0530 Message-Id: <1353902984-10728-4-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1353902984-10728-1-git-send-email-sachin.kamat@linaro.org> References: <1353902984-10728-1-git-send-email-sachin.kamat@linaro.org> X-Gm-Message-State: ALoCoQmxuTvdsb57YZytweGA9EpTPFVT5d6oJvFmN/6pmqYS5Oo8YLZGq9UjpOcBzAAgHQAneq84 devm_gpio_request_one is device managed and makes error handling and cleanup simpler. Cc: Simon Guinot Signed-off-by: Sachin Kamat --- drivers/leds/leds-ns2.c | 17 +++++------------ 1 files changed, 5 insertions(+), 12 deletions(-) diff --git a/drivers/leds/leds-ns2.c b/drivers/leds/leds-ns2.c index 5df2a25..9505d86 100644 --- a/drivers/leds/leds-ns2.c +++ b/drivers/leds/leds-ns2.c @@ -191,7 +191,7 @@ create_ns2_led(struct platform_device *pdev, struct ns2_led_data *led_dat, int ret; enum ns2_led_modes mode; - ret = gpio_request_one(template->cmd, + ret = devm_gpio_request_one(&pdev->dev, template->cmd, GPIOF_DIR_OUT | gpio_get_value(template->cmd), template->name); if (ret) { @@ -200,13 +200,13 @@ create_ns2_led(struct platform_device *pdev, struct ns2_led_data *led_dat, return ret; } - ret = gpio_request_one(template->slow, + ret = devm_gpio_request_one(&pdev->dev, template->slow, GPIOF_DIR_OUT | gpio_get_value(template->slow), template->name); if (ret) { dev_err(&pdev->dev, "%s: failed to setup slow GPIO\n", template->name); - goto err_free_cmd; + return ret; } rwlock_init(&led_dat->rw_lock); @@ -221,7 +221,7 @@ create_ns2_led(struct platform_device *pdev, struct ns2_led_data *led_dat, ret = ns2_led_get_mode(led_dat, &mode); if (ret < 0) - goto err_free_slow; + return ret; /* Set LED initial state. */ led_dat->sata = (mode == NS_V2_LED_SATA) ? 1 : 0; @@ -230,7 +230,7 @@ create_ns2_led(struct platform_device *pdev, struct ns2_led_data *led_dat, ret = led_classdev_register(&pdev->dev, &led_dat->cdev); if (ret < 0) - goto err_free_slow; + return ret; ret = device_create_file(led_dat->cdev.dev, &dev_attr_sata); if (ret < 0) @@ -240,11 +240,6 @@ create_ns2_led(struct platform_device *pdev, struct ns2_led_data *led_dat, err_free_cdev: led_classdev_unregister(&led_dat->cdev); -err_free_slow: - gpio_free(led_dat->slow); -err_free_cmd: - gpio_free(led_dat->cmd); - return ret; } @@ -252,8 +247,6 @@ static void delete_ns2_led(struct ns2_led_data *led_dat) { device_remove_file(led_dat->cdev.dev, &dev_attr_sata); led_classdev_unregister(&led_dat->cdev); - gpio_free(led_dat->cmd); - gpio_free(led_dat->slow); } static int __devinit ns2_led_probe(struct platform_device *pdev)