Commit 24a4f4e4 authored by Herve Codina's avatar Herve Codina Committed by Thomas Gleixner

irqdomain: Convert __irq_domain_create() to use struct irq_domain_info

The existing __irq_domain_create() use a bunch of parameters to create
an irq domain.

With the introduction of irq_domain_info structure, these parameters are
available in the information structure itself.
Using directly this information structure allows future flexibility to
add other parameters in a simple way without the need to change the
__irq_domain_create() prototype.

Convert __irq_domain_create() to use the information structure.

[ tglx: Fixup struct initializer ]
Suggested-by: default avatarThomas Gleixner <tglx@linutronix.de>
Signed-off-by: default avatarHerve Codina <herve.codina@bootlin.com>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20240614173232.1184015-7-herve.codina@bootlin.com
parent dbd56abf
...@@ -179,45 +179,40 @@ static int irq_domain_set_name(struct irq_domain *domain, ...@@ -179,45 +179,40 @@ static int irq_domain_set_name(struct irq_domain *domain,
return 0; return 0;
} }
static struct irq_domain *__irq_domain_create(struct fwnode_handle *fwnode, static struct irq_domain *__irq_domain_create(const struct irq_domain_info *info)
unsigned int size,
irq_hw_number_t hwirq_max,
int direct_max,
const struct irq_domain_ops *ops,
void *host_data)
{ {
struct irq_domain *domain; struct irq_domain *domain;
int err; int err;
if (WARN_ON((size && direct_max) || if (WARN_ON((info->size && info->direct_max) ||
(!IS_ENABLED(CONFIG_IRQ_DOMAIN_NOMAP) && direct_max) || (!IS_ENABLED(CONFIG_IRQ_DOMAIN_NOMAP) && info->direct_max) ||
(direct_max && direct_max != hwirq_max))) (info->direct_max && info->direct_max != info->hwirq_max)))
return NULL; return NULL;
domain = kzalloc_node(struct_size(domain, revmap, size), domain = kzalloc_node(struct_size(domain, revmap, info->size),
GFP_KERNEL, of_node_to_nid(to_of_node(fwnode))); GFP_KERNEL, of_node_to_nid(to_of_node(info->fwnode)));
if (!domain) if (!domain)
return NULL; return NULL;
err = irq_domain_set_name(domain, fwnode); err = irq_domain_set_name(domain, info->fwnode);
if (err) { if (err) {
kfree(domain); kfree(domain);
return NULL; return NULL;
} }
domain->fwnode = fwnode_handle_get(fwnode); domain->fwnode = fwnode_handle_get(info->fwnode);
fwnode_dev_initialized(domain->fwnode, true); fwnode_dev_initialized(domain->fwnode, true);
/* Fill structure */ /* Fill structure */
INIT_RADIX_TREE(&domain->revmap_tree, GFP_KERNEL); INIT_RADIX_TREE(&domain->revmap_tree, GFP_KERNEL);
domain->ops = ops; domain->ops = info->ops;
domain->host_data = host_data; domain->host_data = info->host_data;
domain->hwirq_max = hwirq_max; domain->hwirq_max = info->hwirq_max;
if (direct_max) if (info->direct_max)
domain->flags |= IRQ_DOMAIN_FLAG_NO_MAP; domain->flags |= IRQ_DOMAIN_FLAG_NO_MAP;
domain->revmap_size = size; domain->revmap_size = info->size;
/* /*
* Hierarchical domains use the domain lock of the root domain * Hierarchical domains use the domain lock of the root domain
...@@ -264,8 +259,7 @@ struct irq_domain *irq_domain_instantiate(const struct irq_domain_info *info) ...@@ -264,8 +259,7 @@ struct irq_domain *irq_domain_instantiate(const struct irq_domain_info *info)
{ {
struct irq_domain *domain; struct irq_domain *domain;
domain = __irq_domain_create(info->fwnode, info->size, info->hwirq_max, domain = __irq_domain_create(info);
info->direct_max, info->ops, info->host_data);
if (!domain) if (!domain)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
...@@ -1204,13 +1198,19 @@ struct irq_domain *irq_domain_create_hierarchy(struct irq_domain *parent, ...@@ -1204,13 +1198,19 @@ struct irq_domain *irq_domain_create_hierarchy(struct irq_domain *parent,
const struct irq_domain_ops *ops, const struct irq_domain_ops *ops,
void *host_data) void *host_data)
{ {
struct irq_domain_info info = {
.fwnode = fwnode,
.size = size,
.hwirq_max = size,
.ops = ops,
.host_data = host_data,
};
struct irq_domain *domain; struct irq_domain *domain;
if (size) if (!info.size)
domain = __irq_domain_create(fwnode, size, size, 0, ops, host_data); info.hwirq_max = ~0U;
else
domain = __irq_domain_create(fwnode, 0, ~0, 0, ops, host_data);
domain = __irq_domain_create(&info);
if (domain) { if (domain) {
if (parent) if (parent)
domain->root = parent->root; domain->root = parent->root;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment