Skip to content

Commit f9f890b

Browse files
fancerLinus Walleij
authored andcommitted
gpio: dwapb: Add max GPIOs macro
Add a new macro DWAPB_MAX_GPIOS which defines the maximum possible number of GPIO lines corresponding to the maximum DW APB GPIO controller port width. Use the new macro instead of number literal 32 where it's applicable. Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20200730152808.2955-5-Sergey.Semin@baikalelectronics.ru Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent 75c1236 commit f9f890b

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

drivers/gpio/gpio-dwapb.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ static struct dwapb_gpio_port *dwapb_offs_to_port(struct dwapb_gpio *gpio, unsig
162162

163163
for (i = 0; i < gpio->nr_ports; i++) {
164164
port = &gpio->ports[i];
165-
if (port->idx == offs / 32)
165+
if (port->idx == offs / DWAPB_MAX_GPIOS)
166166
return port;
167167
}
168168

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

183183
pol = dwapb_read(gpio, GPIO_INT_POLARITY);
184184
/* Just read the current value right out of the data register */
185-
val = gc->get(gc, offs % 32);
185+
val = gc->get(gc, offs % DWAPB_MAX_GPIOS);
186186
if (val)
187187
pol &= ~BIT(offs);
188188
else
@@ -197,7 +197,7 @@ static u32 dwapb_do_irq(struct dwapb_gpio *gpio)
197197
irq_hw_number_t hwirq;
198198

199199
irq_status = dwapb_read(gpio, GPIO_INTSTATUS);
200-
for_each_set_bit(hwirq, &irq_status, 32) {
200+
for_each_set_bit(hwirq, &irq_status, DWAPB_MAX_GPIOS) {
201201
int gpio_irq = irq_find_mapping(gpio->domain, hwirq);
202202
u32 irq_type = irq_get_trigger_type(gpio_irq);
203203

@@ -599,7 +599,7 @@ static struct dwapb_platform_data *dwapb_gpio_get_pdata(struct device *dev)
599599
dev_info(dev,
600600
"failed to get number of gpios for port%d\n",
601601
i);
602-
pp->ngpio = 32;
602+
pp->ngpio = DWAPB_MAX_GPIOS;
603603
}
604604

605605
pp->irq_shared = false;

include/linux/platform_data/gpio-dwapb.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66
#ifndef GPIO_DW_APB_H
77
#define GPIO_DW_APB_H
88

9+
#define DWAPB_MAX_GPIOS 32
10+
911
struct dwapb_port_property {
1012
struct fwnode_handle *fwnode;
1113
unsigned int idx;
1214
unsigned int ngpio;
1315
unsigned int gpio_base;
14-
int irq[32];
16+
int irq[DWAPB_MAX_GPIOS];
1517
bool irq_shared;
1618
};
1719

0 commit comments

Comments
 (0)