From patchwork Fri Jun 21 03:07:17 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 253124 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 5B5A02C029B for ; Fri, 21 Jun 2013 13:08:03 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C05744A1CF; Fri, 21 Jun 2013 05:07:59 +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 sGt+xAO7XPXQ; Fri, 21 Jun 2013 05:07:59 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 848894A1D1; Fri, 21 Jun 2013 05:07:57 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 86AE44A1D1 for ; Fri, 21 Jun 2013 05:07:48 +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 AI+fjo6NG1Tq for ; Fri, 21 Jun 2013 05:07:41 +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 mail-pa0-f50.google.com (mail-pa0-f50.google.com [209.85.220.50]) by theia.denx.de (Postfix) with ESMTPS id 788684A1CF for ; Fri, 21 Jun 2013 05:07:33 +0200 (CEST) Received: by mail-pa0-f50.google.com with SMTP id fb1so7116379pad.9 for ; Thu, 20 Jun 2013 20:07:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:subject:from:to:cc:date:content-type:x-mailer :mime-version:content-transfer-encoding:x-gm-message-state; bh=lPxR/ZpR3ElaZGQsEM4NveonbyJ04IA6rmjs74FVQEU=; b=MSrp24cZjsAEzRijVAiY6BPDosshYQxRewjc9yWno3bLuh0mKCBwnurdH+iM4wpWnX OysNZMGrKsjrX6tw9X0OURT1rrNQrMzQnjevnYUAaaw/kYCY+3j7rIDOEOPs3IOVni5g VK3UD15lqVwZhKbeMN8958DNL95rbvksvz/QDr5ns7O4+aLlc4cqABUwCIGUF3J8KbwL RRy47/ddsGCud0PO+5Sa++6Et1NSRBbhVg+TBhi+dU5wMFvb09sDPx8LbWDYedR0/Ms7 WsnKPBssZPwg3z7m+zbavXScG7kOo/vYLtzKI57K4D1nwAQYtm6Qa3Dnkh/UiIkgXBO/ B+UA== X-Received: by 10.68.138.193 with SMTP id qs1mr10064743pbb.95.1371784049785; Thu, 20 Jun 2013 20:07:29 -0700 (PDT) Received: from [192.168.0.100] (114-39-103-89.dynamic.hinet.net. [114.39.103.89]) by mx.google.com with ESMTPSA id kq2sm3457970pab.19.2013.06.20.20.07.22 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 20 Jun 2013 20:07:29 -0700 (PDT) Message-ID: <1371784037.19200.1.camel@phoenix> From: Axel Lin To: Steve Sakoman , Stefan Roese Date: Fri, 21 Jun 2013 11:07:17 +0800 X-Mailer: Evolution 3.6.4-0ubuntu1 Mime-Version: 1.0 X-Gm-Message-State: ALoCoQm9Pg/mpxChPdKcBeFZM7tPFO4jBUbM/7gJ57UbK+LQDOpAf3DJEHuPs7ZQNp4qEuTW6s+8 Cc: Marek Vasut , Igor@theia.denx.de, Albert@theia.denx.de, u-boot@lists.denx.de, Tom Rini Subject: [U-Boot] [PATCH v2] gpio: omap_gpio: Fix valid gpio range for AM33XX X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de AM33XX has 4 gpio banks, thus the valid gpio range should be 0 ... 127. Signed-off-by: Axel Lin Acked-by: Stefan Roese --- v2: define OMAP_MAX_GPIO and use it. This change is mainly based on Stefan's comment, however I use OMAP_MAX_GPIO instead of CONFIG_OMAP_MAX_GPIO because having CONFIG_ prefix seems meaning it can be configurable in configs. drivers/gpio/omap_gpio.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/gpio/omap_gpio.c b/drivers/gpio/omap_gpio.c index a30d7f0..6fa57c9 100644 --- a/drivers/gpio/omap_gpio.c +++ b/drivers/gpio/omap_gpio.c @@ -40,6 +40,12 @@ #include #include +#if defined(CONFIG_AM33XX) +#define OMAP_MAX_GPIO 128 +#else +#define OMAP_MAX_GPIO 192 +#endif + #define OMAP_GPIO_DIR_OUT 0 #define OMAP_GPIO_DIR_IN 1 @@ -55,7 +61,7 @@ static inline int get_gpio_index(int gpio) int gpio_is_valid(int gpio) { - return (gpio >= 0) && (gpio < 192); + return (gpio >= 0) && (gpio < OMAP_MAX_GPIO); } static int check_gpio(int gpio)