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: Feng 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: Thomas Gleixner <tglx@linutronix.de>

authored by Feng Tang and committed by Thomas Gleixner 0e3fa13f 2d8009ba

+8 -67
+2 -35
arch/x86/kernel/apic/io_apic.c
··· 126 126 } 127 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 129 /* Will be called in mpparse/acpi/sfi codes for saving IRQ info */ 163 130 void mp_save_irq(struct mpc_intsrc *m) 164 131 { ··· 137 170 m->srcbusirq, m->dstapic, m->dstirq); 138 171 139 172 for (i = 0; i < mp_irq_entries; i++) { 140 - if (!mp_irq_mpc_intsrc_cmp(&mp_irqs[i], m)) 173 + if (!memcmp(&mp_irqs[i], m, sizeof(*m))) 141 174 return; 142 175 } 143 176 144 - assign_to_mp_irq(m, &mp_irqs[mp_irq_entries]); 177 + memcpy(&mp_irqs[mp_irq_entries], m, sizeof(*m)); 145 178 if (++mp_irq_entries == MAX_IRQ_SOURCES) 146 179 panic("Max # of irq sources exceeded!!\n"); 147 180 }
+6 -32
arch/x86/kernel/mpparse.c
··· 118 118 119 119 static void __init MP_ioapic_info(struct mpc_ioapic *m) 120 120 { 121 - if (!(m->flags & MPC_APIC_USABLE)) 122 - return; 123 - 124 - printk(KERN_INFO "I/O APIC #%d Version %d at 0x%X.\n", 125 - m->apicid, m->apicver, m->apicaddr); 126 - 127 - mp_register_ioapic(m->apicid, m->apicaddr, gsi_top); 128 - } 129 - 130 - static void print_MP_intsrc_info(struct mpc_intsrc *m) 131 - { 132 - apic_printk(APIC_VERBOSE, "Int: type %d, pol %d, trig %d, bus %02x," 133 - " IRQ %02x, APIC ID %x, APIC INT %02x\n", 134 - m->irqtype, m->irqflag & 3, (m->irqflag >> 2) & 3, m->srcbus, 135 - m->srcbusirq, m->dstapic, m->dstirq); 121 + if (m->flags & MPC_APIC_USABLE) 122 + mp_register_ioapic(m->apicid, m->apicaddr, gsi_top); 136 123 } 137 124 138 125 static void __init print_mp_irq_info(struct mpc_intsrc *mp_irq) ··· 131 144 mp_irq->srcbusirq, mp_irq->dstapic, mp_irq->dstirq); 132 145 } 133 146 134 - static void __init assign_to_mpc_intsrc(struct mpc_intsrc *mp_irq, 135 - struct mpc_intsrc *m) 136 - { 137 - m->dstapic = mp_irq->dstapic; 138 - m->type = mp_irq->type; 139 - m->irqtype = mp_irq->irqtype; 140 - m->irqflag = mp_irq->irqflag; 141 - m->srcbus = mp_irq->srcbus; 142 - m->srcbusirq = mp_irq->srcbusirq; 143 - m->dstirq = mp_irq->dstirq; 144 - } 145 147 #else /* CONFIG_X86_IO_APIC */ 146 148 static inline void __init MP_bus_info(struct mpc_bus *m) {} 147 149 static inline void __init MP_ioapic_info(struct mpc_ioapic *m) {} 148 150 #endif /* CONFIG_X86_IO_APIC */ 149 - 150 151 151 152 static void __init MP_lintsrc_info(struct mpc_lintsrc *m) 152 153 { ··· 147 172 /* 148 173 * Read/parse the MPC 149 174 */ 150 - 151 175 static int __init smp_check_mpc(struct mpc_table *mpc, char *oem, char *str) 152 176 { 153 177 ··· 692 718 int i; 693 719 694 720 apic_printk(APIC_VERBOSE, "OLD "); 695 - print_MP_intsrc_info(m); 721 + print_mp_irq_info(m); 696 722 697 723 i = get_MP_intsrc_index(m); 698 724 if (i > 0) { 699 - assign_to_mpc_intsrc(&mp_irqs[i], m); 725 + memcpy(m, &mp_irqs[i], sizeof(*m)); 700 726 apic_printk(APIC_VERBOSE, "NEW "); 701 727 print_mp_irq_info(&mp_irqs[i]); 702 728 return; ··· 783 809 if (nr_m_spare > 0) { 784 810 apic_printk(APIC_VERBOSE, "*NEW* found\n"); 785 811 nr_m_spare--; 786 - assign_to_mpc_intsrc(&mp_irqs[i], m_spare[nr_m_spare]); 812 + memcpy(m_spare[nr_m_spare], &mp_irqs[i], sizeof(mp_irqs[i])); 787 813 m_spare[nr_m_spare] = NULL; 788 814 } else { 789 815 struct mpc_intsrc *m = (struct mpc_intsrc *)mpt; 790 816 count += sizeof(struct mpc_intsrc); 791 817 if (check_slot(mpc_new_phys, mpc_new_length, count) < 0) 792 818 goto out; 793 - assign_to_mpc_intsrc(&mp_irqs[i], m); 819 + memcpy(m, &mp_irqs[i], sizeof(*m)); 794 820 mpc->length = count; 795 821 mpt += sizeof(struct mpc_intsrc); 796 822 }