diff options
author | Feng Tang <feng.tang@intel.com> | 2010-11-18 22:33:35 -0500 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2010-12-09 15:52:06 -0500 |
commit | 2d8009ba67f9503ceadf9d5a3b5637cee291ea8d (patch) | |
tree | ab3ca6aacc84b5fb0135909e788c5b65830cd75f /arch/x86/kernel/apic/io_apic.c | |
parent | 60d79fd99ff3b9c692b260a4d53a203f537c052a (diff) |
x86: Unify 3 similar ways of saving mp_irqs info
There are 3 places defining similar functions of saving IRQ vector
info into mp_irqs[] array: mmparse/acpi/mrst.
Replace the redundant code by a common function in io_apic.c as it's
only called when CONFIG_X86_IO_APIC=y
Signed-off-by: Feng Tang <feng.tang@intel.com>
Cc: Alan Cox <alan@linux.intel.com>
Cc: Len Brown <len.brown@intel.com>
Cc: Yinghai Lu <yinghai@kernel.org>
LKML-Reference: <20101207133204.4d913c5a@feng-i7>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch/x86/kernel/apic/io_apic.c')
-rw-r--r-- | arch/x86/kernel/apic/io_apic.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c index 8a0215042a5f..c6b44f78ac14 100644 --- a/arch/x86/kernel/apic/io_apic.c +++ b/arch/x86/kernel/apic/io_apic.c | |||
@@ -126,6 +126,59 @@ static int __init parse_noapic(char *str) | |||
126 | } | 126 | } |
127 | early_param("noapic", parse_noapic); | 127 | early_param("noapic", parse_noapic); |
128 | 128 | ||
129 | static void assign_to_mp_irq(struct mpc_intsrc *m, | ||
130 | struct mpc_intsrc *mp_irq) | ||
131 | { | ||
132 | mp_irq->dstapic = m->dstapic; | ||
133 | mp_irq->type = m->type; | ||
134 | mp_irq->irqtype = m->irqtype; | ||
135 | mp_irq->irqflag = m->irqflag; | ||
136 | mp_irq->srcbus = m->srcbus; | ||
137 | mp_irq->srcbusirq = m->srcbusirq; | ||
138 | mp_irq->dstirq = m->dstirq; | ||
139 | } | ||
140 | |||
141 | static int mp_irq_mpc_intsrc_cmp(struct mpc_intsrc *mp_irq, | ||
142 | struct mpc_intsrc *m) | ||
143 | { | ||
144 | if (mp_irq->dstapic != m->dstapic) | ||
145 | return 1; | ||
146 | if (mp_irq->type != m->type) | ||
147 | return 2; | ||
148 | if (mp_irq->irqtype != m->irqtype) | ||
149 | return 3; | ||
150 | if (mp_irq->irqflag != m->irqflag) | ||
151 | return 4; | ||
152 | if (mp_irq->srcbus != m->srcbus) | ||
153 | return 5; | ||
154 | if (mp_irq->srcbusirq != m->srcbusirq) | ||
155 | return 6; | ||
156 | if (mp_irq->dstirq != m->dstirq) | ||
157 | return 7; | ||
158 | |||
159 | return 0; | ||
160 | } | ||
161 | |||
162 | /* Will be called in mpparse/acpi/sfi codes for saving IRQ info */ | ||
163 | void mp_save_irq(struct mpc_intsrc *m) | ||
164 | { | ||
165 | int i; | ||
166 | |||
167 | apic_printk(APIC_VERBOSE, "Int: type %d, pol %d, trig %d, bus %02x," | ||
168 | " IRQ %02x, APIC ID %x, APIC INT %02x\n", | ||
169 | m->irqtype, m->irqflag & 3, (m->irqflag >> 2) & 3, m->srcbus, | ||
170 | m->srcbusirq, m->dstapic, m->dstirq); | ||
171 | |||
172 | for (i = 0; i < mp_irq_entries; i++) { | ||
173 | if (!mp_irq_mpc_intsrc_cmp(&mp_irqs[i], m)) | ||
174 | return; | ||
175 | } | ||
176 | |||
177 | assign_to_mp_irq(m, &mp_irqs[mp_irq_entries]); | ||
178 | if (++mp_irq_entries == MAX_IRQ_SOURCES) | ||
179 | panic("Max # of irq sources exceeded!!\n"); | ||
180 | } | ||
181 | |||
129 | struct irq_pin_list { | 182 | struct irq_pin_list { |
130 | int apic, pin; | 183 | int apic, pin; |
131 | struct irq_pin_list *next; | 184 | struct irq_pin_list *next; |
@@ -136,6 +189,7 @@ static struct irq_pin_list *alloc_irq_pin_list(int node) | |||
136 | return kzalloc_node(sizeof(struct irq_pin_list), GFP_KERNEL, node); | 189 | return kzalloc_node(sizeof(struct irq_pin_list), GFP_KERNEL, node); |
137 | } | 190 | } |
138 | 191 | ||
192 | |||
139 | /* irq_cfg is indexed by the sum of all RTEs in all I/O APICs. */ | 193 | /* irq_cfg is indexed by the sum of all RTEs in all I/O APICs. */ |
140 | #ifdef CONFIG_SPARSE_IRQ | 194 | #ifdef CONFIG_SPARSE_IRQ |
141 | static struct irq_cfg irq_cfgx[NR_IRQS_LEGACY]; | 195 | static struct irq_cfg irq_cfgx[NR_IRQS_LEGACY]; |