Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 875e68ec authored by Jeremy Fitzhardinge's avatar Jeremy Fitzhardinge
Browse files

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: default avatarJeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
parent d8c52063
Loading
Loading
Loading
Loading
+8 −20
Original line number Original line Diff line number Diff line
@@ -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)
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;
	for (entryp = &cfg->irq_2_pin;
	if (!entry) {
	     *entryp != NULL;
		entry = get_one_free_irq_2_pin(node);
	     entryp = &(*entryp)->next) {
		if (!entry) {
		entry = *entryp;
			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) {
		/* not again, please */
		/* not again, please */
		if (entry->apic == apic && entry->pin == pin)
		if (entry->apic == apic && entry->pin == pin)
			return;
			return;

		entry = entry->next;
	}
	}


	entry->next = get_one_free_irq_2_pin(node);
	entry = get_one_free_irq_2_pin(node);
	entry = entry->next;
	entry->apic = apic;
	entry->apic = apic;
	entry->pin = pin;
	entry->pin = pin;

	*entryp = entry;
}
}


/*
/*