From: Arnd Bergmann <arnd@arndb.de>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: linux-arm-kernel@lists.infradead.org,
Arnd Bergmann <arnd@arndb.de>,
Russell King <rmk+kernel@arm.linux.org.uk>,
Bjorn Helgaas <bhelgaas@google.com>,
Alexandre Courbot <gnurou@gmail.com>,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
Lars-Peter Clausen <lars@metafoo.de>,
Ralf Baechle <ralf@linux-mips.org>,
linux-mips@linux-mips.org
Subject: [PATCH v2 4/5] gpio: ep93xx: remove private irq_to_gpio function
Date: Tue, 16 Feb 2016 16:40:37 +0100 [thread overview]
Message-ID: <1455637261-2920972-4-git-send-email-arnd@arndb.de> (raw)
In-Reply-To: <1455637261-2920972-1-git-send-email-arnd@arndb.de>
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 <arnd@arndb.de>
---
drivers/gpio/gpio-ep93xx.c | 37 +++++++++++++++++--------------------
1 file changed, 17 insertions(+), 20 deletions(-)
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 <linux/io.h>
#include <linux/irq.h>
#include <linux/slab.h>
-#include <linux/gpio/driver.h>
-/* FIXME: this is here for gpio_to_irq() - get rid of this! */
#include <linux/gpio.h>
-#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,
--
2.7.0
next prev parent reply other threads:[~2016-02-16 15:42 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <455637086-2794174-1-git-send-email-arnd@arndb.de>
2016-02-16 15:40 ` [PATCH v2 1/5] MIPS: jz4740: remove broken irq_to_gpio() call Arnd Bergmann
2016-02-16 15:40 ` [PATCH v2 2/5] gpio: remove broken irq_to_gpio() interface Arnd Bergmann
2016-02-18 23:19 ` Linus Walleij
2016-02-16 15:40 ` [PATCH v2 3/5] gpio: ks8695: remove irq_to_gpio function Arnd Bergmann
2016-02-18 23:20 ` Linus Walleij
2016-02-16 15:40 ` Arnd Bergmann [this message]
2016-02-18 23:21 ` [PATCH v2 4/5] gpio: ep93xx: remove private " Linus Walleij
2016-02-16 15:40 ` [PATCH v2 5/5] gpio: allow setting ARCH_NR_GPIOS from Kconfig Arnd Bergmann
2016-02-18 23:23 ` Linus Walleij
2016-02-16 15:47 ` [PATCH v2 1/5] MIPS: jz4740: remove broken irq_to_gpio() call Lars-Peter Clausen
2016-02-16 16:06 ` Ralf Baechle
2016-02-18 23:19 ` Linus Walleij
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1455637261-2920972-4-git-send-email-arnd@arndb.de \
--to=arnd@arndb.de \
--cc=bhelgaas@google.com \
--cc=gnurou@gmail.com \
--cc=lars@metafoo.de \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@linux-mips.org \
--cc=ralf@linux-mips.org \
--cc=rmk+kernel@arm.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®