Commit 5c4fee63 authored by Thomas Petazzoni's avatar Thomas Petazzoni Committed by Linus Walleij

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: default avatarThomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 7341fa7a
...@@ -150,6 +150,7 @@ struct pca953x_chip { ...@@ -150,6 +150,7 @@ struct pca953x_chip {
u8 irq_stat[MAX_BANK]; u8 irq_stat[MAX_BANK];
u8 irq_trig_raise[MAX_BANK]; u8 irq_trig_raise[MAX_BANK];
u8 irq_trig_fall[MAX_BANK]; u8 irq_trig_fall[MAX_BANK];
struct irq_chip irq_chip;
#endif #endif
struct i2c_client *client; struct i2c_client *client;
...@@ -594,16 +595,6 @@ static void pca953x_irq_shutdown(struct irq_data *d) ...@@ -594,16 +595,6 @@ static void pca953x_irq_shutdown(struct irq_data *d)
chip->irq_trig_fall[d->hwirq / BANK_SZ] &= ~mask; chip->irq_trig_fall[d->hwirq / BANK_SZ] &= ~mask;
} }
static struct irq_chip pca953x_irq_chip = {
.name = "pca953x",
.irq_mask = pca953x_irq_mask,
.irq_unmask = pca953x_irq_unmask,
.irq_bus_lock = pca953x_irq_bus_lock,
.irq_bus_sync_unlock = pca953x_irq_bus_sync_unlock,
.irq_set_type = pca953x_irq_set_type,
.irq_shutdown = pca953x_irq_shutdown,
};
static bool pca953x_irq_pending(struct pca953x_chip *chip, u8 *pending) static bool pca953x_irq_pending(struct pca953x_chip *chip, u8 *pending)
{ {
u8 cur_stat[MAX_BANK]; u8 cur_stat[MAX_BANK];
...@@ -699,6 +690,7 @@ static int pca953x_irq_setup(struct pca953x_chip *chip, ...@@ -699,6 +690,7 @@ static int pca953x_irq_setup(struct pca953x_chip *chip,
int irq_base) int irq_base)
{ {
struct i2c_client *client = chip->client; struct i2c_client *client = chip->client;
struct irq_chip *irq_chip = &chip->irq_chip;
int reg_direction[MAX_BANK]; int reg_direction[MAX_BANK];
int ret, i; int ret, i;
...@@ -737,7 +729,15 @@ static int pca953x_irq_setup(struct pca953x_chip *chip, ...@@ -737,7 +729,15 @@ static int pca953x_irq_setup(struct pca953x_chip *chip,
return ret; return ret;
} }
ret = gpiochip_irqchip_add_nested(&chip->gpio_chip, &pca953x_irq_chip, irq_chip->name = dev_name(&chip->client->dev);
irq_chip->irq_mask = pca953x_irq_mask;
irq_chip->irq_unmask = pca953x_irq_unmask;
irq_chip->irq_bus_lock = pca953x_irq_bus_lock;
irq_chip->irq_bus_sync_unlock = pca953x_irq_bus_sync_unlock;
irq_chip->irq_set_type = pca953x_irq_set_type;
irq_chip->irq_shutdown = pca953x_irq_shutdown;
ret = gpiochip_irqchip_add_nested(&chip->gpio_chip, irq_chip,
irq_base, handle_simple_irq, irq_base, handle_simple_irq,
IRQ_TYPE_NONE); IRQ_TYPE_NONE);
if (ret) { if (ret) {
...@@ -746,8 +746,7 @@ static int pca953x_irq_setup(struct pca953x_chip *chip, ...@@ -746,8 +746,7 @@ static int pca953x_irq_setup(struct pca953x_chip *chip,
return ret; return ret;
} }
gpiochip_set_nested_irqchip(&chip->gpio_chip, &pca953x_irq_chip, gpiochip_set_nested_irqchip(&chip->gpio_chip, irq_chip, client->irq);
client->irq);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment