ia64/xen-unstable

changeset 9641:70837ac15cad

Fix remove_pin_at_irq(), introduced with changeset
9586:f84a333d8aa6e1a25e2b73b07610e95007267f6a.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Sat Apr 08 11:01:17 2006 +0100 (2006-04-08)
parents 12621916d820
children e36892ad4144
files xen/arch/x86/io_apic.c
line diff
     1.1 --- a/xen/arch/x86/io_apic.c	Sat Apr 08 09:05:53 2006 +0100
     1.2 +++ b/xen/arch/x86/io_apic.c	Sat Apr 08 11:01:17 2006 +0100
     1.3 @@ -110,7 +110,6 @@ static void add_pin_to_irq(unsigned int 
     1.4  static void remove_pin_at_irq(unsigned int irq, int apic, int pin)
     1.5  {
     1.6      struct irq_pin_list *entry, *prev;
     1.7 -    int idx;
     1.8  
     1.9      for (entry = &irq_2_pin[irq]; ; entry = &irq_2_pin[entry->next]) {
    1.10          if ((entry->apic == apic) && (entry->pin == pin))
    1.11 @@ -119,18 +118,24 @@ static void remove_pin_at_irq(unsigned i
    1.12              BUG();
    1.13      }
    1.14  
    1.15 -    entry->pin  = -1;
    1.16 -    entry->apic = -1;
    1.17 +    entry->pin = entry->apic = -1;
    1.18      
    1.19 -    idx = entry - irq_2_pin;
    1.20 -    if (idx >= NR_IRQS) {
    1.21 -        while (prev->next != idx)
    1.22 +    if (entry != &irq_2_pin[irq]) {
    1.23 +        /* Removed entry is not at head of list. */
    1.24 +        prev = &irq_2_pin[irq];
    1.25 +        while (&irq_2_pin[prev->next] != entry)
    1.26              prev = &irq_2_pin[prev->next];
    1.27          prev->next = entry->next;
    1.28          entry->next = irq_2_pin_free_entry;
    1.29 -        irq_2_pin_free_entry = idx;
    1.30 -    } else {
    1.31 -        entry->next = 0;
    1.32 +        irq_2_pin_free_entry = entry - irq_2_pin;
    1.33 +    } else if (entry->next != 0) {
    1.34 +        /* Removed entry is at head of multi-item list. */
    1.35 +        prev  = entry;
    1.36 +        entry = &irq_2_pin[entry->next];
    1.37 +        *prev = *entry;
    1.38 +        entry->pin = entry->apic = -1;
    1.39 +        entry->next = irq_2_pin_free_entry;
    1.40 +        irq_2_pin_free_entry = entry - irq_2_pin;
    1.41      }
    1.42  }
    1.43