* [PATCH v2] gpio: sifive: Make the irqchip immutable
@ 2022-05-20 10:24 ` Geert Uytterhoeven
0 siblings, 0 replies; 6+ messages in thread
From: Geert Uytterhoeven @ 2022-05-20 10:24 UTC (permalink / raw)
To: Linus Walleij, Bartosz Golaszewski, Palmer Dabbelt,
Paul Walmsley, Damien Le Moal, Marc Zyngier
Cc: linux-gpio, linux-riscv, Geert Uytterhoeven
Commit 6c846d026d49 ("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 sifive driver:
gpio gpiochip1: (38001000.gpio-controller): not an immutable chip, please consider fixing it!
Fix this by making the irqchip in the sifive driver immutable.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
Against gpio/for-next.
Boot-tested on SiPEED MAiXBiT (Canaan K210).
v2:
- Factor out hwirq using preferred helper.
---
drivers/gpio/gpio-sifive.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/drivers/gpio/gpio-sifive.c b/drivers/gpio/gpio-sifive.c
index 03b8c4de2e91e3c4..238f3210970cfa0e 100644
--- a/drivers/gpio/gpio-sifive.c
+++ b/drivers/gpio/gpio-sifive.c
@@ -75,10 +75,12 @@ static void sifive_gpio_irq_enable(struct irq_data *d)
{
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct sifive_gpio *chip = gpiochip_get_data(gc);
- int offset = irqd_to_hwirq(d) % SIFIVE_GPIO_MAX;
+ irq_hw_number_t hwirq = irqd_to_hwirq(d);
+ int offset = hwirq % SIFIVE_GPIO_MAX;
u32 bit = BIT(offset);
unsigned long flags;
+ gpiochip_enable_irq(gc, hwirq);
irq_chip_enable_parent(d);
/* Switch to input */
@@ -101,11 +103,13 @@ static void sifive_gpio_irq_disable(struct irq_data *d)
{
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct sifive_gpio *chip = gpiochip_get_data(gc);
- int offset = irqd_to_hwirq(d) % SIFIVE_GPIO_MAX;
+ irq_hw_number_t hwirq = irqd_to_hwirq(d);
+ int offset = hwirq % SIFIVE_GPIO_MAX;
assign_bit(offset, &chip->irq_state, 0);
sifive_gpio_set_ie(chip, offset);
irq_chip_disable_parent(d);
+ gpiochip_disable_irq(gc, hwirq);
}
static void sifive_gpio_irq_eoi(struct irq_data *d)
@@ -137,7 +141,7 @@ static int sifive_gpio_irq_set_affinity(struct irq_data *data,
return -EINVAL;
}
-static struct irq_chip sifive_gpio_irqchip = {
+static const struct irq_chip sifive_gpio_irqchip = {
.name = "sifive-gpio",
.irq_set_type = sifive_gpio_irq_set_type,
.irq_mask = irq_chip_mask_parent,
@@ -146,6 +150,8 @@ static struct irq_chip sifive_gpio_irqchip = {
.irq_disable = sifive_gpio_irq_disable,
.irq_eoi = sifive_gpio_irq_eoi,
.irq_set_affinity = sifive_gpio_irq_set_affinity,
+ .flags = IRQCHIP_IMMUTABLE,
+ GPIOCHIP_IRQ_RESOURCE_HELPERS,
};
static int sifive_gpio_child_to_parent_hwirq(struct gpio_chip *gc,
@@ -242,7 +248,7 @@ static int sifive_gpio_probe(struct platform_device *pdev)
chip->gc.parent = dev;
chip->gc.owner = THIS_MODULE;
girq = &chip->gc.irq;
- girq->chip = &sifive_gpio_irqchip;
+ gpio_irq_chip_set_chip(girq, &sifive_gpio_irqchip);
girq->fwnode = of_node_to_fwnode(node);
girq->parent_domain = parent;
girq->child_to_parent_hwirq = sifive_gpio_child_to_parent_hwirq;
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2] gpio: sifive: Make the irqchip immutable
@ 2022-05-20 10:24 ` Geert Uytterhoeven
0 siblings, 0 replies; 6+ messages in thread
From: Geert Uytterhoeven @ 2022-05-20 10:24 UTC (permalink / raw)
To: Linus Walleij, Bartosz Golaszewski, Palmer Dabbelt,
Paul Walmsley, Damien Le Moal, Marc Zyngier
Cc: linux-gpio, linux-riscv, Geert Uytterhoeven
Commit 6c846d026d49 ("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 sifive driver:
gpio gpiochip1: (38001000.gpio-controller): not an immutable chip, please consider fixing it!
Fix this by making the irqchip in the sifive driver immutable.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
Against gpio/for-next.
Boot-tested on SiPEED MAiXBiT (Canaan K210).
v2:
- Factor out hwirq using preferred helper.
---
drivers/gpio/gpio-sifive.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/drivers/gpio/gpio-sifive.c b/drivers/gpio/gpio-sifive.c
index 03b8c4de2e91e3c4..238f3210970cfa0e 100644
--- a/drivers/gpio/gpio-sifive.c
+++ b/drivers/gpio/gpio-sifive.c
@@ -75,10 +75,12 @@ static void sifive_gpio_irq_enable(struct irq_data *d)
{
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct sifive_gpio *chip = gpiochip_get_data(gc);
- int offset = irqd_to_hwirq(d) % SIFIVE_GPIO_MAX;
+ irq_hw_number_t hwirq = irqd_to_hwirq(d);
+ int offset = hwirq % SIFIVE_GPIO_MAX;
u32 bit = BIT(offset);
unsigned long flags;
+ gpiochip_enable_irq(gc, hwirq);
irq_chip_enable_parent(d);
/* Switch to input */
@@ -101,11 +103,13 @@ static void sifive_gpio_irq_disable(struct irq_data *d)
{
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct sifive_gpio *chip = gpiochip_get_data(gc);
- int offset = irqd_to_hwirq(d) % SIFIVE_GPIO_MAX;
+ irq_hw_number_t hwirq = irqd_to_hwirq(d);
+ int offset = hwirq % SIFIVE_GPIO_MAX;
assign_bit(offset, &chip->irq_state, 0);
sifive_gpio_set_ie(chip, offset);
irq_chip_disable_parent(d);
+ gpiochip_disable_irq(gc, hwirq);
}
static void sifive_gpio_irq_eoi(struct irq_data *d)
@@ -137,7 +141,7 @@ static int sifive_gpio_irq_set_affinity(struct irq_data *data,
return -EINVAL;
}
-static struct irq_chip sifive_gpio_irqchip = {
+static const struct irq_chip sifive_gpio_irqchip = {
.name = "sifive-gpio",
.irq_set_type = sifive_gpio_irq_set_type,
.irq_mask = irq_chip_mask_parent,
@@ -146,6 +150,8 @@ static struct irq_chip sifive_gpio_irqchip = {
.irq_disable = sifive_gpio_irq_disable,
.irq_eoi = sifive_gpio_irq_eoi,
.irq_set_affinity = sifive_gpio_irq_set_affinity,
+ .flags = IRQCHIP_IMMUTABLE,
+ GPIOCHIP_IRQ_RESOURCE_HELPERS,
};
static int sifive_gpio_child_to_parent_hwirq(struct gpio_chip *gc,
@@ -242,7 +248,7 @@ static int sifive_gpio_probe(struct platform_device *pdev)
chip->gc.parent = dev;
chip->gc.owner = THIS_MODULE;
girq = &chip->gc.irq;
- girq->chip = &sifive_gpio_irqchip;
+ gpio_irq_chip_set_chip(girq, &sifive_gpio_irqchip);
girq->fwnode = of_node_to_fwnode(node);
girq->parent_domain = parent;
girq->child_to_parent_hwirq = sifive_gpio_child_to_parent_hwirq;
--
2.25.1
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2] gpio: sifive: Make the irqchip immutable
2022-05-20 10:24 ` Geert Uytterhoeven
@ 2022-05-20 13:52 ` Andy Shevchenko
-1 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2022-05-20 13:52 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Linus Walleij, Bartosz Golaszewski, Palmer Dabbelt,
Paul Walmsley, Damien Le Moal, Marc Zyngier,
open list:GPIO SUBSYSTEM, linux-riscv
On Fri, May 20, 2022 at 12:34 PM Geert Uytterhoeven
<geert+renesas@glider.be> wrote:
>
> Commit 6c846d026d49 ("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 sifive driver:
>
> gpio gpiochip1: (38001000.gpio-controller): not an immutable chip, please consider fixing it!
>
> Fix this by making the irqchip in the sifive driver immutable.
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> Against gpio/for-next.
> Boot-tested on SiPEED MAiXBiT (Canaan K210).
>
> v2:
> - Factor out hwirq using preferred helper.
> ---
> drivers/gpio/gpio-sifive.c | 14 ++++++++++----
> 1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpio/gpio-sifive.c b/drivers/gpio/gpio-sifive.c
> index 03b8c4de2e91e3c4..238f3210970cfa0e 100644
> --- a/drivers/gpio/gpio-sifive.c
> +++ b/drivers/gpio/gpio-sifive.c
> @@ -75,10 +75,12 @@ static void sifive_gpio_irq_enable(struct irq_data *d)
> {
> struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
> struct sifive_gpio *chip = gpiochip_get_data(gc);
> - int offset = irqd_to_hwirq(d) % SIFIVE_GPIO_MAX;
> + irq_hw_number_t hwirq = irqd_to_hwirq(d);
> + int offset = hwirq % SIFIVE_GPIO_MAX;
> u32 bit = BIT(offset);
> unsigned long flags;
>
> + gpiochip_enable_irq(gc, hwirq);
> irq_chip_enable_parent(d);
>
> /* Switch to input */
> @@ -101,11 +103,13 @@ static void sifive_gpio_irq_disable(struct irq_data *d)
> {
> struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
> struct sifive_gpio *chip = gpiochip_get_data(gc);
> - int offset = irqd_to_hwirq(d) % SIFIVE_GPIO_MAX;
> + irq_hw_number_t hwirq = irqd_to_hwirq(d);
> + int offset = hwirq % SIFIVE_GPIO_MAX;
>
> assign_bit(offset, &chip->irq_state, 0);
> sifive_gpio_set_ie(chip, offset);
> irq_chip_disable_parent(d);
> + gpiochip_disable_irq(gc, hwirq);
> }
>
> static void sifive_gpio_irq_eoi(struct irq_data *d)
> @@ -137,7 +141,7 @@ static int sifive_gpio_irq_set_affinity(struct irq_data *data,
> return -EINVAL;
> }
>
> -static struct irq_chip sifive_gpio_irqchip = {
> +static const struct irq_chip sifive_gpio_irqchip = {
> .name = "sifive-gpio",
> .irq_set_type = sifive_gpio_irq_set_type,
> .irq_mask = irq_chip_mask_parent,
> @@ -146,6 +150,8 @@ static struct irq_chip sifive_gpio_irqchip = {
> .irq_disable = sifive_gpio_irq_disable,
> .irq_eoi = sifive_gpio_irq_eoi,
> .irq_set_affinity = sifive_gpio_irq_set_affinity,
> + .flags = IRQCHIP_IMMUTABLE,
> + GPIOCHIP_IRQ_RESOURCE_HELPERS,
> };
>
> static int sifive_gpio_child_to_parent_hwirq(struct gpio_chip *gc,
> @@ -242,7 +248,7 @@ static int sifive_gpio_probe(struct platform_device *pdev)
> chip->gc.parent = dev;
> chip->gc.owner = THIS_MODULE;
> girq = &chip->gc.irq;
> - girq->chip = &sifive_gpio_irqchip;
> + gpio_irq_chip_set_chip(girq, &sifive_gpio_irqchip);
> girq->fwnode = of_node_to_fwnode(node);
> girq->parent_domain = parent;
> girq->child_to_parent_hwirq = sifive_gpio_child_to_parent_hwirq;
> --
> 2.25.1
>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] gpio: sifive: Make the irqchip immutable
@ 2022-05-20 13:52 ` Andy Shevchenko
0 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2022-05-20 13:52 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Linus Walleij, Bartosz Golaszewski, Palmer Dabbelt,
Paul Walmsley, Damien Le Moal, Marc Zyngier,
open list:GPIO SUBSYSTEM, linux-riscv
On Fri, May 20, 2022 at 12:34 PM Geert Uytterhoeven
<geert+renesas@glider.be> wrote:
>
> Commit 6c846d026d49 ("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 sifive driver:
>
> gpio gpiochip1: (38001000.gpio-controller): not an immutable chip, please consider fixing it!
>
> Fix this by making the irqchip in the sifive driver immutable.
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> Against gpio/for-next.
> Boot-tested on SiPEED MAiXBiT (Canaan K210).
>
> v2:
> - Factor out hwirq using preferred helper.
> ---
> drivers/gpio/gpio-sifive.c | 14 ++++++++++----
> 1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpio/gpio-sifive.c b/drivers/gpio/gpio-sifive.c
> index 03b8c4de2e91e3c4..238f3210970cfa0e 100644
> --- a/drivers/gpio/gpio-sifive.c
> +++ b/drivers/gpio/gpio-sifive.c
> @@ -75,10 +75,12 @@ static void sifive_gpio_irq_enable(struct irq_data *d)
> {
> struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
> struct sifive_gpio *chip = gpiochip_get_data(gc);
> - int offset = irqd_to_hwirq(d) % SIFIVE_GPIO_MAX;
> + irq_hw_number_t hwirq = irqd_to_hwirq(d);
> + int offset = hwirq % SIFIVE_GPIO_MAX;
> u32 bit = BIT(offset);
> unsigned long flags;
>
> + gpiochip_enable_irq(gc, hwirq);
> irq_chip_enable_parent(d);
>
> /* Switch to input */
> @@ -101,11 +103,13 @@ static void sifive_gpio_irq_disable(struct irq_data *d)
> {
> struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
> struct sifive_gpio *chip = gpiochip_get_data(gc);
> - int offset = irqd_to_hwirq(d) % SIFIVE_GPIO_MAX;
> + irq_hw_number_t hwirq = irqd_to_hwirq(d);
> + int offset = hwirq % SIFIVE_GPIO_MAX;
>
> assign_bit(offset, &chip->irq_state, 0);
> sifive_gpio_set_ie(chip, offset);
> irq_chip_disable_parent(d);
> + gpiochip_disable_irq(gc, hwirq);
> }
>
> static void sifive_gpio_irq_eoi(struct irq_data *d)
> @@ -137,7 +141,7 @@ static int sifive_gpio_irq_set_affinity(struct irq_data *data,
> return -EINVAL;
> }
>
> -static struct irq_chip sifive_gpio_irqchip = {
> +static const struct irq_chip sifive_gpio_irqchip = {
> .name = "sifive-gpio",
> .irq_set_type = sifive_gpio_irq_set_type,
> .irq_mask = irq_chip_mask_parent,
> @@ -146,6 +150,8 @@ static struct irq_chip sifive_gpio_irqchip = {
> .irq_disable = sifive_gpio_irq_disable,
> .irq_eoi = sifive_gpio_irq_eoi,
> .irq_set_affinity = sifive_gpio_irq_set_affinity,
> + .flags = IRQCHIP_IMMUTABLE,
> + GPIOCHIP_IRQ_RESOURCE_HELPERS,
> };
>
> static int sifive_gpio_child_to_parent_hwirq(struct gpio_chip *gc,
> @@ -242,7 +248,7 @@ static int sifive_gpio_probe(struct platform_device *pdev)
> chip->gc.parent = dev;
> chip->gc.owner = THIS_MODULE;
> girq = &chip->gc.irq;
> - girq->chip = &sifive_gpio_irqchip;
> + gpio_irq_chip_set_chip(girq, &sifive_gpio_irqchip);
> girq->fwnode = of_node_to_fwnode(node);
> girq->parent_domain = parent;
> girq->child_to_parent_hwirq = sifive_gpio_child_to_parent_hwirq;
> --
> 2.25.1
>
--
With Best Regards,
Andy Shevchenko
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] gpio: sifive: Make the irqchip immutable
2022-05-20 10:24 ` Geert Uytterhoeven
@ 2022-05-20 23:42 ` Damien Le Moal
-1 siblings, 0 replies; 6+ messages in thread
From: Damien Le Moal @ 2022-05-20 23:42 UTC (permalink / raw)
To: Geert Uytterhoeven, Linus Walleij, Bartosz Golaszewski,
Palmer Dabbelt, Paul Walmsley, Marc Zyngier
Cc: linux-gpio, linux-riscv
On 5/20/22 19:24, Geert Uytterhoeven wrote:
> Commit 6c846d026d49 ("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 sifive driver:
>
> gpio gpiochip1: (38001000.gpio-controller): not an immutable chip, please consider fixing it!
>
> Fix this by making the irqchip in the sifive driver immutable.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> Against gpio/for-next.
> Boot-tested on SiPEED MAiXBiT (Canaan K210).
>
> v2:
> - Factor out hwirq using preferred helper.
> ---
> drivers/gpio/gpio-sifive.c | 14 ++++++++++----
> 1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpio/gpio-sifive.c b/drivers/gpio/gpio-sifive.c
> index 03b8c4de2e91e3c4..238f3210970cfa0e 100644
> --- a/drivers/gpio/gpio-sifive.c
> +++ b/drivers/gpio/gpio-sifive.c
> @@ -75,10 +75,12 @@ static void sifive_gpio_irq_enable(struct irq_data *d)
> {
> struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
> struct sifive_gpio *chip = gpiochip_get_data(gc);
> - int offset = irqd_to_hwirq(d) % SIFIVE_GPIO_MAX;
> + irq_hw_number_t hwirq = irqd_to_hwirq(d);
> + int offset = hwirq % SIFIVE_GPIO_MAX;
> u32 bit = BIT(offset);
> unsigned long flags;
>
> + gpiochip_enable_irq(gc, hwirq);
> irq_chip_enable_parent(d);
>
> /* Switch to input */
> @@ -101,11 +103,13 @@ static void sifive_gpio_irq_disable(struct irq_data *d)
> {
> struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
> struct sifive_gpio *chip = gpiochip_get_data(gc);
> - int offset = irqd_to_hwirq(d) % SIFIVE_GPIO_MAX;
> + irq_hw_number_t hwirq = irqd_to_hwirq(d);
> + int offset = hwirq % SIFIVE_GPIO_MAX;
>
> assign_bit(offset, &chip->irq_state, 0);
> sifive_gpio_set_ie(chip, offset);
> irq_chip_disable_parent(d);
> + gpiochip_disable_irq(gc, hwirq);
> }
>
> static void sifive_gpio_irq_eoi(struct irq_data *d)
> @@ -137,7 +141,7 @@ static int sifive_gpio_irq_set_affinity(struct irq_data *data,
> return -EINVAL;
> }
>
> -static struct irq_chip sifive_gpio_irqchip = {
> +static const struct irq_chip sifive_gpio_irqchip = {
> .name = "sifive-gpio",
> .irq_set_type = sifive_gpio_irq_set_type,
> .irq_mask = irq_chip_mask_parent,
> @@ -146,6 +150,8 @@ static struct irq_chip sifive_gpio_irqchip = {
> .irq_disable = sifive_gpio_irq_disable,
> .irq_eoi = sifive_gpio_irq_eoi,
> .irq_set_affinity = sifive_gpio_irq_set_affinity,
> + .flags = IRQCHIP_IMMUTABLE,
> + GPIOCHIP_IRQ_RESOURCE_HELPERS,
> };
>
> static int sifive_gpio_child_to_parent_hwirq(struct gpio_chip *gc,
> @@ -242,7 +248,7 @@ static int sifive_gpio_probe(struct platform_device *pdev)
> chip->gc.parent = dev;
> chip->gc.owner = THIS_MODULE;
> girq = &chip->gc.irq;
> - girq->chip = &sifive_gpio_irqchip;
> + gpio_irq_chip_set_chip(girq, &sifive_gpio_irqchip);
> girq->fwnode = of_node_to_fwnode(node);
> girq->parent_domain = parent;
> girq->child_to_parent_hwirq = sifive_gpio_child_to_parent_hwirq;
Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] gpio: sifive: Make the irqchip immutable
@ 2022-05-20 23:42 ` Damien Le Moal
0 siblings, 0 replies; 6+ messages in thread
From: Damien Le Moal @ 2022-05-20 23:42 UTC (permalink / raw)
To: Geert Uytterhoeven, Linus Walleij, Bartosz Golaszewski,
Palmer Dabbelt, Paul Walmsley, Marc Zyngier
Cc: linux-gpio, linux-riscv
On 5/20/22 19:24, Geert Uytterhoeven wrote:
> Commit 6c846d026d49 ("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 sifive driver:
>
> gpio gpiochip1: (38001000.gpio-controller): not an immutable chip, please consider fixing it!
>
> Fix this by making the irqchip in the sifive driver immutable.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> Against gpio/for-next.
> Boot-tested on SiPEED MAiXBiT (Canaan K210).
>
> v2:
> - Factor out hwirq using preferred helper.
> ---
> drivers/gpio/gpio-sifive.c | 14 ++++++++++----
> 1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpio/gpio-sifive.c b/drivers/gpio/gpio-sifive.c
> index 03b8c4de2e91e3c4..238f3210970cfa0e 100644
> --- a/drivers/gpio/gpio-sifive.c
> +++ b/drivers/gpio/gpio-sifive.c
> @@ -75,10 +75,12 @@ static void sifive_gpio_irq_enable(struct irq_data *d)
> {
> struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
> struct sifive_gpio *chip = gpiochip_get_data(gc);
> - int offset = irqd_to_hwirq(d) % SIFIVE_GPIO_MAX;
> + irq_hw_number_t hwirq = irqd_to_hwirq(d);
> + int offset = hwirq % SIFIVE_GPIO_MAX;
> u32 bit = BIT(offset);
> unsigned long flags;
>
> + gpiochip_enable_irq(gc, hwirq);
> irq_chip_enable_parent(d);
>
> /* Switch to input */
> @@ -101,11 +103,13 @@ static void sifive_gpio_irq_disable(struct irq_data *d)
> {
> struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
> struct sifive_gpio *chip = gpiochip_get_data(gc);
> - int offset = irqd_to_hwirq(d) % SIFIVE_GPIO_MAX;
> + irq_hw_number_t hwirq = irqd_to_hwirq(d);
> + int offset = hwirq % SIFIVE_GPIO_MAX;
>
> assign_bit(offset, &chip->irq_state, 0);
> sifive_gpio_set_ie(chip, offset);
> irq_chip_disable_parent(d);
> + gpiochip_disable_irq(gc, hwirq);
> }
>
> static void sifive_gpio_irq_eoi(struct irq_data *d)
> @@ -137,7 +141,7 @@ static int sifive_gpio_irq_set_affinity(struct irq_data *data,
> return -EINVAL;
> }
>
> -static struct irq_chip sifive_gpio_irqchip = {
> +static const struct irq_chip sifive_gpio_irqchip = {
> .name = "sifive-gpio",
> .irq_set_type = sifive_gpio_irq_set_type,
> .irq_mask = irq_chip_mask_parent,
> @@ -146,6 +150,8 @@ static struct irq_chip sifive_gpio_irqchip = {
> .irq_disable = sifive_gpio_irq_disable,
> .irq_eoi = sifive_gpio_irq_eoi,
> .irq_set_affinity = sifive_gpio_irq_set_affinity,
> + .flags = IRQCHIP_IMMUTABLE,
> + GPIOCHIP_IRQ_RESOURCE_HELPERS,
> };
>
> static int sifive_gpio_child_to_parent_hwirq(struct gpio_chip *gc,
> @@ -242,7 +248,7 @@ static int sifive_gpio_probe(struct platform_device *pdev)
> chip->gc.parent = dev;
> chip->gc.owner = THIS_MODULE;
> girq = &chip->gc.irq;
> - girq->chip = &sifive_gpio_irqchip;
> + gpio_irq_chip_set_chip(girq, &sifive_gpio_irqchip);
> girq->fwnode = of_node_to_fwnode(node);
> girq->parent_domain = parent;
> girq->child_to_parent_hwirq = sifive_gpio_child_to_parent_hwirq;
Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
--
Damien Le Moal
Western Digital Research
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-05-20 23:42 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-20 10:24 [PATCH v2] gpio: sifive: Make the irqchip immutable Geert Uytterhoeven
2022-05-20 10:24 ` Geert Uytterhoeven
2022-05-20 13:52 ` Andy Shevchenko
2022-05-20 13:52 ` Andy Shevchenko
2022-05-20 23:42 ` Damien Le Moal
2022-05-20 23:42 ` Damien Le Moal
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.