From patchwork Fri Aug 31 09:29:20 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "AnilKumar, Chimata" X-Patchwork-Id: 1392131 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 93F653FC85 for ; Fri, 31 Aug 2012 09:30:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752944Ab2HaJas (ORCPT ); Fri, 31 Aug 2012 05:30:48 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:44908 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751799Ab2HaJaq (ORCPT ); Fri, 31 Aug 2012 05:30:46 -0400 Received: from dbdp20.itg.ti.com ([172.24.170.38]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id q7V9TiXt005267; Fri, 31 Aug 2012 04:29:45 -0500 Received: from DBDE70.ent.ti.com (localhost [127.0.0.1]) by dbdp20.itg.ti.com (8.13.8/8.13.8) with ESMTP id q7V9TeFV020853; Fri, 31 Aug 2012 14:59:44 +0530 (IST) Received: from dbdp32.itg.ti.com (172.24.170.251) by dbde70.ent.ti.com (172.24.170.148) with Microsoft SMTP Server id 14.1.323.3; Fri, 31 Aug 2012 14:59:40 +0530 Received: from localhost.localdomain (dbdp20.itg.ti.com [172.24.170.38]) by dbdp32.itg.ti.com (8.13.8/8.13.8) with ESMTP id q7V9TXQ8013319; Fri, 31 Aug 2012 14:59:40 +0530 From: AnilKumar Ch To: CC: , , , , , , , , , AnilKumar Ch Subject: [PATCH 4/5] leds: leds-gpio: adopt pinctrl support Date: Fri, 31 Aug 2012 14:59:20 +0530 Message-ID: <1346405361-29711-5-git-send-email-anilkumar@ti.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1346405361-29711-1-git-send-email-anilkumar@ti.com> References: <1346405361-29711-1-git-send-email-anilkumar@ti.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Adopt pinctrl support to leds-gpio driver, based on the device pointer (leds-gpio) pinctrl driver configure SoC pins to GPIO mode. Signed-off-by: AnilKumar Ch --- drivers/leds/leds-gpio.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c index c032b21..d98dfb9 100644 --- a/drivers/leds/leds-gpio.c +++ b/drivers/leds/leds-gpio.c @@ -20,6 +20,7 @@ #include #include #include +#include struct gpio_led_data { struct led_classdev cdev; @@ -236,14 +237,23 @@ static int __devinit gpio_led_probe(struct platform_device *pdev) { struct gpio_led_platform_data *pdata = pdev->dev.platform_data; struct gpio_leds_priv *priv; - int i, ret = 0; + struct pinctrl *pinctrl; + int i = 0; + int ret = 0; + + pinctrl = devm_pinctrl_get_select_default(&pdev->dev); + if (IS_ERR(pinctrl)) { + return PTR_ERR(pinctrl); + } if (pdata && pdata->num_leds) { priv = devm_kzalloc(&pdev->dev, sizeof_gpio_leds_priv(pdata->num_leds), GFP_KERNEL); - if (!priv) - return -ENOMEM; + if (!priv) { + ret = -ENOMEM; + goto err_pctrl_put; + } priv->num_leds = pdata->num_leds; for (i = 0; i < priv->num_leds; i++) { @@ -254,18 +264,25 @@ 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]); - return ret; + goto err_pctrl_put; } } } else { priv = gpio_leds_create_of(pdev); - if (!priv) - return -ENODEV; + if (!priv) { + ret = -ENODEV; + goto err_del_gpio_led; + } } platform_set_drvdata(pdev, priv); - return 0; +err_pctrl_put: + pinctrl_put(pinctrl); +err_del_gpio_led: + while (--i >= 0) + delete_gpio_led(&priv->leds[i]); + return ret; } static int __devexit gpio_led_remove(struct platform_device *pdev)