Skip to content

Commit

Permalink
gpio: ws16c48: Make irq_chip immutable
Browse files Browse the repository at this point in the history
Kernel warns about mutable irq_chips:

    "not an immutable chip, please consider fixing!"

Make the struct irq_chip const, flag it as IRQCHIP_IMMUTABLE, add the
new helper functions, and call the appropriate gpiolib functions.

Signed-off-by: William Breathitt Gray <[email protected]>
Signed-off-by: Bartosz Golaszewski <[email protected]>
  • Loading branch information
vilhelmgray authored and brgl committed Sep 3, 2022
1 parent 410a504 commit 6890381
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions drivers/gpio/gpio-ws16c48.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ static void ws16c48_irq_mask(struct irq_data *data)
raw_spin_lock_irqsave(&ws16c48gpio->lock, flags);

ws16c48gpio->irq_mask &= ~mask;
gpiochip_disable_irq(chip, offset);
port_state = ws16c48gpio->irq_mask >> (8 * port);

/* Select Register Page 2; Unlock all I/O ports */
Expand Down Expand Up @@ -295,6 +296,7 @@ static void ws16c48_irq_unmask(struct irq_data *data)

raw_spin_lock_irqsave(&ws16c48gpio->lock, flags);

gpiochip_enable_irq(chip, offset);
ws16c48gpio->irq_mask |= mask;
port_state = ws16c48gpio->irq_mask >> (8 * port);

Expand Down Expand Up @@ -356,12 +358,14 @@ static int ws16c48_irq_set_type(struct irq_data *data, unsigned flow_type)
return 0;
}

static struct irq_chip ws16c48_irqchip = {
static const struct irq_chip ws16c48_irqchip = {
.name = "ws16c48",
.irq_ack = ws16c48_irq_ack,
.irq_mask = ws16c48_irq_mask,
.irq_unmask = ws16c48_irq_unmask,
.irq_set_type = ws16c48_irq_set_type
.irq_set_type = ws16c48_irq_set_type,
.flags = IRQCHIP_IMMUTABLE,
GPIOCHIP_IRQ_RESOURCE_HELPERS,
};

static irqreturn_t ws16c48_irq_handler(int irq, void *dev_id)
Expand Down Expand Up @@ -463,7 +467,7 @@ static int ws16c48_probe(struct device *dev, unsigned int id)
ws16c48gpio->chip.set_multiple = ws16c48_gpio_set_multiple;

girq = &ws16c48gpio->chip.irq;
girq->chip = &ws16c48_irqchip;
gpio_irq_chip_set_chip(girq, &ws16c48_irqchip);
/* This will let us handle the parent IRQ in the driver */
girq->parent_handler = NULL;
girq->num_parents = 0;
Expand Down

0 comments on commit 6890381

Please sign in to comment.