aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCyrill Gorcunov <gorcunov@openvz.org>2009-08-01 03:47:59 -0400
committerIngo Molnar <mingo@elte.hu>2009-08-05 04:30:49 -0400
commit2977fb3ffc8493a2f4f0a362e8660a6cde9f1bb9 (patch)
tree29a3ea6d05c83a07a841af7c498f678209455a05
parent25f6e89bedd29cc49bfa0d55497e91a671b9ae6e (diff)
x86, ioapic: Introduce for_each_irq_pin() helper
This allow us to save a few lines of code. Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org> Cc: yinghai@kernel.org LKML-Reference: <20090801075435.597863129@openvz.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--arch/x86/kernel/apic/io_apic.c43
1 files changed, 15 insertions, 28 deletions
diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index 7e92a9212fd7..ffd8fdfcbe4c 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -66,6 +66,8 @@
66#include <asm/apic.h> 66#include <asm/apic.h>
67 67
68#define __apicdebuginit(type) static type __init 68#define __apicdebuginit(type) static type __init
69#define for_each_irq_pin(entry, head) \
70 for (entry = head; entry; entry = entry->next)
69 71
70/* 72/*
71 * Is the SiS APIC rmw bug present ? 73 * Is the SiS APIC rmw bug present ?
@@ -410,7 +412,7 @@ static bool io_apic_level_ack_pending(struct irq_cfg *cfg)
410 unsigned long flags; 412 unsigned long flags;
411 413
412 spin_lock_irqsave(&ioapic_lock, flags); 414 spin_lock_irqsave(&ioapic_lock, flags);
413 for (entry = cfg->irq_2_pin; entry != NULL; entry = entry->next) { 415 for_each_irq_pin(entry, cfg->irq_2_pin) {
414 unsigned int reg; 416 unsigned int reg;
415 int pin; 417 int pin;
416 418
@@ -490,22 +492,21 @@ static void ioapic_mask_entry(int apic, int pin)
490 */ 492 */
491static void add_pin_to_irq_node(struct irq_cfg *cfg, int node, int apic, int pin) 493static void add_pin_to_irq_node(struct irq_cfg *cfg, int node, int apic, int pin)
492{ 494{
493 struct irq_pin_list **entryp, *entry; 495 struct irq_pin_list **last, *entry;
494 496
495 for (entryp = &cfg->irq_2_pin; 497 /* don't allow duplicates */
496 *entryp != NULL; 498 last = &cfg->irq_2_pin;
497 entryp = &(*entryp)->next) { 499 for_each_irq_pin(entry, cfg->irq_2_pin) {
498 entry = *entryp;
499 /* not again, please */
500 if (entry->apic == apic && entry->pin == pin) 500 if (entry->apic == apic && entry->pin == pin)
501 return; 501 return;
502 last = &entry->next;
502 } 503 }
503 504
504 entry = get_one_free_irq_2_pin(node); 505 entry = get_one_free_irq_2_pin(node);
505 entry->apic = apic; 506 entry->apic = apic;
506 entry->pin = pin; 507 entry->pin = pin;
507 508
508 *entryp = entry; 509 *last = entry;
509} 510}
510 511
511/* 512/*
@@ -517,7 +518,7 @@ static void __init replace_pin_at_irq_node(struct irq_cfg *cfg, int node,
517{ 518{
518 struct irq_pin_list *entry; 519 struct irq_pin_list *entry;
519 520
520 for (entry = cfg->irq_2_pin; entry != NULL; entry = entry->next) { 521 for_each_irq_pin(entry, cfg->irq_2_pin) {
521 if (entry->apic == oldapic && entry->pin == oldpin) { 522 if (entry->apic == oldapic && entry->pin == oldpin) {
522 entry->apic = newapic; 523 entry->apic = newapic;
523 entry->pin = newpin; 524 entry->pin = newpin;
@@ -537,7 +538,7 @@ static void io_apic_modify_irq(struct irq_cfg *cfg,
537 int pin; 538 int pin;
538 struct irq_pin_list *entry; 539 struct irq_pin_list *entry;
539 540
540 for (entry = cfg->irq_2_pin; entry != NULL; entry = entry->next) { 541 for_each_irq_pin(entry, cfg->irq_2_pin) {
541 unsigned int reg; 542 unsigned int reg;
542 pin = entry->pin; 543 pin = entry->pin;
543 reg = io_apic_read(entry->apic, 0x10 + pin * 2); 544 reg = io_apic_read(entry->apic, 0x10 + pin * 2);
@@ -1669,12 +1670,8 @@ __apicdebuginit(void) print_IO_APIC(void)
1669 if (!entry) 1670 if (!entry)
1670 continue; 1671 continue;
1671 printk(KERN_DEBUG "IRQ%d ", irq); 1672 printk(KERN_DEBUG "IRQ%d ", irq);
1672 for (;;) { 1673 for_each_irq_pin(entry, cfg->irq_2_pin)
1673 printk("-> %d:%d", entry->apic, entry->pin); 1674 printk("-> %d:%d", entry->apic, entry->pin);
1674 if (!entry->next)
1675 break;
1676 entry = entry->next;
1677 }
1678 printk("\n"); 1675 printk("\n");
1679 } 1676 }
1680 1677
@@ -2227,7 +2224,7 @@ static void __target_IO_APIC_irq(unsigned int irq, unsigned int dest, struct irq
2227 struct irq_pin_list *entry; 2224 struct irq_pin_list *entry;
2228 u8 vector = cfg->vector; 2225 u8 vector = cfg->vector;
2229 2226
2230 for (entry = cfg->irq_2_pin; entry != NULL; entry = entry->next) { 2227 for_each_irq_pin(entry, cfg->irq_2_pin) {
2231 unsigned int reg; 2228 unsigned int reg;
2232 2229
2233 apic = entry->apic; 2230 apic = entry->apic;
@@ -2556,20 +2553,10 @@ static void ack_apic_level(unsigned int irq)
2556#ifdef CONFIG_INTR_REMAP 2553#ifdef CONFIG_INTR_REMAP
2557static void __eoi_ioapic_irq(unsigned int irq, struct irq_cfg *cfg) 2554static void __eoi_ioapic_irq(unsigned int irq, struct irq_cfg *cfg)
2558{ 2555{
2559 int apic, pin;
2560 struct irq_pin_list *entry; 2556 struct irq_pin_list *entry;
2561 2557
2562 entry = cfg->irq_2_pin; 2558 for_each_irq_pin(entry, cfg->irq_2_pin)
2563 for (;;) { 2559 io_apic_eoi(entry->apic, entry->pin);
2564
2565 if (!entry)
2566 break;
2567
2568 apic = entry->apic;
2569 pin = entry->pin;
2570 io_apic_eoi(apic, pin);
2571 entry = entry->next;
2572 }
2573} 2560}
2574 2561
2575static void 2562static void