From patchwork Fri Apr 24 13:48:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 464348 X-Patchwork-Delegate: hdegoede@redhat.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id AF37714011B for ; Sat, 25 Apr 2015 04:02:26 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id BEB47A77B7; Fri, 24 Apr 2015 19:52:20 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ODbUn-ueTFDP; Fri, 24 Apr 2015 19:52:20 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E18394BFB6; Fri, 24 Apr 2015 19:49:17 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B13A64BAA2 for ; Fri, 24 Apr 2015 18:55:39 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id n0zl-jlklPro for ; Fri, 24 Apr 2015 18:55:39 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by theia.denx.de (Postfix) with ESMTPS id 347EA4BAA1 for ; Fri, 24 Apr 2015 18:55:38 +0200 (CEST) Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t3ODmb1V028709 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 24 Apr 2015 09:48:37 -0400 Received: from shalem.localdomain.com (vpn1-5-210.ams2.redhat.com [10.36.5.210]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t3ODmWmg029346; Fri, 24 Apr 2015 09:48:36 -0400 From: Hans de Goede To: Ian Campbell , Simon Glass Date: Fri, 24 Apr 2015 15:48:12 +0200 Message-Id: <1429883310-22441-4-git-send-email-hdegoede@redhat.com> In-Reply-To: <1429883310-22441-1-git-send-email-hdegoede@redhat.com> References: <1429883310-22441-1-git-send-email-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH 03/21] sunxi: usbc: Fix vbus gpio handling to work with the device-model X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The device-model gpio functions may return another value then -1 as error, make the sunxi usbc properly handle this. Signed-off-by: Hans de Goede Reviewed-by: Simon Glass Acked-by: Ian Campbell --- arch/arm/cpu/armv7/sunxi/usbc.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/arch/arm/cpu/armv7/sunxi/usbc.c b/arch/arm/cpu/armv7/sunxi/usbc.c index 515549d..39452a7 100644 --- a/arch/arm/cpu/armv7/sunxi/usbc.c +++ b/arch/arm/cpu/armv7/sunxi/usbc.c @@ -17,6 +17,7 @@ #include #include #include +#include #ifdef CONFIG_AXP152_POWER #include #endif @@ -90,7 +91,7 @@ static int get_vbus_gpio(int index) case 1: return sunxi_name_to_gpio(CONFIG_USB1_VBUS_PIN); case 2: return sunxi_name_to_gpio(CONFIG_USB2_VBUS_PIN); } - return -1; + return -EINVAL; } static int get_vbus_detect_gpio(int index) @@ -187,13 +188,13 @@ int sunxi_usbc_request_resources(int index) int ret = 0; sunxi_usbc->gpio_vbus = get_vbus_gpio(index); - if (sunxi_usbc->gpio_vbus != -1) { + if (sunxi_usbc->gpio_vbus >= 0) { ret |= gpio_request(sunxi_usbc->gpio_vbus, "usbc_vbus"); ret |= gpio_direction_output(sunxi_usbc->gpio_vbus, 0); } sunxi_usbc->gpio_vbus_det = get_vbus_detect_gpio(index); - if (sunxi_usbc->gpio_vbus_det != -1) { + if (sunxi_usbc->gpio_vbus_det >= 0) { ret |= gpio_request(sunxi_usbc->gpio_vbus_det, "usbc_vbus_det"); ret |= gpio_direction_input(sunxi_usbc->gpio_vbus_det); } @@ -206,10 +207,10 @@ int sunxi_usbc_free_resources(int index) struct sunxi_usbc_hcd *sunxi_usbc = &sunxi_usbc_hcd[index]; int ret = 0; - if (sunxi_usbc->gpio_vbus != -1) + if (sunxi_usbc->gpio_vbus >= 0) ret |= gpio_free(sunxi_usbc->gpio_vbus); - if (sunxi_usbc->gpio_vbus_det != -1) + if (sunxi_usbc->gpio_vbus_det >= 0) ret |= gpio_free(sunxi_usbc->gpio_vbus_det); return ret; @@ -263,7 +264,7 @@ void sunxi_usbc_vbus_enable(int index) { struct sunxi_usbc_hcd *sunxi_usbc = &sunxi_usbc_hcd[index]; - if (sunxi_usbc->gpio_vbus != -1) + if (sunxi_usbc->gpio_vbus >= 0) gpio_set_value(sunxi_usbc->gpio_vbus, 1); } @@ -271,7 +272,7 @@ void sunxi_usbc_vbus_disable(int index) { struct sunxi_usbc_hcd *sunxi_usbc = &sunxi_usbc_hcd[index]; - if (sunxi_usbc->gpio_vbus != -1) + if (sunxi_usbc->gpio_vbus >= 0) gpio_set_value(sunxi_usbc->gpio_vbus, 0); } @@ -280,9 +281,9 @@ int sunxi_usbc_vbus_detect(int index) struct sunxi_usbc_hcd *sunxi_usbc = &sunxi_usbc_hcd[index]; int err, retries = 3; - if (sunxi_usbc->gpio_vbus_det == -1) { + if (sunxi_usbc->gpio_vbus_det < 0) { eprintf("Error: invalid vbus detection pin\n"); - return -1; + return sunxi_usbc->gpio_vbus_det; } err = gpio_get_value(sunxi_usbc->gpio_vbus_det);