Skip to content

Commit f6b6154

Browse files
maquefelbrgl
authored andcommitted
gpio: ep93xx: refactor ep93xx_gpio_add_bank
- replace plain numbers with girq->num_parents in devm_kcalloc - replace plain numbers with girq->num_parents for port F - refactor i - 1 to i + 1 to make loop more readable - combine getting IRQ's loop and setting handler's into single loop Reviewed-by: Linus Walleij <[email protected]> Acked-by: Alexander Sverdlin <[email protected]> Signed-off-by: Nikita Shubin <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent 78f85c7 commit f6b6154

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

drivers/gpio/gpio-ep93xx.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ static int ep93xx_gpio_add_bank(struct ep93xx_gpio_chip *egc,
370370

371371
girq->parent_handler = ep93xx_gpio_ab_irq_handler;
372372
girq->num_parents = 1;
373-
girq->parents = devm_kcalloc(dev, 1,
373+
girq->parents = devm_kcalloc(dev, girq->num_parents,
374374
sizeof(*girq->parents),
375375
GFP_KERNEL);
376376
if (!girq->parents)
@@ -392,15 +392,14 @@ static int ep93xx_gpio_add_bank(struct ep93xx_gpio_chip *egc,
392392
*/
393393
girq->parent_handler = ep93xx_gpio_f_irq_handler;
394394
girq->num_parents = 8;
395-
girq->parents = devm_kcalloc(dev, 8,
395+
girq->parents = devm_kcalloc(dev, girq->num_parents,
396396
sizeof(*girq->parents),
397397
GFP_KERNEL);
398398
if (!girq->parents)
399399
return -ENOMEM;
400400
/* Pick resources 1..8 for these IRQs */
401-
for (i = 1; i <= 8; i++)
402-
girq->parents[i - 1] = platform_get_irq(pdev, i);
403-
for (i = 0; i < 8; i++) {
401+
for (i = 0; i < girq->num_parents; i++) {
402+
girq->parents[i] = platform_get_irq(pdev, i + 1);
404403
gpio_irq = EP93XX_GPIO_F_IRQ_BASE + i;
405404
irq_set_chip_data(gpio_irq, &epg->gc[5]);
406405
irq_set_chip_and_handler(gpio_irq,

0 commit comments

Comments
 (0)