提交 0e3fa13f 编写于 作者: F Feng Tang 提交者: Thomas Gleixner

x86: Further simplify mp_irq info handling

assign_to_mp_irq() is copying the struct mpc_intsrc members one by
one. That's silly. Use memcpy() and let the compiler figure it out.
Same for the identical function assign_to_mpc_intsrc()

mp_irq_mpc_intsrc_cmp() is comparing the struct members one by one,
but no caller ever checks the different return codes. Use memcmp()
instead.

Remove the extra printk in MP_ioapic_info()
Signed-off-by: NFeng Tang <feng.tang@linux.intel.com>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: "Alan Cox <alan@linux.intel.com>
Cc: Len Brown <len.brown@intel.com>
LKML-Reference: <20101208151857.212f0018@feng-i7>
Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
上级 2d8009ba
...@@ -126,39 +126,6 @@ static int __init parse_noapic(char *str) ...@@ -126,39 +126,6 @@ static int __init parse_noapic(char *str)
} }
early_param("noapic", parse_noapic); early_param("noapic", parse_noapic);
static void assign_to_mp_irq(struct mpc_intsrc *m,
struct mpc_intsrc *mp_irq)
{
mp_irq->dstapic = m->dstapic;
mp_irq->type = m->type;
mp_irq->irqtype = m->irqtype;
mp_irq->irqflag = m->irqflag;
mp_irq->srcbus = m->srcbus;
mp_irq->srcbusirq = m->srcbusirq;
mp_irq->dstirq = m->dstirq;
}
static int mp_irq_mpc_intsrc_cmp(struct mpc_intsrc *mp_irq,
struct mpc_intsrc *m)
{
if (mp_irq->dstapic != m->dstapic)
return 1;
if (mp_irq->type != m->type)
return 2;
if (mp_irq->irqtype != m->irqtype)
return 3;
if (mp_irq->irqflag != m->irqflag)
return 4;
if (mp_irq->srcbus != m->srcbus)
return 5;
if (mp_irq->srcbusirq != m->srcbusirq)
return 6;
if (mp_irq->dstirq != m->dstirq)
return 7;
return 0;
}
/* Will be called in mpparse/acpi/sfi codes for saving IRQ info */ /* Will be called in mpparse/acpi/sfi codes for saving IRQ info */
void mp_save_irq(struct mpc_intsrc *m) void mp_save_irq(struct mpc_intsrc *m)
{ {
...@@ -170,11 +137,11 @@ void mp_save_irq(struct mpc_intsrc *m) ...@@ -170,11 +137,11 @@ void mp_save_irq(struct mpc_intsrc *m)
m->srcbusirq, m->dstapic, m->dstirq); m->srcbusirq, m->dstapic, m->dstirq);
for (i = 0; i < mp_irq_entries; i++) { for (i = 0; i < mp_irq_entries; i++) {
if (!mp_irq_mpc_intsrc_cmp(&mp_irqs[i], m)) if (!memcmp(&mp_irqs[i], m, sizeof(*m)))
return; return;
} }
assign_to_mp_irq(m, &mp_irqs[mp_irq_entries]); memcpy(&mp_irqs[mp_irq_entries], m, sizeof(*m));
if (++mp_irq_entries == MAX_IRQ_SOURCES) if (++mp_irq_entries == MAX_IRQ_SOURCES)
panic("Max # of irq sources exceeded!!\n"); panic("Max # of irq sources exceeded!!\n");
} }
......
...@@ -118,21 +118,8 @@ static void __init MP_bus_info(struct mpc_bus *m) ...@@ -118,21 +118,8 @@ static void __init MP_bus_info(struct mpc_bus *m)
static void __init MP_ioapic_info(struct mpc_ioapic *m) static void __init MP_ioapic_info(struct mpc_ioapic *m)
{ {
if (!(m->flags & MPC_APIC_USABLE)) if (m->flags & MPC_APIC_USABLE)
return; mp_register_ioapic(m->apicid, m->apicaddr, gsi_top);
printk(KERN_INFO "I/O APIC #%d Version %d at 0x%X.\n",
m->apicid, m->apicver, m->apicaddr);
mp_register_ioapic(m->apicid, m->apicaddr, gsi_top);
}
static void print_MP_intsrc_info(struct mpc_intsrc *m)
{
apic_printk(APIC_VERBOSE, "Int: type %d, pol %d, trig %d, bus %02x,"
" IRQ %02x, APIC ID %x, APIC INT %02x\n",
m->irqtype, m->irqflag & 3, (m->irqflag >> 2) & 3, m->srcbus,
m->srcbusirq, m->dstapic, m->dstirq);
} }
static void __init print_mp_irq_info(struct mpc_intsrc *mp_irq) static void __init print_mp_irq_info(struct mpc_intsrc *mp_irq)
...@@ -144,23 +131,11 @@ static void __init print_mp_irq_info(struct mpc_intsrc *mp_irq) ...@@ -144,23 +131,11 @@ static void __init print_mp_irq_info(struct mpc_intsrc *mp_irq)
mp_irq->srcbusirq, mp_irq->dstapic, mp_irq->dstirq); mp_irq->srcbusirq, mp_irq->dstapic, mp_irq->dstirq);
} }
static void __init assign_to_mpc_intsrc(struct mpc_intsrc *mp_irq,
struct mpc_intsrc *m)
{
m->dstapic = mp_irq->dstapic;
m->type = mp_irq->type;
m->irqtype = mp_irq->irqtype;
m->irqflag = mp_irq->irqflag;
m->srcbus = mp_irq->srcbus;
m->srcbusirq = mp_irq->srcbusirq;
m->dstirq = mp_irq->dstirq;
}
#else /* CONFIG_X86_IO_APIC */ #else /* CONFIG_X86_IO_APIC */
static inline void __init MP_bus_info(struct mpc_bus *m) {} static inline void __init MP_bus_info(struct mpc_bus *m) {}
static inline void __init MP_ioapic_info(struct mpc_ioapic *m) {} static inline void __init MP_ioapic_info(struct mpc_ioapic *m) {}
#endif /* CONFIG_X86_IO_APIC */ #endif /* CONFIG_X86_IO_APIC */
static void __init MP_lintsrc_info(struct mpc_lintsrc *m) static void __init MP_lintsrc_info(struct mpc_lintsrc *m)
{ {
apic_printk(APIC_VERBOSE, "Lint: type %d, pol %d, trig %d, bus %02x," apic_printk(APIC_VERBOSE, "Lint: type %d, pol %d, trig %d, bus %02x,"
...@@ -172,7 +147,6 @@ static void __init MP_lintsrc_info(struct mpc_lintsrc *m) ...@@ -172,7 +147,6 @@ static void __init MP_lintsrc_info(struct mpc_lintsrc *m)
/* /*
* Read/parse the MPC * Read/parse the MPC
*/ */
static int __init smp_check_mpc(struct mpc_table *mpc, char *oem, char *str) static int __init smp_check_mpc(struct mpc_table *mpc, char *oem, char *str)
{ {
...@@ -718,11 +692,11 @@ static void __init check_irq_src(struct mpc_intsrc *m, int *nr_m_spare) ...@@ -718,11 +692,11 @@ static void __init check_irq_src(struct mpc_intsrc *m, int *nr_m_spare)
int i; int i;
apic_printk(APIC_VERBOSE, "OLD "); apic_printk(APIC_VERBOSE, "OLD ");
print_MP_intsrc_info(m); print_mp_irq_info(m);
i = get_MP_intsrc_index(m); i = get_MP_intsrc_index(m);
if (i > 0) { if (i > 0) {
assign_to_mpc_intsrc(&mp_irqs[i], m); memcpy(m, &mp_irqs[i], sizeof(*m));
apic_printk(APIC_VERBOSE, "NEW "); apic_printk(APIC_VERBOSE, "NEW ");
print_mp_irq_info(&mp_irqs[i]); print_mp_irq_info(&mp_irqs[i]);
return; return;
...@@ -809,14 +783,14 @@ static int __init replace_intsrc_all(struct mpc_table *mpc, ...@@ -809,14 +783,14 @@ static int __init replace_intsrc_all(struct mpc_table *mpc,
if (nr_m_spare > 0) { if (nr_m_spare > 0) {
apic_printk(APIC_VERBOSE, "*NEW* found\n"); apic_printk(APIC_VERBOSE, "*NEW* found\n");
nr_m_spare--; nr_m_spare--;
assign_to_mpc_intsrc(&mp_irqs[i], m_spare[nr_m_spare]); memcpy(m_spare[nr_m_spare], &mp_irqs[i], sizeof(mp_irqs[i]));
m_spare[nr_m_spare] = NULL; m_spare[nr_m_spare] = NULL;
} else { } else {
struct mpc_intsrc *m = (struct mpc_intsrc *)mpt; struct mpc_intsrc *m = (struct mpc_intsrc *)mpt;
count += sizeof(struct mpc_intsrc); count += sizeof(struct mpc_intsrc);
if (check_slot(mpc_new_phys, mpc_new_length, count) < 0) if (check_slot(mpc_new_phys, mpc_new_length, count) < 0)
goto out; goto out;
assign_to_mpc_intsrc(&mp_irqs[i], m); memcpy(m, &mp_irqs[i], sizeof(*m));
mpc->length = count; mpc->length = count;
mpt += sizeof(struct mpc_intsrc); mpt += sizeof(struct mpc_intsrc);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册