Skip to content

Commit b2cf569

Browse files
Doug BergerBartosz Golaszewski
authored andcommitted
gpio: brcmstb: correct hwirq to bank map
The brcmstb_gpio_hwirq_to_bank() function was designed to accommodate the downward numbering of dynamic GPIOs by traversing the bank list in the reverse order. However, the dynamic numbering has changed to increment upward which can produce an incorrect mapping. The function is modified to no longer assume an ordering of the list to accommodate either option. Fixes: 7b61212 ("gpiolib: Get rid of ARCH_NR_GPIOS") Signed-off-by: Doug Berger <opendmb@gmail.com> Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com> Reviewed-by: Linus Walleij <linusw@kernel.org> Link: https://patch.msgid.link/20260127214656.447333-2-florian.fainelli@broadcom.com Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
1 parent 730e5eb commit b2cf569

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

drivers/gpio/gpio-brcmstb.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -301,12 +301,10 @@ static struct brcmstb_gpio_bank *brcmstb_gpio_hwirq_to_bank(
301301
struct brcmstb_gpio_priv *priv, irq_hw_number_t hwirq)
302302
{
303303
struct brcmstb_gpio_bank *bank;
304-
int i = 0;
305304

306-
/* banks are in descending order */
307-
list_for_each_entry_reverse(bank, &priv->bank_list, node) {
308-
i += bank->chip.gc.ngpio;
309-
if (hwirq < i)
305+
list_for_each_entry(bank, &priv->bank_list, node) {
306+
if (hwirq >= bank->chip.gc.offset &&
307+
hwirq < (bank->chip.gc.offset + bank->chip.gc.ngpio))
310308
return bank;
311309
}
312310
return NULL;

0 commit comments

Comments
 (0)