summaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/apic
diff options
context:
space:
mode:
authorJeremy Fitzhardinge2009-06-08 12:24:11 +0200
committerJeremy Fitzhardinge2009-07-14 22:32:50 +0200
commit875e68ec32fc5495f3edf987aaae1c52306184b7 (patch)
tree818f673786ecb64a93482f053718db56de6b7308 /arch/x86/kernel/apic
parentx86/ioapic.c: convert io_apic_level_ack_pending loop to normal for() loop (diff)
downloadkernel-qcow2-linux-875e68ec32fc5495f3edf987aaae1c52306184b7.tar.gz
kernel-qcow2-linux-875e68ec32fc5495f3edf987aaae1c52306184b7.tar.xz
kernel-qcow2-linux-875e68ec32fc5495f3edf987aaae1c52306184b7.zip
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)
*/
static void add_pin_to_irq_node(struct irq_cfg *cfg, int node, int apic, int pin)
{
- struct irq_pin_list *entry;
+ struct irq_pin_list **entryp, *entry;
- entry = cfg->irq_2_pin;
- if (!entry) {
- entry = get_one_free_irq_2_pin(node);
- if (!entry) {
- printk(KERN_ERR "can not alloc irq_2_pin to add %d - %d\n",
- apic, pin);
- return;
- }
- cfg->irq_2_pin = entry;
- entry->apic = apic;
- entry->pin = pin;
- return;
- }
-
- while (entry->next) {
+ for (entryp = &cfg->irq_2_pin;
+ *entryp != NULL;
+ entryp = &(*entryp)->next) {
+ entry = *entryp;
/* not again, please */
if (entry->apic == apic && entry->pin == pin)
return;
-
- entry = entry->next;
}
- entry->next = get_one_free_irq_2_pin(node);
- entry = entry->next;
+ entry = get_one_free_irq_2_pin(node);
entry->apic = apic;
entry->pin = pin;
+
+ *entryp = entry;
}
/*