Skip to content

Commit d22558d

Browse files
author
Marc Zyngier
committed
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 <[email protected]>
1 parent d4a45c6 commit d22558d

File tree

2 files changed

+41
-10
lines changed

2 files changed

+41
-10
lines changed

include/linux/irqdomain.h

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ struct fwnode_handle;
4141
struct irq_domain;
4242
struct irq_chip;
4343
struct irq_data;
44+
struct irq_desc;
4445
struct cpumask;
4546
struct seq_file;
4647
struct irq_affinity_desc;
@@ -401,13 +402,31 @@ static inline unsigned int irq_create_mapping(struct irq_domain *host,
401402
return irq_create_mapping_affinity(host, hwirq, NULL);
402403
}
403404

405+
extern struct irq_desc *__irq_resolve_mapping(struct irq_domain *domain,
406+
irq_hw_number_t hwirq,
407+
unsigned int *irq);
408+
409+
static inline struct irq_desc *irq_resolve_mapping(struct irq_domain *domain,
410+
irq_hw_number_t hwirq)
411+
{
412+
return __irq_resolve_mapping(domain, hwirq, NULL);
413+
}
414+
404415
/**
405416
* irq_find_mapping() - Find a linux irq from a hw irq number.
406417
* @domain: domain owning this hardware interrupt
407418
* @hwirq: hardware irq number in that domain space
408419
*/
409-
extern unsigned int irq_find_mapping(struct irq_domain *host,
410-
irq_hw_number_t hwirq);
420+
static inline unsigned int irq_find_mapping(struct irq_domain *domain,
421+
irq_hw_number_t hwirq)
422+
{
423+
unsigned int irq;
424+
425+
if (__irq_resolve_mapping(domain, hwirq, &irq))
426+
return irq;
427+
428+
return 0;
429+
}
411430

412431
static inline unsigned int irq_linear_revmap(struct irq_domain *domain,
413432
irq_hw_number_t hwirq)

kernel/irq/irqdomain.c

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -884,29 +884,34 @@ void irq_dispose_mapping(unsigned int virq)
884884
EXPORT_SYMBOL_GPL(irq_dispose_mapping);
885885

886886
/**
887-
* irq_find_mapping() - Find a linux irq from a hw irq number.
887+
* __irq_resolve_mapping() - Find a linux irq from a hw irq number.
888888
* @domain: domain owning this hardware interrupt
889889
* @hwirq: hardware irq number in that domain space
890+
* @irq: optional pointer to return the Linux irq if required
891+
*
892+
* Returns the interrupt descriptor.
890893
*/
891-
unsigned int irq_find_mapping(struct irq_domain *domain,
892-
irq_hw_number_t hwirq)
894+
struct irq_desc *__irq_resolve_mapping(struct irq_domain *domain,
895+
irq_hw_number_t hwirq,
896+
unsigned int *irq)
893897
{
898+
struct irq_desc *desc = NULL;
894899
struct irq_data *data;
895900

896901
/* Look for default domain if necessary */
897902
if (domain == NULL)
898903
domain = irq_default_domain;
899904
if (domain == NULL)
900-
return 0;
905+
return desc;
901906

902907
if (irq_domain_is_nomap(domain)) {
903908
if (hwirq < domain->revmap_size) {
904909
data = irq_domain_get_irq_data(domain, hwirq);
905910
if (data && data->hwirq == hwirq)
906-
return hwirq;
911+
desc = irq_data_to_desc(data);
907912
}
908913

909-
return 0;
914+
return desc;
910915
}
911916

912917
rcu_read_lock();
@@ -915,10 +920,17 @@ unsigned int irq_find_mapping(struct irq_domain *domain,
915920
data = rcu_dereference(domain->revmap[hwirq]);
916921
else
917922
data = radix_tree_lookup(&domain->revmap_tree, hwirq);
923+
924+
if (likely(data)) {
925+
desc = irq_data_to_desc(data);
926+
if (irq)
927+
*irq = data->irq;
928+
}
929+
918930
rcu_read_unlock();
919-
return data ? data->irq : 0;
931+
return desc;
920932
}
921-
EXPORT_SYMBOL_GPL(irq_find_mapping);
933+
EXPORT_SYMBOL_GPL(__irq_resolve_mapping);
922934

923935
/**
924936
* irq_domain_xlate_onecell() - Generic xlate for direct one cell bindings

0 commit comments

Comments
 (0)