Skip to content

Commit ac2f6f9

Browse files
geertubrgl
authored andcommitted
gpio: pca953x: Make the irqchip immutable
Commit 6c846d0 ("gpio: Don't fiddle with irqchips marked as immutable") added a warning to indicate if the gpiolib is altering the internals of irqchips. Following this change the following warning is now observed for the pca953x driver: gpio gpiochip7: (0-0020): not an immutable chip, please consider fixing it! Fix this by making the irqchip in the pca953x driver immutable. Signed-off-by: Geert Uytterhoeven <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent cfc2b00 commit ac2f6f9

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

drivers/gpio/gpio-pca953x.c

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ struct pca953x_chip {
201201
DECLARE_BITMAP(irq_stat, MAX_LINE);
202202
DECLARE_BITMAP(irq_trig_raise, MAX_LINE);
203203
DECLARE_BITMAP(irq_trig_fall, MAX_LINE);
204-
struct irq_chip irq_chip;
205204
#endif
206205
atomic_t wakeup_path;
207206

@@ -629,6 +628,7 @@ static void pca953x_irq_mask(struct irq_data *d)
629628
irq_hw_number_t hwirq = irqd_to_hwirq(d);
630629

631630
clear_bit(hwirq, chip->irq_mask);
631+
gpiochip_disable_irq(gc, hwirq);
632632
}
633633

634634
static void pca953x_irq_unmask(struct irq_data *d)
@@ -637,6 +637,7 @@ static void pca953x_irq_unmask(struct irq_data *d)
637637
struct pca953x_chip *chip = gpiochip_get_data(gc);
638638
irq_hw_number_t hwirq = irqd_to_hwirq(d);
639639

640+
gpiochip_enable_irq(gc, hwirq);
640641
set_bit(hwirq, chip->irq_mask);
641642
}
642643

@@ -721,6 +722,26 @@ static void pca953x_irq_shutdown(struct irq_data *d)
721722
clear_bit(hwirq, chip->irq_trig_fall);
722723
}
723724

725+
static void pca953x_irq_print_chip(struct irq_data *data, struct seq_file *p)
726+
{
727+
struct gpio_chip *gc = irq_data_get_irq_chip_data(data);
728+
729+
seq_printf(p, dev_name(gc->parent));
730+
}
731+
732+
static const struct irq_chip pca953x_irq_chip = {
733+
.irq_mask = pca953x_irq_mask,
734+
.irq_unmask = pca953x_irq_unmask,
735+
.irq_set_wake = pca953x_irq_set_wake,
736+
.irq_bus_lock = pca953x_irq_bus_lock,
737+
.irq_bus_sync_unlock = pca953x_irq_bus_sync_unlock,
738+
.irq_set_type = pca953x_irq_set_type,
739+
.irq_shutdown = pca953x_irq_shutdown,
740+
.irq_print_chip = pca953x_irq_print_chip,
741+
.flags = IRQCHIP_IMMUTABLE,
742+
GPIOCHIP_IRQ_RESOURCE_HELPERS,
743+
};
744+
724745
static bool pca953x_irq_pending(struct pca953x_chip *chip, unsigned long *pending)
725746
{
726747
struct gpio_chip *gc = &chip->gpio_chip;
@@ -812,7 +833,6 @@ static irqreturn_t pca953x_irq_handler(int irq, void *devid)
812833
static int pca953x_irq_setup(struct pca953x_chip *chip, int irq_base)
813834
{
814835
struct i2c_client *client = chip->client;
815-
struct irq_chip *irq_chip = &chip->irq_chip;
816836
DECLARE_BITMAP(reg_direction, MAX_LINE);
817837
DECLARE_BITMAP(irq_stat, MAX_LINE);
818838
struct gpio_irq_chip *girq;
@@ -846,17 +866,8 @@ static int pca953x_irq_setup(struct pca953x_chip *chip, int irq_base)
846866
bitmap_and(chip->irq_stat, irq_stat, reg_direction, chip->gpio_chip.ngpio);
847867
mutex_init(&chip->irq_lock);
848868

849-
irq_chip->name = dev_name(&client->dev);
850-
irq_chip->irq_mask = pca953x_irq_mask;
851-
irq_chip->irq_unmask = pca953x_irq_unmask;
852-
irq_chip->irq_set_wake = pca953x_irq_set_wake;
853-
irq_chip->irq_bus_lock = pca953x_irq_bus_lock;
854-
irq_chip->irq_bus_sync_unlock = pca953x_irq_bus_sync_unlock;
855-
irq_chip->irq_set_type = pca953x_irq_set_type;
856-
irq_chip->irq_shutdown = pca953x_irq_shutdown;
857-
858869
girq = &chip->gpio_chip.irq;
859-
girq->chip = irq_chip;
870+
gpio_irq_chip_set_chip(girq, &pca953x_irq_chip);
860871
/* This will let us handle the parent IRQ in the driver */
861872
girq->parent_handler = NULL;
862873
girq->num_parents = 0;

0 commit comments

Comments
 (0)