From patchwork Tue Apr 12 07:03:15 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 90726 X-Patchwork-Delegate: wd@denx.de 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 CA473B6EF1 for ; Tue, 12 Apr 2011 17:01:19 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id DC9E7281EC; Tue, 12 Apr 2011 09:01:17 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 ccU4jGAeEWQD; Tue, 12 Apr 2011 09:01:17 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 59B3C281E0; Tue, 12 Apr 2011 09:01:15 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B7627281E0 for ; Tue, 12 Apr 2011 09:01:13 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 WncefcW3Lu89 for ; Tue, 12 Apr 2011 09:01:13 +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 smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by theia.denx.de (Postfix) with ESMTPS id 01DE3281C9 for ; Tue, 12 Apr 2011 09:01:12 +0200 (CEST) Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 597771B402A for ; Tue, 12 Apr 2011 07:01:08 +0000 (UTC) From: Mike Frysinger To: u-boot@lists.denx.de Date: Tue, 12 Apr 2011 03:03:15 -0400 Message-Id: <1302591795-12024-1-git-send-email-vapier@gentoo.org> X-Mailer: git-send-email 1.7.5.rc1 In-Reply-To: <1301820218-26319-1-git-send-email-vapier@gentoo.org> References: <1301820218-26319-1-git-send-email-vapier@gentoo.org> Subject: [U-Boot] [PATCH] gpio: check request result X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Make sure the pin request passed before attempting to use it later on. Signed-off-by: Mike Frysinger Tested-by: Andreas Pretzsch --- common/cmd_gpio.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/common/cmd_gpio.c b/common/cmd_gpio.c index 9c9de28..9cc790a 100644 --- a/common/cmd_gpio.c +++ b/common/cmd_gpio.c @@ -57,7 +57,10 @@ static int do_gpio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) goto show_usage; /* grab the pin before we tweak it */ - gpio_request(gpio, "cmd_gpio"); + if (gpio_request(gpio, "cmd_gpio")) { + printf("gpio: requesting pin %u failed\n", gpio); + return -1; + } /* finally, let's do it: set direction and exec command */ if (sub_cmd == GPIO_INPUT) {