From patchwork Fri Dec 13 16:47:02 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nishanth Menon X-Patchwork-Id: 3341641 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5AE7CC0D4A for ; Fri, 13 Dec 2013 16:47:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3FD5B207FD for ; Fri, 13 Dec 2013 16:47:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3FDA420690 for ; Fri, 13 Dec 2013 16:47:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752735Ab3LMQrP (ORCPT ); Fri, 13 Dec 2013 11:47:15 -0500 Received: from bear.ext.ti.com ([192.94.94.41]:34328 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752717Ab3LMQrO (ORCPT ); Fri, 13 Dec 2013 11:47:14 -0500 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id rBDGl5n8016333; Fri, 13 Dec 2013 10:47:05 -0600 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id rBDGl4oE028429; Fri, 13 Dec 2013 10:47:05 -0600 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.2.342.3; Fri, 13 Dec 2013 10:47:04 -0600 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id rBDGl42G032354; Fri, 13 Dec 2013 10:47:04 -0600 From: Nishanth Menon To: Tony Lindgren , Linus Walleij CC: Peter Ujfalusi , Roger Quadros , , , , Nishanth Menon Subject: [PATCH] gpio: twl4030: fix regression for twl gpio outputs for led pins Date: Fri, 13 Dec 2013 10:47:02 -0600 Message-ID: <1386953222-26396-1-git-send-email-nm@ti.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Commit 0b2aa8b (gpio: twl4030: Fix regression for twl gpio output) introduces yet another regression by ignoring the fact that we use twl gpio even for LED. For example, leda (offset 18) is used for USB port2 power on beagleboard-xm. The original logic was supposed to setup the TWL4030 GPIO direction if the offset was < TWL4030_GPIO_MAX, and anything greater used twl4030_led_set_value as part of twl_set to setup the LED pin. However, with the commit mentioned above, LEDa pin request will result in fail as the GPIO number for LEDa is equal to TWL4030_GPIO_MAX and USB fails to function on beagleboard-xm. This is reported in the log as: hsusb2_vbus: Failed to request enable GPIO510: -22 To fix this, we should handle the fail case of twl4030_set_gpio_direction independent of the offset < TWL4030_GPIO_MAX check. Signed-off-by: Nishanth Menon --- Applies on v3.13-rc3 Tested on beagleboard-xm which uses ethernet over usb: before the patch (USB regression): http://pastebin.mozilla.org/3769443 After this patch: http://pastebin.mozilla.org/3769454 drivers/gpio/gpio-twl4030.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/gpio-twl4030.c b/drivers/gpio/gpio-twl4030.c index b97d6a6..9242276 100644 --- a/drivers/gpio/gpio-twl4030.c +++ b/drivers/gpio/gpio-twl4030.c @@ -354,11 +354,16 @@ static void twl_set(struct gpio_chip *chip, unsigned offset, int value) static int twl_direction_out(struct gpio_chip *chip, unsigned offset, int value) { struct gpio_twl4030_priv *priv = to_gpio_twl4030(chip); - int ret = -EINVAL; + int ret = 0; mutex_lock(&priv->mutex); - if (offset < TWL4030_GPIO_MAX) + if (offset < TWL4030_GPIO_MAX) { ret = twl4030_set_gpio_direction(offset, 0); + if (ret) { + mutex_unlock(&priv->mutex); + return ret; + } + } priv->direction |= BIT(offset); mutex_unlock(&priv->mutex);