Skip to content

Commit 5c4fee6

Browse files
tpetazzonilinusw
authored andcommitted
gpio: pca953x: use a per instance irq_chip structure
When a system has two PCA953x GPIO expanders, the kernel complains with: gpio gpiochip2: (0-0021): detected irqchip that is shared with multiple gpiochips: please fix the driver. Indeed, there is a single instance of "struct irq_chip" that gets re-used for both PCA953x instance. This commit moves the "struct irq_chip" to be part of the "struct pca953x_chip", so that we have one "struct irq_chip" per PCA953X instance. As part of this, the name of the irq_chip is also made different on a per-instance basis, now using the dev_name() of the I2C device. This changes what is visible in /proc/interrupts. Before: 47: 0 0 pca953x 10 Edge e0100000.sdhci cd 48: 0 0 pca953x 6 Edge e0101000.sdhci cd After: 47: 0 0 0-0020 10 Edge e0100000.sdhci cd 48: 2 0 0-0020 6 Edge e0101000.sdhci cd Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent 7341fa7 commit 5c4fee6

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

drivers/gpio/gpio-pca953x.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ struct pca953x_chip {
150150
u8 irq_stat[MAX_BANK];
151151
u8 irq_trig_raise[MAX_BANK];
152152
u8 irq_trig_fall[MAX_BANK];
153+
struct irq_chip irq_chip;
153154
#endif
154155

155156
struct i2c_client *client;
@@ -594,16 +595,6 @@ static void pca953x_irq_shutdown(struct irq_data *d)
594595
chip->irq_trig_fall[d->hwirq / BANK_SZ] &= ~mask;
595596
}
596597

597-
static struct irq_chip pca953x_irq_chip = {
598-
.name = "pca953x",
599-
.irq_mask = pca953x_irq_mask,
600-
.irq_unmask = pca953x_irq_unmask,
601-
.irq_bus_lock = pca953x_irq_bus_lock,
602-
.irq_bus_sync_unlock = pca953x_irq_bus_sync_unlock,
603-
.irq_set_type = pca953x_irq_set_type,
604-
.irq_shutdown = pca953x_irq_shutdown,
605-
};
606-
607598
static bool pca953x_irq_pending(struct pca953x_chip *chip, u8 *pending)
608599
{
609600
u8 cur_stat[MAX_BANK];
@@ -699,6 +690,7 @@ static int pca953x_irq_setup(struct pca953x_chip *chip,
699690
int irq_base)
700691
{
701692
struct i2c_client *client = chip->client;
693+
struct irq_chip *irq_chip = &chip->irq_chip;
702694
int reg_direction[MAX_BANK];
703695
int ret, i;
704696

@@ -737,7 +729,15 @@ static int pca953x_irq_setup(struct pca953x_chip *chip,
737729
return ret;
738730
}
739731

740-
ret = gpiochip_irqchip_add_nested(&chip->gpio_chip, &pca953x_irq_chip,
732+
irq_chip->name = dev_name(&chip->client->dev);
733+
irq_chip->irq_mask = pca953x_irq_mask;
734+
irq_chip->irq_unmask = pca953x_irq_unmask;
735+
irq_chip->irq_bus_lock = pca953x_irq_bus_lock;
736+
irq_chip->irq_bus_sync_unlock = pca953x_irq_bus_sync_unlock;
737+
irq_chip->irq_set_type = pca953x_irq_set_type;
738+
irq_chip->irq_shutdown = pca953x_irq_shutdown;
739+
740+
ret = gpiochip_irqchip_add_nested(&chip->gpio_chip, irq_chip,
741741
irq_base, handle_simple_irq,
742742
IRQ_TYPE_NONE);
743743
if (ret) {
@@ -746,8 +746,7 @@ static int pca953x_irq_setup(struct pca953x_chip *chip,
746746
return ret;
747747
}
748748

749-
gpiochip_set_nested_irqchip(&chip->gpio_chip, &pca953x_irq_chip,
750-
client->irq);
749+
gpiochip_set_nested_irqchip(&chip->gpio_chip, irq_chip, client->irq);
751750

752751
return 0;
753752
}

0 commit comments

Comments
 (0)