irqdomain: Introduce irq_resolve_mapping()
Rework irq_find_mapping() to return an both an irq_desc pointer, optionally the virtual irq number, and rename the result to __irq_resolve_mapping(). a new helper called irq_resolve_mapping() is provided for code that doesn't need the virtual irq number. irq_find_mapping() is also rewritten in terms of __irq_resolve_mapping(). Signed-off-by: Marc Zyngier <maz@kernel.org>
This commit is contained in:
parent
d4a45c68dc
commit
d22558dd0a
2 changed files with 41 additions and 10 deletions
|
@ -41,6 +41,7 @@ struct fwnode_handle;
|
||||||
struct irq_domain;
|
struct irq_domain;
|
||||||
struct irq_chip;
|
struct irq_chip;
|
||||||
struct irq_data;
|
struct irq_data;
|
||||||
|
struct irq_desc;
|
||||||
struct cpumask;
|
struct cpumask;
|
||||||
struct seq_file;
|
struct seq_file;
|
||||||
struct irq_affinity_desc;
|
struct irq_affinity_desc;
|
||||||
|
@ -401,13 +402,31 @@ static inline unsigned int irq_create_mapping(struct irq_domain *host,
|
||||||
return irq_create_mapping_affinity(host, hwirq, NULL);
|
return irq_create_mapping_affinity(host, hwirq, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern struct irq_desc *__irq_resolve_mapping(struct irq_domain *domain,
|
||||||
|
irq_hw_number_t hwirq,
|
||||||
|
unsigned int *irq);
|
||||||
|
|
||||||
|
static inline struct irq_desc *irq_resolve_mapping(struct irq_domain *domain,
|
||||||
|
irq_hw_number_t hwirq)
|
||||||
|
{
|
||||||
|
return __irq_resolve_mapping(domain, hwirq, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* irq_find_mapping() - Find a linux irq from a hw irq number.
|
* irq_find_mapping() - Find a linux irq from a hw irq number.
|
||||||
* @domain: domain owning this hardware interrupt
|
* @domain: domain owning this hardware interrupt
|
||||||
* @hwirq: hardware irq number in that domain space
|
* @hwirq: hardware irq number in that domain space
|
||||||
*/
|
*/
|
||||||
extern unsigned int irq_find_mapping(struct irq_domain *host,
|
static inline unsigned int irq_find_mapping(struct irq_domain *domain,
|
||||||
irq_hw_number_t hwirq);
|
irq_hw_number_t hwirq)
|
||||||
|
{
|
||||||
|
unsigned int irq;
|
||||||
|
|
||||||
|
if (__irq_resolve_mapping(domain, hwirq, &irq))
|
||||||
|
return irq;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static inline unsigned int irq_linear_revmap(struct irq_domain *domain,
|
static inline unsigned int irq_linear_revmap(struct irq_domain *domain,
|
||||||
irq_hw_number_t hwirq)
|
irq_hw_number_t hwirq)
|
||||||
|
|
|
@ -884,29 +884,34 @@ void irq_dispose_mapping(unsigned int virq)
|
||||||
EXPORT_SYMBOL_GPL(irq_dispose_mapping);
|
EXPORT_SYMBOL_GPL(irq_dispose_mapping);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* irq_find_mapping() - Find a linux irq from a hw irq number.
|
* __irq_resolve_mapping() - Find a linux irq from a hw irq number.
|
||||||
* @domain: domain owning this hardware interrupt
|
* @domain: domain owning this hardware interrupt
|
||||||
* @hwirq: hardware irq number in that domain space
|
* @hwirq: hardware irq number in that domain space
|
||||||
|
* @irq: optional pointer to return the Linux irq if required
|
||||||
|
*
|
||||||
|
* Returns the interrupt descriptor.
|
||||||
*/
|
*/
|
||||||
unsigned int irq_find_mapping(struct irq_domain *domain,
|
struct irq_desc *__irq_resolve_mapping(struct irq_domain *domain,
|
||||||
irq_hw_number_t hwirq)
|
irq_hw_number_t hwirq,
|
||||||
|
unsigned int *irq)
|
||||||
{
|
{
|
||||||
|
struct irq_desc *desc = NULL;
|
||||||
struct irq_data *data;
|
struct irq_data *data;
|
||||||
|
|
||||||
/* Look for default domain if necessary */
|
/* Look for default domain if necessary */
|
||||||
if (domain == NULL)
|
if (domain == NULL)
|
||||||
domain = irq_default_domain;
|
domain = irq_default_domain;
|
||||||
if (domain == NULL)
|
if (domain == NULL)
|
||||||
return 0;
|
return desc;
|
||||||
|
|
||||||
if (irq_domain_is_nomap(domain)) {
|
if (irq_domain_is_nomap(domain)) {
|
||||||
if (hwirq < domain->revmap_size) {
|
if (hwirq < domain->revmap_size) {
|
||||||
data = irq_domain_get_irq_data(domain, hwirq);
|
data = irq_domain_get_irq_data(domain, hwirq);
|
||||||
if (data && data->hwirq == hwirq)
|
if (data && data->hwirq == hwirq)
|
||||||
return hwirq;
|
desc = irq_data_to_desc(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
rcu_read_lock();
|
rcu_read_lock();
|
||||||
|
@ -915,10 +920,17 @@ unsigned int irq_find_mapping(struct irq_domain *domain,
|
||||||
data = rcu_dereference(domain->revmap[hwirq]);
|
data = rcu_dereference(domain->revmap[hwirq]);
|
||||||
else
|
else
|
||||||
data = radix_tree_lookup(&domain->revmap_tree, hwirq);
|
data = radix_tree_lookup(&domain->revmap_tree, hwirq);
|
||||||
|
|
||||||
|
if (likely(data)) {
|
||||||
|
desc = irq_data_to_desc(data);
|
||||||
|
if (irq)
|
||||||
|
*irq = data->irq;
|
||||||
|
}
|
||||||
|
|
||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
return data ? data->irq : 0;
|
return desc;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(irq_find_mapping);
|
EXPORT_SYMBOL_GPL(__irq_resolve_mapping);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* irq_domain_xlate_onecell() - Generic xlate for direct one cell bindings
|
* irq_domain_xlate_onecell() - Generic xlate for direct one cell bindings
|
||||||
|
|
Loading…
Add table
Reference in a new issue