Skip to content

Commit ec37529

Browse files
Doug BergerBartosz Golaszewski
authored andcommitted
gpio: brcmstb: Use dynamic GPIO base numbers
Forcing a gpiochip to have a fixed base number now leads to a warning message. Remove the need to do so by using the offset value of the gpiochip. Signed-off-by: Phil Elwell <[email protected]> Signed-off-by: Doug Berger <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Tested-by: Florian Fainelli <[email protected]> Reviewed-by: Linus Walleij <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent 8a7a610 commit ec37529

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

drivers/gpio/gpio-brcmstb.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ struct brcmstb_gpio_priv {
5050
struct irq_domain *irq_domain;
5151
struct irq_chip irq_chip;
5252
int parent_irq;
53-
int gpio_base;
5453
int num_gpios;
5554
int parent_wake_irq;
5655
};
@@ -92,7 +91,7 @@ brcmstb_gpio_get_active_irqs(struct brcmstb_gpio_bank *bank)
9291
static int brcmstb_gpio_hwirq_to_offset(irq_hw_number_t hwirq,
9392
struct brcmstb_gpio_bank *bank)
9493
{
95-
return hwirq - (bank->gc.base - bank->parent_priv->gpio_base);
94+
return hwirq - bank->gc.offset;
9695
}
9796

9897
static void brcmstb_gpio_set_imask(struct brcmstb_gpio_bank *bank,
@@ -118,7 +117,7 @@ static int brcmstb_gpio_to_irq(struct gpio_chip *gc, unsigned offset)
118117
{
119118
struct brcmstb_gpio_priv *priv = brcmstb_gpio_gc_to_priv(gc);
120119
/* gc_offset is relative to this gpio_chip; want real offset */
121-
int hwirq = offset + (gc->base - priv->gpio_base);
120+
int hwirq = offset + gc->offset;
122121

123122
if (hwirq >= priv->num_gpios)
124123
return -ENXIO;
@@ -263,7 +262,7 @@ static void brcmstb_gpio_irq_bank_handler(struct brcmstb_gpio_bank *bank)
263262
{
264263
struct brcmstb_gpio_priv *priv = bank->parent_priv;
265264
struct irq_domain *domain = priv->irq_domain;
266-
int hwbase = bank->gc.base - priv->gpio_base;
265+
int hwbase = bank->gc.offset;
267266
unsigned long status;
268267

269268
while ((status = brcmstb_gpio_get_active_irqs(bank))) {
@@ -412,7 +411,7 @@ static int brcmstb_gpio_of_xlate(struct gpio_chip *gc,
412411
if (WARN_ON(gpiospec->args_count < gc->of_gpio_n_cells))
413412
return -EINVAL;
414413

415-
offset = gpiospec->args[0] - (gc->base - priv->gpio_base);
414+
offset = gpiospec->args[0] - bank->gc.offset;
416415
if (offset >= gc->ngpio || offset < 0)
417416
return -EINVAL;
418417

@@ -596,8 +595,8 @@ static int brcmstb_gpio_probe(struct platform_device *pdev)
596595
const __be32 *p;
597596
u32 bank_width;
598597
int num_banks = 0;
598+
int num_gpios = 0;
599599
int err;
600-
static int gpio_base;
601600
unsigned long flags = 0;
602601
bool need_wakeup_event = false;
603602

@@ -611,7 +610,6 @@ static int brcmstb_gpio_probe(struct platform_device *pdev)
611610
if (IS_ERR(reg_base))
612611
return PTR_ERR(reg_base);
613612

614-
priv->gpio_base = gpio_base;
615613
priv->reg_base = reg_base;
616614
priv->pdev = pdev;
617615

@@ -651,7 +649,7 @@ static int brcmstb_gpio_probe(struct platform_device *pdev)
651649
dev_dbg(dev, "Width 0 found: Empty bank @ %d\n",
652650
num_banks);
653651
num_banks++;
654-
gpio_base += MAX_GPIO_PER_BANK;
652+
num_gpios += MAX_GPIO_PER_BANK;
655653
continue;
656654
}
657655

@@ -691,7 +689,6 @@ static int brcmstb_gpio_probe(struct platform_device *pdev)
691689
err = -ENOMEM;
692690
goto fail;
693691
}
694-
gc->base = gpio_base;
695692
gc->of_gpio_n_cells = 2;
696693
gc->of_xlate = brcmstb_gpio_of_xlate;
697694
/* not all ngpio lines are valid, will use bank width later */
@@ -713,7 +710,7 @@ static int brcmstb_gpio_probe(struct platform_device *pdev)
713710
bank->id);
714711
goto fail;
715712
}
716-
gpio_base += gc->ngpio;
713+
num_gpios += gc->ngpio;
717714

718715
dev_dbg(dev, "bank=%d, base=%d, ngpio=%d, width=%d\n", bank->id,
719716
gc->base, gc->ngpio, bank->width);
@@ -724,7 +721,7 @@ static int brcmstb_gpio_probe(struct platform_device *pdev)
724721
num_banks++;
725722
}
726723

727-
priv->num_gpios = gpio_base - priv->gpio_base;
724+
priv->num_gpios = num_gpios;
728725
if (priv->parent_irq > 0) {
729726
err = brcmstb_gpio_irq_setup(pdev, priv);
730727
if (err)

0 commit comments

Comments
 (0)