Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gpio: Drop the parent_irq from gpio_irq_chip

We already have an array named "parents" so instead
of letting one point to the other, simply allocate a
dynamic array to hold the parents, just one if desired
and drop the number of members in gpio_irq_chip by
1. Rename gpiochip to gc in the process.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

+19 -18
+19 -11
drivers/gpio/gpiolib.c
··· 1644 1644 1645 1645 /** 1646 1646 * gpiochip_set_cascaded_irqchip() - connects a cascaded irqchip to a gpiochip 1647 - * @gpiochip: the gpiochip to set the irqchip chain to 1647 + * @gc: the gpiochip to set the irqchip chain to 1648 1648 * @parent_irq: the irq number corresponding to the parent IRQ for this 1649 1649 * chained irqchip 1650 1650 * @parent_handler: the parent interrupt handler for the accumulated IRQ 1651 1651 * coming out of the gpiochip. If the interrupt is nested rather than 1652 1652 * cascaded, pass NULL in this handler argument 1653 1653 */ 1654 - static void gpiochip_set_cascaded_irqchip(struct gpio_chip *gpiochip, 1654 + static void gpiochip_set_cascaded_irqchip(struct gpio_chip *gc, 1655 1655 unsigned int parent_irq, 1656 1656 irq_flow_handler_t parent_handler) 1657 1657 { 1658 - if (!gpiochip->irq.domain) { 1659 - chip_err(gpiochip, "called %s before setting up irqchip\n", 1658 + struct gpio_irq_chip *girq = &gc->irq; 1659 + struct device *dev = &gc->gpiodev->dev; 1660 + 1661 + if (!girq->domain) { 1662 + chip_err(gc, "called %s before setting up irqchip\n", 1660 1663 __func__); 1661 1664 return; 1662 1665 } 1663 1666 1664 1667 if (parent_handler) { 1665 - if (gpiochip->can_sleep) { 1666 - chip_err(gpiochip, 1668 + if (gc->can_sleep) { 1669 + chip_err(gc, 1667 1670 "you cannot have chained interrupts on a chip that may sleep\n"); 1668 1671 return; 1669 1672 } 1673 + girq->parents = devm_kcalloc(dev, 1, 1674 + sizeof(*girq->parents), 1675 + GFP_KERNEL); 1676 + if (!girq->parents) { 1677 + chip_err(gc, "out of memory allocating parent IRQ\n"); 1678 + return; 1679 + } 1680 + girq->parents[0] = parent_irq; 1681 + girq->num_parents = 1; 1670 1682 /* 1671 1683 * The parent irqchip is already using the chip_data for this 1672 1684 * irqchip, so our callbacks simply use the handler_data. 1673 1685 */ 1674 1686 irq_set_chained_handler_and_data(parent_irq, parent_handler, 1675 - gpiochip); 1676 - 1677 - gpiochip->irq.parent_irq = parent_irq; 1678 - gpiochip->irq.parents = &gpiochip->irq.parent_irq; 1679 - gpiochip->irq.num_parents = 1; 1687 + gc); 1680 1688 } 1681 1689 } 1682 1690
-7
include/linux/gpio/driver.h
··· 103 103 unsigned int num_parents; 104 104 105 105 /** 106 - * @parent_irq: 107 - * 108 - * For use by gpiochip_set_cascaded_irqchip() 109 - */ 110 - unsigned int parent_irq; 111 - 112 - /** 113 106 * @parents: 114 107 * 115 108 * A list of interrupt parents of a GPIO chip. This is owned by the