[PATCH v2 50/57] irqdomain: Use irq_domain_instantiate() retvals as initializers

From: Jiri Slaby (SUSE)
Date: Wed Mar 19 2025 - 05:44:53 EST


I was thinking whether add a \n before the 'return' or this. And this
looks both more compact and more readable.

Note irq_domain_create_hierarchy()'s handling of size is now part of
info's initializer (using the ternary operator). That makes more sense
while reading it.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@xxxxxxxxxx>
---
include/linux/irqdomain.h | 17 +++++------------
1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h
index d5c9e32ff0a2..bf52a08f3255 100644
--- a/include/linux/irqdomain.h
+++ b/include/linux/irqdomain.h
@@ -403,9 +403,8 @@ static inline struct irq_domain *irq_domain_create_nomap(struct fwnode_handle *f
.ops = ops,
.host_data = host_data,
};
- struct irq_domain *d;
+ struct irq_domain *d = irq_domain_instantiate(&info);

- d = irq_domain_instantiate(&info);
return IS_ERR(d) ? NULL : d;
}

@@ -424,9 +423,8 @@ static inline struct irq_domain *irq_domain_create_linear(struct fwnode_handle *
.ops = ops,
.host_data = host_data,
};
- struct irq_domain *d;
+ struct irq_domain *d = irq_domain_instantiate(&info);

- d = irq_domain_instantiate(&info);
return IS_ERR(d) ? NULL : d;
}

@@ -440,9 +438,8 @@ static inline struct irq_domain *irq_domain_create_tree(struct fwnode_handle *fw
.ops = ops,
.host_data = host_data,
};
- struct irq_domain *d;
+ struct irq_domain *d = irq_domain_instantiate(&info);

- d = irq_domain_instantiate(&info);
return IS_ERR(d) ? NULL : d;
}

@@ -554,18 +551,14 @@ static inline struct irq_domain *irq_domain_create_hierarchy(struct irq_domain *
struct irq_domain_info info = {
.fwnode = fwnode,
.size = size,
- .hwirq_max = size,
+ .hwirq_max = size ? : ~0U,
.ops = ops,
.host_data = host_data,
.domain_flags = flags,
.parent = parent,
};
- struct irq_domain *d;
-
- if (!info.size)
- info.hwirq_max = ~0U;
+ struct irq_domain *d = irq_domain_instantiate(&info);

- d = irq_domain_instantiate(&info);
return IS_ERR(d) ? NULL : d;
}

--
2.49.0