aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/apic
diff options
context:
space:
mode:
authorJeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>2009-06-08 06:24:11 -0400
committerJeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>2009-07-14 16:32:50 -0400
commit875e68ec32fc5495f3edf987aaae1c52306184b7 (patch)
tree818f673786ecb64a93482f053718db56de6b7308 /arch/x86/kernel/apic
parentd8c52063ed85dda61b70bc05b90711478db5dc17 (diff)
x86/ioapic.c: simplify add_pin_to_irq_node()
Rather than duplicating the same alloc/init code twice, restructure the function to look for duplicates and then add an entry if none is found. This function is not performance critical; all but one of its callers are __init functions, and the non-__init caller is for PCI device setup. Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Diffstat (limited to 'arch/x86/kernel/apic')
-rw-r--r--arch/x86/kernel/apic/io_apic.c28
1 files changed, 8 insertions, 20 deletions
diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index 0d0401802d4f..d9e8f19088d4 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -490,34 +490,22 @@ static void ioapic_mask_entry(int apic, int pin)
490 */ 490 */
491static void add_pin_to_irq_node(struct irq_cfg *cfg, int node, int apic, int pin) 491static void add_pin_to_irq_node(struct irq_cfg *cfg, int node, int apic, int pin)
492{ 492{
493 struct irq_pin_list *entry; 493 struct irq_pin_list **entryp, *entry;
494 494
495 entry = cfg->irq_2_pin; 495 for (entryp = &cfg->irq_2_pin;
496 if (!entry) { 496 *entryp != NULL;
497 entry = get_one_free_irq_2_pin(node); 497 entryp = &(*entryp)->next) {
498 if (!entry) { 498 entry = *entryp;
499 printk(KERN_ERR "can not alloc irq_2_pin to add %d - %d\n",
500 apic, pin);
501 return;
502 }
503 cfg->irq_2_pin = entry;
504 entry->apic = apic;
505 entry->pin = pin;
506 return;
507 }
508
509 while (entry->next) {
510 /* not again, please */ 499 /* not again, please */
511 if (entry->apic == apic && entry->pin == pin) 500 if (entry->apic == apic && entry->pin == pin)
512 return; 501 return;
513
514 entry = entry->next;
515 } 502 }
516 503
517 entry->next = get_one_free_irq_2_pin(node); 504 entry = get_one_free_irq_2_pin(node);
518 entry = entry->next;
519 entry->apic = apic; 505 entry->apic = apic;
520 entry->pin = pin; 506 entry->pin = pin;
507
508 *entryp = entry;
521} 509}
522 510
523/* 511/*