diff options
Diffstat (limited to 'arch')
-rw-r--r-- | arch/i386/kernel/io_apic.c | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/arch/i386/kernel/io_apic.c b/arch/i386/kernel/io_apic.c index 2424cc9c7b3d..6a3875f81a0a 100644 --- a/arch/i386/kernel/io_apic.c +++ b/arch/i386/kernel/io_apic.c | |||
@@ -1227,26 +1227,32 @@ static u8 irq_vector[NR_IRQ_VECTORS] __read_mostly = { FIRST_DEVICE_VECTOR , 0 } | |||
1227 | 1227 | ||
1228 | static int __assign_irq_vector(int irq) | 1228 | static int __assign_irq_vector(int irq) |
1229 | { | 1229 | { |
1230 | static int current_vector = FIRST_DEVICE_VECTOR, offset = 0; | 1230 | static int current_vector = FIRST_DEVICE_VECTOR, current_offset = 0; |
1231 | int vector; | 1231 | int vector, offset, i; |
1232 | 1232 | ||
1233 | BUG_ON((unsigned)irq >= NR_IRQ_VECTORS); | 1233 | BUG_ON((unsigned)irq >= NR_IRQ_VECTORS); |
1234 | 1234 | ||
1235 | if (irq_vector[irq] > 0) | 1235 | if (irq_vector[irq] > 0) |
1236 | return irq_vector[irq]; | 1236 | return irq_vector[irq]; |
1237 | 1237 | ||
1238 | current_vector += 8; | ||
1239 | if (current_vector == SYSCALL_VECTOR) | ||
1240 | current_vector += 8; | ||
1241 | |||
1242 | if (current_vector >= FIRST_SYSTEM_VECTOR) { | ||
1243 | offset++; | ||
1244 | if (!(offset % 8)) | ||
1245 | return -ENOSPC; | ||
1246 | current_vector = FIRST_DEVICE_VECTOR + offset; | ||
1247 | } | ||
1248 | |||
1249 | vector = current_vector; | 1238 | vector = current_vector; |
1239 | offset = current_offset; | ||
1240 | next: | ||
1241 | vector += 8; | ||
1242 | if (vector >= FIRST_SYSTEM_VECTOR) { | ||
1243 | offset = (offset + 1) % 8; | ||
1244 | vector = FIRST_DEVICE_VECTOR + offset; | ||
1245 | } | ||
1246 | if (vector == current_vector) | ||
1247 | return -ENOSPC; | ||
1248 | if (vector == SYSCALL_VECTOR) | ||
1249 | goto next; | ||
1250 | for (i = 0; i < NR_IRQ_VECTORS; i++) | ||
1251 | if (irq_vector[i] == vector) | ||
1252 | goto next; | ||
1253 | |||
1254 | current_vector = vector; | ||
1255 | current_offset = offset; | ||
1250 | irq_vector[irq] = vector; | 1256 | irq_vector[irq] = vector; |
1251 | 1257 | ||
1252 | return vector; | 1258 | return vector; |