aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/irq
diff options
context:
space:
mode:
authorDavid Daney <david.daney@cavium.com>2017-08-17 20:53:32 -0400
committerThomas Gleixner <tglx@linutronix.de>2017-08-18 05:21:41 -0400
commitb526adfe1b0531fceba44b18c156e4edf9c6205c (patch)
treea3a68ff629961b85ed4083b00ab7acbae15770bb /kernel/irq
parent7703b08cc93b3586f9eb733f3a2b10bed634a5cf (diff)
irqdomain: Factor out code to add and remove items to and from the revmap
The code to add and remove items to and from the revmap occurs several times. In preparation for the follow on patches that add more uses of this code, factor this out in to separate static functions. Signed-off-by: David Daney <david.daney@cavium.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Marc Zyngier <marc.zyngier@arm.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Alexandre Courbot <gnurou@gmail.com> Cc: Linus Walleij <linus.walleij@linaro.org> Cc: linux-gpio@vger.kernel.org Link: http://lkml.kernel.org/r/1503017616-3252-4-git-send-email-david.daney@cavium.com
Diffstat (limited to 'kernel/irq')
-rw-r--r--kernel/irq/irqdomain.c58
1 files changed, 29 insertions, 29 deletions
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index f1f251479aa6..2093b88ce9b7 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -455,6 +455,31 @@ void irq_set_default_host(struct irq_domain *domain)
455} 455}
456EXPORT_SYMBOL_GPL(irq_set_default_host); 456EXPORT_SYMBOL_GPL(irq_set_default_host);
457 457
458static void irq_domain_clear_mapping(struct irq_domain *domain,
459 irq_hw_number_t hwirq)
460{
461 if (hwirq < domain->revmap_size) {
462 domain->linear_revmap[hwirq] = 0;
463 } else {
464 mutex_lock(&revmap_trees_mutex);
465 radix_tree_delete(&domain->revmap_tree, hwirq);
466 mutex_unlock(&revmap_trees_mutex);
467 }
468}
469
470static void irq_domain_set_mapping(struct irq_domain *domain,
471 irq_hw_number_t hwirq,
472 struct irq_data *irq_data)
473{
474 if (hwirq < domain->revmap_size) {
475 domain->linear_revmap[hwirq] = irq_data->irq;
476 } else {
477 mutex_lock(&revmap_trees_mutex);
478 radix_tree_insert(&domain->revmap_tree, hwirq, irq_data);
479 mutex_unlock(&revmap_trees_mutex);
480 }
481}
482
458void irq_domain_disassociate(struct irq_domain *domain, unsigned int irq) 483void irq_domain_disassociate(struct irq_domain *domain, unsigned int irq)
459{ 484{
460 struct irq_data *irq_data = irq_get_irq_data(irq); 485 struct irq_data *irq_data = irq_get_irq_data(irq);
@@ -483,13 +508,7 @@ void irq_domain_disassociate(struct irq_domain *domain, unsigned int irq)
483 domain->mapcount--; 508 domain->mapcount--;
484 509
485 /* Clear reverse map for this hwirq */ 510 /* Clear reverse map for this hwirq */
486 if (hwirq < domain->revmap_size) { 511 irq_domain_clear_mapping(domain, hwirq);
487 domain->linear_revmap[hwirq] = 0;
488 } else {
489 mutex_lock(&revmap_trees_mutex);
490 radix_tree_delete(&domain->revmap_tree, hwirq);
491 mutex_unlock(&revmap_trees_mutex);
492 }
493} 512}
494 513
495int irq_domain_associate(struct irq_domain *domain, unsigned int virq, 514int irq_domain_associate(struct irq_domain *domain, unsigned int virq,
@@ -533,13 +552,7 @@ int irq_domain_associate(struct irq_domain *domain, unsigned int virq,
533 } 552 }
534 553
535 domain->mapcount++; 554 domain->mapcount++;
536 if (hwirq < domain->revmap_size) { 555 irq_domain_set_mapping(domain, hwirq, irq_data);
537 domain->linear_revmap[hwirq] = virq;
538 } else {
539 mutex_lock(&revmap_trees_mutex);
540 radix_tree_insert(&domain->revmap_tree, hwirq, irq_data);
541 mutex_unlock(&revmap_trees_mutex);
542 }
543 mutex_unlock(&irq_domain_mutex); 556 mutex_unlock(&irq_domain_mutex);
544 557
545 irq_clear_status_flags(virq, IRQ_NOREQUEST); 558 irq_clear_status_flags(virq, IRQ_NOREQUEST);
@@ -1138,16 +1151,9 @@ static void irq_domain_insert_irq(int virq)
1138 1151
1139 for (data = irq_get_irq_data(virq); data; data = data->parent_data) { 1152 for (data = irq_get_irq_data(virq); data; data = data->parent_data) {
1140 struct irq_domain *domain = data->domain; 1153 struct irq_domain *domain = data->domain;
1141 irq_hw_number_t hwirq = data->hwirq;
1142 1154
1143 domain->mapcount++; 1155 domain->mapcount++;
1144 if (hwirq < domain->revmap_size) { 1156 irq_domain_set_mapping(domain, data->hwirq, data);
1145 domain->linear_revmap[hwirq] = virq;
1146 } else {
1147 mutex_lock(&revmap_trees_mutex);
1148 radix_tree_insert(&domain->revmap_tree, hwirq, data);
1149 mutex_unlock(&revmap_trees_mutex);
1150 }
1151 1157
1152 /* If not already assigned, give the domain the chip's name */ 1158 /* If not already assigned, give the domain the chip's name */
1153 if (!domain->name && data->chip) 1159 if (!domain->name && data->chip)
@@ -1171,13 +1177,7 @@ static void irq_domain_remove_irq(int virq)
1171 irq_hw_number_t hwirq = data->hwirq; 1177 irq_hw_number_t hwirq = data->hwirq;
1172 1178
1173 domain->mapcount--; 1179 domain->mapcount--;
1174 if (hwirq < domain->revmap_size) { 1180 irq_domain_clear_mapping(domain, hwirq);
1175 domain->linear_revmap[hwirq] = 0;
1176 } else {
1177 mutex_lock(&revmap_trees_mutex);
1178 radix_tree_delete(&domain->revmap_tree, hwirq);
1179 mutex_unlock(&revmap_trees_mutex);
1180 }
1181 } 1181 }
1182} 1182}
1183 1183