From patchwork Mon Feb 15 15:46:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 102781 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp1142375lbl; Mon, 15 Feb 2016 07:48:07 -0800 (PST) X-Received: by 10.98.8.200 with SMTP id 69mr24936656pfi.39.1455551287803; Mon, 15 Feb 2016 07:48:07 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e3si44075642pas.149.2016.02.15.07.48.07; Mon, 15 Feb 2016 07:48:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752334AbcBOPsC (ORCPT + 30 others); Mon, 15 Feb 2016 10:48:02 -0500 Received: from mout.kundenserver.de ([212.227.126.130]:56983 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752300AbcBOPr4 (ORCPT ); Mon, 15 Feb 2016 10:47:56 -0500 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue002) with ESMTPA (Nemesis) id 0MH9BC-1aj2Uv3OWg-00Dn3x; Mon, 15 Feb 2016 16:47:27 +0100 From: Arnd Bergmann To: Linus Walleij Cc: linux-arm-kernel@lists.infradead.org, Arnd Bergmann , Russell King , Bjorn Helgaas , Alexandre Courbot , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/4] gpio: ep93xx: remove private irq_to_gpio function Date: Mon, 15 Feb 2016 16:46:30 +0100 Message-Id: <1455551208-2825510-4-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1455551208-2825510-1-git-send-email-arnd@arndb.de> References: <20160202194831.10827.63244.stgit@bhelgaas-glaptop2.roam.corp.google.com> <1455551208-2825510-1-git-send-email-arnd@arndb.de> X-Provags-ID: V03:K0:GHe8QSrcI1EmfM24Th5WYjUnEjsUxGYvOCCTrNSTYTWq2Paw5gb UytmNbVms9w5p9ntK9ftJwL5UGfHmc86gNhy25f1bVKoM9rEAxKLLZWx2reHyBDpaN72SyS m6OyMwld+ZYf8Tfp+2IRIlCEpsr3oRyJnSRabLgVOA18pKbQzaglakO2xoaTVMvYKPsy9KR flOG0d4Y/6noJ3TATldOA== X-UI-Out-Filterresults: notjunk:1; V01:K0:PntlPy42DDY=:lmVRbP31baSSq7+ay1N7BG zdv/qTs+x64JFu/NsHTgznMQzUFu97SrWaXcfFc/iBEYzHOaew9wDlITyeQ/O6SGdDAINE1Jj zlGV3FrKijYEtrfnfWSC9yxHc8AiYdRT1wPM/E4h+9iKIV3Po8bH6HAPW8S0srRPw84foM/UK 3IJCFKY1n1Te3ug3vBE7PBJuwU+x6DvMVhnnfjPWzT6XZ9JP0TzRe+XLrwa9uzPEAy3HiRATu IZVbRLjC3eZvGWMkkj6/61MLx/EiIqWGtkmHoBeL7IiWOCeHlEKDeC6jMQ/i63T4mOxdX8XpJ MDkQ6X/xBNalrJBYeBp9OPNeYt9k0KeF/PkA8mFxCyFDXgOpeiRZQqoJcAGlj4DuK+Qsnt/4R g8q2FuVlH292CODVbuqcosAD2NdEEXUmYYy1648jFJqf6C7YboniJtcHvK15pVDCL4VkomHAl btocmdtezzCwtjW9d7yDQcDtcq+YQv7z5j/1XN9kP9/I5fR98UmQM3webVyuRaGCUKv+dq1Ep yO3CJMdJGXcJusMu7aEkqROr0DaTXySHJsAJjqGJPpxY9aBTRmhyV5k4KxuTX7VyfreNnVQhl qLZpuU9r97OiQc+sATvRrEp1ERUgkoxUSlTfUds/AG4yNV1EZQFtTpavhHs+pAR36RNZYKw1t 1sXKGdXGxDYFTQ7n6C6OhUp2A1W+aaDa0iFoeUG37tx5q4X5yMVuo6qAPx5FY3qqfKRQ= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The ep93xx goes through its own back-and-forth dance every time it wants to know the gpio number for an irq line, when it really just hardcodes a fixed offset in ep93xx_gpio_to_irq(). This removes the pointless macro and replaces the conversion inside of the driver with simple add/subtract operations, using an explicit macro. Signed-off-by: Arnd Bergmann --- drivers/gpio/gpio-ep93xx.c | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) -- 2.7.0 diff --git a/drivers/gpio/gpio-ep93xx.c b/drivers/gpio/gpio-ep93xx.c index 20e5846bda28..cd83d30e8ff7 100644 --- a/drivers/gpio/gpio-ep93xx.c +++ b/drivers/gpio/gpio-ep93xx.c @@ -18,12 +18,8 @@ #include #include #include -#include -/* FIXME: this is here for gpio_to_irq() - get rid of this! */ #include -#define irq_to_gpio(irq) ((irq) - gpio_to_irq(0)) - void __iomem *ep93xx_gpio_base; /* FIXME: put this into irq_data */ #define EP93XX_GPIO_REG(x) (ep93xx_gpio_base + (x)) @@ -35,6 +31,7 @@ void __iomem *ep93xx_gpio_base; /* FIXME: put this into irq_data */ #define EP93XX_GPIO_LINE_MAX 63 /* maximum value for irq capable line identifiers */ +#define EP93XX_GPIO_IRQ_BASE 64 #define EP93XX_GPIO_LINE_MAX_IRQ 23 @@ -77,7 +74,7 @@ static void ep93xx_gpio_update_int_params(unsigned port) static void ep93xx_gpio_int_debounce(unsigned int irq, bool enable) { - int line = irq_to_gpio(irq); + int line = irq - EP93XX_GPIO_IRQ_BASE; int port = line >> 3; int port_mask = 1 << (line & 7); @@ -98,7 +95,7 @@ static void ep93xx_gpio_ab_irq_handler(struct irq_desc *desc) status = readb(EP93XX_GPIO_A_INT_STATUS); for (i = 0; i < 8; i++) { if (status & (1 << i)) { - int gpio_irq = gpio_to_irq(0) + i; + int gpio_irq = EP93XX_GPIO_IRQ_BASE + i; generic_handle_irq(gpio_irq); } } @@ -106,7 +103,7 @@ static void ep93xx_gpio_ab_irq_handler(struct irq_desc *desc) status = readb(EP93XX_GPIO_B_INT_STATUS); for (i = 0; i < 8; i++) { if (status & (1 << i)) { - int gpio_irq = gpio_to_irq(8) + i; + int gpio_irq = EP93XX_GPIO_IRQ_BASE + 8 + i; generic_handle_irq(gpio_irq); } } @@ -121,14 +118,14 @@ static void ep93xx_gpio_f_irq_handler(struct irq_desc *desc) */ unsigned int irq = irq_desc_get_irq(desc); int port_f_idx = ((irq + 1) & 7) ^ 4; /* {19..22,47..50} -> {0..7} */ - int gpio_irq = gpio_to_irq(16) + port_f_idx; + int gpio_irq = EP93XX_GPIO_IRQ_BASE + 16 + port_f_idx; generic_handle_irq(gpio_irq); } static void ep93xx_gpio_irq_ack(struct irq_data *d) { - int line = irq_to_gpio(d->irq); + int line = d->irq - EP93XX_GPIO_IRQ_BASE; int port = line >> 3; int port_mask = 1 << (line & 7); @@ -142,7 +139,7 @@ static void ep93xx_gpio_irq_ack(struct irq_data *d) static void ep93xx_gpio_irq_mask_ack(struct irq_data *d) { - int line = irq_to_gpio(d->irq); + int line = d->irq - EP93XX_GPIO_IRQ_BASE; int port = line >> 3; int port_mask = 1 << (line & 7); @@ -157,7 +154,7 @@ static void ep93xx_gpio_irq_mask_ack(struct irq_data *d) static void ep93xx_gpio_irq_mask(struct irq_data *d) { - int line = irq_to_gpio(d->irq); + int line = d->irq - EP93XX_GPIO_IRQ_BASE; int port = line >> 3; gpio_int_unmasked[port] &= ~(1 << (line & 7)); @@ -166,7 +163,7 @@ static void ep93xx_gpio_irq_mask(struct irq_data *d) static void ep93xx_gpio_irq_unmask(struct irq_data *d) { - int line = irq_to_gpio(d->irq); + int line = d->irq - EP93XX_GPIO_IRQ_BASE; int port = line >> 3; gpio_int_unmasked[port] |= 1 << (line & 7); @@ -180,7 +177,7 @@ static void ep93xx_gpio_irq_unmask(struct irq_data *d) */ static int ep93xx_gpio_irq_type(struct irq_data *d, unsigned int type) { - const int gpio = irq_to_gpio(d->irq); + const int gpio = d->irq - EP93XX_GPIO_IRQ_BASE; const int port = gpio >> 3; const int port_mask = 1 << (gpio & 7); irq_flow_handler_t handler; @@ -241,14 +238,14 @@ static struct irq_chip ep93xx_gpio_irq_chip = { static void ep93xx_gpio_init_irq(struct platform_device *pdev) { - int gpio_irq; + int gpio; int i; - for (gpio_irq = gpio_to_irq(0); - gpio_irq <= gpio_to_irq(EP93XX_GPIO_LINE_MAX_IRQ); ++gpio_irq) { - irq_set_chip_and_handler(gpio_irq, &ep93xx_gpio_irq_chip, + for (gpio = 0; gpio <= EP93XX_GPIO_LINE_MAX_IRQ; ++gpio) { + irq_set_chip_and_handler(EP93XX_GPIO_IRQ_BASE + gpio, + &ep93xx_gpio_irq_chip, handle_level_irq); - irq_clear_status_flags(gpio_irq, IRQ_NOREQUEST); + irq_clear_status_flags(EP93XX_GPIO_IRQ_BASE + gpio, IRQ_NOREQUEST); } irq_set_chained_handler(platform_get_irq(pdev, 0), @@ -294,7 +291,7 @@ static int ep93xx_gpio_set_debounce(struct gpio_chip *chip, unsigned offset, unsigned debounce) { int gpio = chip->base + offset; - int irq = gpio_to_irq(gpio); + int irq = EP93XX_GPIO_IRQ_BASE + gpio; if (irq < 0) return -EINVAL; @@ -316,7 +313,7 @@ static int ep93xx_gpio_to_irq(struct gpio_chip *chip, unsigned offset) if (gpio > EP93XX_GPIO_LINE_MAX_IRQ) return -EINVAL; - return 64 + gpio; + return EP93XX_GPIO_IRQ_BASE + gpio; } static int ep93xx_gpio_add_bank(struct gpio_chip *gc, struct device *dev,