From patchwork Thu Aug 11 17:48:24 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hartley Sweeten X-Patchwork-Id: 1058222 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p7BHn412012585 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 11 Aug 2011 17:49:29 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QrZMv-0000Dd-Pd; Thu, 11 Aug 2011 17:48:34 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QrZMv-0003X7-A2; Thu, 11 Aug 2011 17:48:33 +0000 Received: from mail132.messagelabs.com ([216.82.242.115]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QrZMs-0003Wn-34 for linux-arm-kernel@lists.infradead.org; Thu, 11 Aug 2011 17:48:31 +0000 X-VirusChecked: Checked X-Env-Sender: hartleys@visionengravers.com X-Msg-Ref: server-10.tower-132.messagelabs.com!1313084905!34828918!2 X-StarScan-Version: 6.2.17; banners=-,-,- X-Originating-IP: [216.166.12.97] Received: (qmail 24917 invoked from network); 11 Aug 2011 17:48:26 -0000 Received: from out001.collaborationhost.net (HELO out001.collaborationhost.net) (216.166.12.97) by server-10.tower-132.messagelabs.com with RC4-SHA encrypted SMTP; 11 Aug 2011 17:48:26 -0000 Received: from AUSP01VMBX24.collaborationhost.net ([10.2.12.1]) by AUSP01MHUB06.collaborationhost.net ([10.2.8.241]) with mapi; Thu, 11 Aug 2011 12:48:25 -0500 From: H Hartley Sweeten To: Linus Walleij Date: Thu, 11 Aug 2011 12:48:24 -0500 Subject: RE: [PATCH 10/19] mach-ep93xx: break out GPIO driver specifics Thread-Topic: [PATCH 10/19] mach-ep93xx: break out GPIO driver specifics Thread-Index: AcxYIlEzTDiKzyFnS+CbB8tv7Dj8ewAJPYaAAAEyWeA= Message-ID: References: <1312978655-18405-1-git-send-email-linus.walleij@stericsson.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US MIME-Version: 1.0 X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110811_134830_251083_B382FFB1 X-CRM114-Status: GOOD ( 24.78 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [216.82.242.115 listed in list.dnswl.org] Cc: Linus Walleij , "linux-kernel@vger.kernel.org" , Grant Likely , Lee Jones , "linux-arm-kernel@lists.infradead.org" , Ryan Mallon X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 11 Aug 2011 17:49:30 +0000 (UTC) X-MIME-Autoconverted: from quoted-printable to 8bit by demeter1.kernel.org id p7BHn412012585 On Thursday, August 11, 2011 10:16 AM, H Hartley Sweeten wrote: > On Thursday, August 11, 2011 5:29 AM, Linus Walleij wrote: >> On Wed, Aug 10, 2011 at 7:23 PM, H Hartley Sweeten wrote: >>> On Wednesday, August 10, 2011 5:18 AM, Linus Walleij wrote: >>>> +#include "gpio-ep93xx.h" >>> >>> Why this form?  Isn't the preferred form? >> >> This is to make the inclusion very local. The only reason it is >> included at all is to get EP93XX_GPIO_LINE_MAX_IRQ, >> nothing else. > > Hmm.. It is needed for gpio_to_irq()... > > The only other user of that define is drivers/gpio/gpio-ep93xx.c. > > To follow the intentions of this patch it would be nice to remove this > include from and add to the gpio driver. > But, any user of gpio_to_irq() whould also have to include > also. > > The other solution is to hook up the gpiolib to_irq callback in > gpio-ep93xx and do: > > #define gpio_to_irq __gpio_to_irq > > Maybe this is a better option? BTW, I have a patch for this if you want. ---- gpio-ep93xx: hookup the to_irq callback in the driver Remove the ep93xx machine specific dependencies for gpio_to_irq() by hooking up the callback in the driver and using __gpio_to_irq. Signed-off-by: H Hartley Sweeten diff --git a/arch/arm/mach-ep93xx/include/mach/gpio.h b/arch/arm/mach-ep93xx/include/mach/gpio.h index 071f676..76c68fa 100644 --- a/arch/arm/mach-ep93xx/include/mach/gpio.h +++ b/arch/arm/mach-ep93xx/include/mach/gpio.h @@ -99,14 +99,7 @@ /* maximum value for irq capable line identifiers */ #define EP93XX_GPIO_LINE_MAX_IRQ EP93XX_GPIO_LINE_F(7) -/* - * Map GPIO A0..A7 (0..7) to irq 64..71, - * B0..B7 (7..15) to irq 72..79, and - * F0..F7 (16..24) to irq 80..87. - */ -#define gpio_to_irq(gpio) \ - (((gpio) <= EP93XX_GPIO_LINE_MAX_IRQ) ? (64 + (gpio)) : -EINVAL) - +#define gpio_to_irq __gpio_to_irq #define irq_to_gpio(irq) ((irq) - gpio_to_irq(0)) #endif diff --git a/drivers/gpio/gpio-ep93xx.c b/drivers/gpio/gpio-ep93xx.c index 468b27d..6a56895 100644 --- a/drivers/gpio/gpio-ep93xx.c +++ b/drivers/gpio/gpio-ep93xx.c @@ -308,6 +308,21 @@ static int ep93xx_gpio_set_debounce(struct gpio_chip *chip, return 0; } +/* + * Map GPIO A0..A7 (0..7) to irq 64..71, + * B0..B7 (7..15) to irq 72..79, and + * F0..F7 (16..24) to irq 80..87. + */ +static int ep93xx_gpio_to_irq(struct gpio_chip *chip, unsigned offset) +{ + int gpio = chip->base + offset; + + if (gpio > EP93XX_GPIO_LINE_MAX_IRQ) + return -EINVAL; + + return 64 + gpio; +} + static int ep93xx_gpio_add_bank(struct bgpio_chip *bgc, struct device *dev, void __iomem *mmio_base, struct ep93xx_gpio_bank *bank) { @@ -322,8 +337,10 @@ static int ep93xx_gpio_add_bank(struct bgpio_chip *bgc, struct device *dev, bgc->gc.label = bank->label; bgc->gc.base = bank->base; - if (bank->has_debounce) + if (bank->has_debounce) { bgc->gc.set_debounce = ep93xx_gpio_set_debounce; + bgc->gc.to_irq = ep93xx_gpio_to_irq; + } return gpiochip_add(&bgc->gc); }