lkml.org 
[lkml]   [2020]   [Jun]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v1 6/6] gpio: dwapb: Define magic number for IRQ and GPIO lines
Date
Define maximum number of IRQ and GPIO lines per port and
replace magic number by it.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/gpio/gpio-dwapb.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/gpio/gpio-dwapb.c b/drivers/gpio/gpio-dwapb.c
index de01b8943bd2..77a86a8eaee0 100644
--- a/drivers/gpio/gpio-dwapb.c
+++ b/drivers/gpio/gpio-dwapb.c
@@ -63,6 +63,7 @@
#define GPIO_INTSTATUS_V2 0x3c
#define GPIO_PORTA_EOI_V2 0x40

+#define DWAPB_NR_GPIOS 32
#define DWAPB_NR_CLOCKS 2

struct dwapb_port_property {
@@ -70,7 +71,7 @@ struct dwapb_port_property {
unsigned int idx;
unsigned int ngpio;
unsigned int gpio_base;
- int irq[32];
+ int irq[DWAPB_NR_GPIOS];
};

struct dwapb_platform_data {
@@ -174,7 +175,7 @@ static struct dwapb_gpio_port *dwapb_offs_to_port(struct dwapb_gpio *gpio, unsig

for (i = 0; i < gpio->nr_ports; i++) {
port = &gpio->ports[i];
- if (port->idx == offs / 32)
+ if (port->idx == offs / DWAPB_NR_GPIOS)
return port;
}

@@ -194,7 +195,7 @@ static void dwapb_toggle_trigger(struct dwapb_gpio *gpio, unsigned int offs)

pol = dwapb_read(gpio, GPIO_INT_POLARITY);
/* Just read the current value right out of the data register */
- val = gc->get(gc, offs % 32);
+ val = gc->get(gc, offs % DWAPB_NR_GPIOS);
if (val)
pol &= ~BIT(offs);
else
@@ -209,7 +210,7 @@ static u32 dwapb_do_irq(struct dwapb_gpio *gpio)
irq_hw_number_t hwirq;

irq_status = dwapb_read(gpio, GPIO_INTSTATUS);
- for_each_set_bit(hwirq, &irq_status, 32) {
+ for_each_set_bit(hwirq, &irq_status, DWAPB_NR_GPIOS) {
int gpio_irq = irq_find_mapping(gpio->domain, hwirq);
u32 irq_type = irq_get_trigger_type(gpio_irq);

@@ -608,7 +609,7 @@ static struct dwapb_platform_data *dwapb_gpio_get_pdata(struct device *dev)
dev_info(dev,
"failed to get number of gpios for port%d\n",
i);
- pp->ngpio = 32;
+ pp->ngpio = DWAPB_NR_GPIOS;
}

if (fwnode_property_read_u32(fwnode, "snps,gpio-base", &pp->gpio_base))
--
2.27.0.rc2
\
 
 \ /
  Last update: 2020-06-08 15:43    [W:0.335 / U:0.708 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site