* [PATCH 1/4] gpio: 104-dio-48e: Make irq_chip immutable
2022-09-02 17:45 [PATCH 0/4] Make irq_chip immutable for ISA drivers William Breathitt Gray
@ 2022-09-02 17:45 ` William Breathitt Gray
2022-09-02 17:45 ` [PATCH 2/4] gpio: 104-idi-48: " William Breathitt Gray
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: William Breathitt Gray @ 2022-09-02 17:45 UTC (permalink / raw)
To: brgl, linus.walleij; +Cc: linux-gpio, linux-kernel, William Breathitt Gray
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 <william.gray@linaro.org>
---
drivers/gpio/gpio-104-dio-48e.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/gpio/gpio-104-dio-48e.c b/drivers/gpio/gpio-104-dio-48e.c
index a41551870759..74cc71bb3984 100644
--- a/drivers/gpio/gpio-104-dio-48e.c
+++ b/drivers/gpio/gpio-104-dio-48e.c
@@ -164,6 +164,7 @@ static void dio48e_irq_mask(struct irq_data *data)
dio48egpio->irq_mask &= ~BIT(0);
else
dio48egpio->irq_mask &= ~BIT(1);
+ gpiochip_disable_irq(chip, offset);
if (!dio48egpio->irq_mask)
/* disable interrupts */
@@ -191,6 +192,7 @@ static void dio48e_irq_unmask(struct irq_data *data)
iowrite8(0x00, &dio48egpio->reg->enable_interrupt);
}
+ gpiochip_enable_irq(chip, offset);
if (offset == 19)
dio48egpio->irq_mask |= BIT(0);
else
@@ -213,12 +215,14 @@ static int dio48e_irq_set_type(struct irq_data *data, unsigned int flow_type)
return 0;
}
-static struct irq_chip dio48e_irqchip = {
+static const struct irq_chip dio48e_irqchip = {
.name = "104-dio-48e",
.irq_ack = dio48e_irq_ack,
.irq_mask = dio48e_irq_mask,
.irq_unmask = dio48e_irq_unmask,
- .irq_set_type = dio48e_irq_set_type
+ .irq_set_type = dio48e_irq_set_type,
+ .flags = IRQCHIP_IMMUTABLE,
+ GPIOCHIP_IRQ_RESOURCE_HELPERS,
};
static irqreturn_t dio48e_irq_handler(int irq, void *dev_id)
@@ -322,7 +326,7 @@ static int dio48e_probe(struct device *dev, unsigned int id)
dio48egpio->chip.set_multiple = dio48e_gpio_set_multiple;
girq = &dio48egpio->chip.irq;
- girq->chip = &dio48e_irqchip;
+ gpio_irq_chip_set_chip(girq, &dio48e_irqchip);
/* This will let us handle the parent IRQ in the driver */
girq->parent_handler = NULL;
girq->num_parents = 0;
--
2.37.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/4] gpio: 104-idi-48: Make irq_chip immutable
2022-09-02 17:45 [PATCH 0/4] Make irq_chip immutable for ISA drivers William Breathitt Gray
2022-09-02 17:45 ` [PATCH 1/4] gpio: 104-dio-48e: Make irq_chip immutable William Breathitt Gray
@ 2022-09-02 17:45 ` William Breathitt Gray
2022-09-02 17:45 ` [PATCH 3/4] gpio: 104-idio-16: " William Breathitt Gray
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: William Breathitt Gray @ 2022-09-02 17:45 UTC (permalink / raw)
To: brgl, linus.walleij; +Cc: linux-gpio, linux-kernel, William Breathitt Gray
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 <william.gray@linaro.org>
---
drivers/gpio/gpio-104-idi-48.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/gpio/gpio-104-idi-48.c b/drivers/gpio/gpio-104-idi-48.c
index 40be76efeed7..3286b914a2cf 100644
--- a/drivers/gpio/gpio-104-idi-48.c
+++ b/drivers/gpio/gpio-104-idi-48.c
@@ -113,6 +113,7 @@ static void idi_48_irq_mask(struct irq_data *data)
spin_lock_irqsave(&idi48gpio->lock, flags);
idi48gpio->irq_mask[boundary] &= ~mask;
+ gpiochip_disable_irq(chip, offset);
/* Exit early if there are still input lines with IRQ unmasked */
if (idi48gpio->irq_mask[boundary])
@@ -140,6 +141,7 @@ static void idi_48_irq_unmask(struct irq_data *data)
prev_irq_mask = idi48gpio->irq_mask[boundary];
+ gpiochip_enable_irq(chip, offset);
idi48gpio->irq_mask[boundary] |= mask;
/* Exit early if IRQ was already unmasked for this boundary */
@@ -164,12 +166,14 @@ static int idi_48_irq_set_type(struct irq_data *data, unsigned int flow_type)
return 0;
}
-static struct irq_chip idi_48_irqchip = {
+static const struct irq_chip idi_48_irqchip = {
.name = "104-idi-48",
.irq_ack = idi_48_irq_ack,
.irq_mask = idi_48_irq_mask,
.irq_unmask = idi_48_irq_unmask,
- .irq_set_type = idi_48_irq_set_type
+ .irq_set_type = idi_48_irq_set_type,
+ .flags = IRQCHIP_IMMUTABLE,
+ GPIOCHIP_IRQ_RESOURCE_HELPERS,
};
static irqreturn_t idi_48_irq_handler(int irq, void *dev_id)
@@ -267,7 +271,7 @@ static int idi_48_probe(struct device *dev, unsigned int id)
idi48gpio->chip.get_multiple = idi_48_gpio_get_multiple;
girq = &idi48gpio->chip.irq;
- girq->chip = &idi_48_irqchip;
+ gpio_irq_chip_set_chip(girq, &idi_48_irqchip);
/* This will let us handle the parent IRQ in the driver */
girq->parent_handler = NULL;
girq->num_parents = 0;
--
2.37.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/4] gpio: 104-idio-16: Make irq_chip immutable
2022-09-02 17:45 [PATCH 0/4] Make irq_chip immutable for ISA drivers William Breathitt Gray
2022-09-02 17:45 ` [PATCH 1/4] gpio: 104-dio-48e: Make irq_chip immutable William Breathitt Gray
2022-09-02 17:45 ` [PATCH 2/4] gpio: 104-idi-48: " William Breathitt Gray
@ 2022-09-02 17:45 ` William Breathitt Gray
2022-09-02 17:45 ` [PATCH 4/4] gpio: ws16c48: " William Breathitt Gray
2022-09-03 21:10 ` [PATCH 0/4] Make irq_chip immutable for ISA drivers Bartosz Golaszewski
4 siblings, 0 replies; 6+ messages in thread
From: William Breathitt Gray @ 2022-09-02 17:45 UTC (permalink / raw)
To: brgl, linus.walleij
Cc: linux-gpio, linux-kernel, William Breathitt Gray, Frede
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 <william.gray@linaro.org>
---
drivers/gpio/gpio-104-idio-16.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/drivers/gpio/gpio-104-idio-16.c b/drivers/gpio/gpio-104-idio-16.c
index 65a5f581d981..4756e583f223 100644
--- a/drivers/gpio/gpio-104-idio-16.c
+++ b/drivers/gpio/gpio-104-idio-16.c
@@ -174,10 +174,11 @@ static void idio_16_irq_mask(struct irq_data *data)
{
struct gpio_chip *chip = irq_data_get_irq_chip_data(data);
struct idio_16_gpio *const idio16gpio = gpiochip_get_data(chip);
- const unsigned long mask = BIT(irqd_to_hwirq(data));
+ const unsigned long offset = irqd_to_hwirq(data);
unsigned long flags;
- idio16gpio->irq_mask &= ~mask;
+ idio16gpio->irq_mask &= ~BIT(offset);
+ gpiochip_disable_irq(chip, offset);
if (!idio16gpio->irq_mask) {
raw_spin_lock_irqsave(&idio16gpio->lock, flags);
@@ -192,11 +193,12 @@ static void idio_16_irq_unmask(struct irq_data *data)
{
struct gpio_chip *chip = irq_data_get_irq_chip_data(data);
struct idio_16_gpio *const idio16gpio = gpiochip_get_data(chip);
- const unsigned long mask = BIT(irqd_to_hwirq(data));
+ const unsigned long offset = irqd_to_hwirq(data);
const unsigned long prev_irq_mask = idio16gpio->irq_mask;
unsigned long flags;
- idio16gpio->irq_mask |= mask;
+ gpiochip_enable_irq(chip, offset);
+ idio16gpio->irq_mask |= BIT(offset);
if (!prev_irq_mask) {
raw_spin_lock_irqsave(&idio16gpio->lock, flags);
@@ -217,12 +219,14 @@ static int idio_16_irq_set_type(struct irq_data *data, unsigned int flow_type)
return 0;
}
-static struct irq_chip idio_16_irqchip = {
+static const struct irq_chip idio_16_irqchip = {
.name = "104-idio-16",
.irq_ack = idio_16_irq_ack,
.irq_mask = idio_16_irq_mask,
.irq_unmask = idio_16_irq_unmask,
- .irq_set_type = idio_16_irq_set_type
+ .irq_set_type = idio_16_irq_set_type,
+ .flags = IRQCHIP_IMMUTABLE,
+ GPIOCHIP_IRQ_RESOURCE_HELPERS,
};
static irqreturn_t idio_16_irq_handler(int irq, void *dev_id)
@@ -299,7 +303,7 @@ static int idio_16_probe(struct device *dev, unsigned int id)
idio16gpio->out_state = 0xFFFF;
girq = &idio16gpio->chip.irq;
- girq->chip = &idio_16_irqchip;
+ gpio_irq_chip_set_chip(girq, &idio_16_irqchip);
/* This will let us handle the parent IRQ in the driver */
girq->parent_handler = NULL;
girq->num_parents = 0;
--
2.37.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 4/4] gpio: ws16c48: Make irq_chip immutable
2022-09-02 17:45 [PATCH 0/4] Make irq_chip immutable for ISA drivers William Breathitt Gray
` (2 preceding siblings ...)
2022-09-02 17:45 ` [PATCH 3/4] gpio: 104-idio-16: " William Breathitt Gray
@ 2022-09-02 17:45 ` William Breathitt Gray
2022-09-03 21:10 ` [PATCH 0/4] Make irq_chip immutable for ISA drivers Bartosz Golaszewski
4 siblings, 0 replies; 6+ messages in thread
From: William Breathitt Gray @ 2022-09-02 17:45 UTC (permalink / raw)
To: brgl, linus.walleij; +Cc: linux-gpio, linux-kernel, William Breathitt Gray
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 <william.gray@linaro.org>
---
drivers/gpio/gpio-ws16c48.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/gpio/gpio-ws16c48.c b/drivers/gpio/gpio-ws16c48.c
index b098f2dc196b..59fb10641598 100644
--- a/drivers/gpio/gpio-ws16c48.c
+++ b/drivers/gpio/gpio-ws16c48.c
@@ -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 */
@@ -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);
@@ -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)
@@ -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;
--
2.37.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 0/4] Make irq_chip immutable for ISA drivers
2022-09-02 17:45 [PATCH 0/4] Make irq_chip immutable for ISA drivers William Breathitt Gray
` (3 preceding siblings ...)
2022-09-02 17:45 ` [PATCH 4/4] gpio: ws16c48: " William Breathitt Gray
@ 2022-09-03 21:10 ` Bartosz Golaszewski
4 siblings, 0 replies; 6+ messages in thread
From: Bartosz Golaszewski @ 2022-09-03 21:10 UTC (permalink / raw)
To: William Breathitt Gray
Cc: Linus Walleij, open list:GPIO SUBSYSTEM,
Linux Kernel Mailing List
On Fri, Sep 2, 2022 at 11:40 PM William Breathitt Gray
<william.gray@linaro.org> wrote:
>
> Kernel warns about mutable irq_chips in ISA drivers:
>
> "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.
>
> William Breathitt Gray (4):
> gpio: 104-dio-48e: Make irq_chip immutable
> gpio: 104-idi-48: Make irq_chip immutable
> gpio: 104-idio-16: Make irq_chip immutable
> gpio: ws16c48: Make irq_chip immutable
>
> drivers/gpio/gpio-104-dio-48e.c | 10 +++++++---
> drivers/gpio/gpio-104-idi-48.c | 10 +++++++---
> drivers/gpio/gpio-104-idio-16.c | 18 +++++++++++-------
> drivers/gpio/gpio-ws16c48.c | 10 +++++++---
> 4 files changed, 32 insertions(+), 16 deletions(-)
>
>
> base-commit: 6ae8e1d0d5e5de922315830aea975c63e8c70b2f
> --
> 2.37.2
>
Queued for fixes, thanks!
Bart
^ permalink raw reply [flat|nested] 6+ messages in thread