2023-06-21 17:52:48

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v1 1/5] gpiolib: Make gpiochip_hierarchy_add_domain() return domain

As a preparatory patch and for the sake of consistency, make
gpiochip_hierarchy_add_domain() return IRQ domain. While at it,
rename it to gpiochip_hierarchy_create_domain() to show
the change.

Signed-off-by: Andy Shevchenko <[email protected]>
---
drivers/gpio/gpiolib.c | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 0d25d9d439a2..058deaa1aa36 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1289,12 +1289,14 @@ static void gpiochip_hierarchy_setup_domain_ops(struct irq_domain_ops *ops)
ops->free = irq_domain_free_irqs_common;
}

-static int gpiochip_hierarchy_add_domain(struct gpio_chip *gc)
+static struct irq_domain *gpiochip_hierarchy_create_domain(struct gpio_chip *gc)
{
+ struct irq_domain *domain;
+
if (!gc->irq.child_to_parent_hwirq ||
!gc->irq.fwnode) {
chip_err(gc, "missing irqdomain vital data\n");
- return -EINVAL;
+ return ERR_PTR(-EINVAL);
}

if (!gc->irq.child_offset_to_irq)
@@ -1306,7 +1308,7 @@ static int gpiochip_hierarchy_add_domain(struct gpio_chip *gc)

gpiochip_hierarchy_setup_domain_ops(&gc->irq.child_irq_domain_ops);

- gc->irq.domain = irq_domain_create_hierarchy(
+ domain = irq_domain_create_hierarchy(
gc->irq.parent_domain,
0,
gc->ngpio,
@@ -1314,12 +1316,12 @@ static int gpiochip_hierarchy_add_domain(struct gpio_chip *gc)
&gc->irq.child_irq_domain_ops,
gc);

- if (!gc->irq.domain)
- return -ENOMEM;
+ if (!domain)
+ return ERR_PTR(-ENOMEM);

gpiochip_set_hierarchical_irqchip(gc, gc->irq.chip);

- return 0;
+ return domain;
}

static bool gpiochip_hierarchy_is_hierarchical(struct gpio_chip *gc)
@@ -1363,9 +1365,9 @@ EXPORT_SYMBOL_GPL(gpiochip_populate_parent_fwspec_fourcell);

#else

-static int gpiochip_hierarchy_add_domain(struct gpio_chip *gc)
+static struct irq_domain *gpiochip_hierarchy_create_domain(struct gpio_chip *gc)
{
- return -EINVAL;
+ return ERR_PTR(-EINVAL);
}

static bool gpiochip_hierarchy_is_hierarchical(struct gpio_chip *gc)
@@ -1664,9 +1666,9 @@ static int gpiochip_add_irqchip(struct gpio_chip *gc,

/* If a parent irqdomain is provided, let's build a hierarchy */
if (gpiochip_hierarchy_is_hierarchical(gc)) {
- int ret = gpiochip_hierarchy_add_domain(gc);
- if (ret)
- return ret;
+ gc->irq.domain = gpiochip_hierarchy_create_domain(gc);
+ if (IS_ERR(gc->irq.domain))
+ return PTR_ERR(gc->irq.domain);
} else {
gc->irq.domain = irq_domain_create_simple(fwnode,
gc->ngpio,
--
2.40.0.1.gaa8946217a0b



2023-06-21 18:03:21

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v1 3/5] gpiolib: Do not assign error pointer to the GPIO IRQ chip domain

Check domain for being an error pointer before assigning it to
the GPIO IRQ chip domain.

Signed-off-by: Andy Shevchenko <[email protected]>
---
drivers/gpio/gpiolib.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index fac1124d5016..0e40f9a44519 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1647,6 +1647,7 @@ static int gpiochip_add_irqchip(struct gpio_chip *gc,
{
struct fwnode_handle *fwnode = dev_fwnode(&gc->gpiodev->dev);
struct irq_chip *irqchip = gc->irq.chip;
+ struct irq_domain *domain;
unsigned int type;
unsigned int i;

@@ -1679,14 +1680,13 @@ static int gpiochip_add_irqchip(struct gpio_chip *gc,

/* If a parent irqdomain is provided, let's build a hierarchy */
if (gpiochip_hierarchy_is_hierarchical(gc)) {
- gc->irq.domain = gpiochip_hierarchy_create_domain(gc);
- if (IS_ERR(gc->irq.domain))
- return PTR_ERR(gc->irq.domain);
+ domain = gpiochip_hierarchy_create_domain(gc);
} else {
- gc->irq.domain = gpiochip_simple_create_domain(gc);
- if (IS_ERR(gc->irq.domain))
- return PTR_ERR(gc->irq.domain);
+ domain = gpiochip_simple_create_domain(gc);
}
+ if (IS_ERR(domain))
+ return PTR_ERR(domain);
+ gc->irq.domain = domain;

if (gc->irq.parent_handler) {
for (i = 0; i < gc->irq.num_parents; i++) {
--
2.40.0.1.gaa8946217a0b


2023-06-30 12:30:29

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH v1 1/5] gpiolib: Make gpiochip_hierarchy_add_domain() return domain

On Wed, Jun 21, 2023 at 7:49 PM Andy Shevchenko
<[email protected]> wrote:

> As a preparatory patch and for the sake of consistency, make
> gpiochip_hierarchy_add_domain() return IRQ domain. While at it,
> rename it to gpiochip_hierarchy_create_domain() to show
> the change.
>
> Signed-off-by: Andy Shevchenko <[email protected]>

Looks good!
Reviewed-by: Linus Walleij <[email protected]>

Yours,
Linus Walleij

2023-06-30 12:33:05

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH v1 3/5] gpiolib: Do not assign error pointer to the GPIO IRQ chip domain

On Wed, Jun 21, 2023 at 7:49 PM Andy Shevchenko
<[email protected]> wrote:

> Check domain for being an error pointer before assigning it to
> the GPIO IRQ chip domain.
>
> Signed-off-by: Andy Shevchenko <[email protected]>

And this concludes patches 1,2,3, nice!
Reviewed-by: Linus Walleij <[email protected]>

Yours,
Linus Walleij

2023-07-10 09:40:22

by Bartosz Golaszewski

[permalink] [raw]
Subject: Re: [PATCH v1 1/5] gpiolib: Make gpiochip_hierarchy_add_domain() return domain

On Wed, Jun 21, 2023 at 7:49 PM Andy Shevchenko
<[email protected]> wrote:
>
> As a preparatory patch and for the sake of consistency, make
> gpiochip_hierarchy_add_domain() return IRQ domain. While at it,
> rename it to gpiochip_hierarchy_create_domain() to show
> the change.
>
> Signed-off-by: Andy Shevchenko <[email protected]>
> ---

Series applied, thanks!

Bart