diff options
| author | Feng Tang <feng.tang@intel.com> | 2010-12-08 02:18:57 -0500 |
|---|---|---|
| committer | Thomas Gleixner <tglx@linutronix.de> | 2010-12-09 15:52:06 -0500 |
| commit | 0e3fa13f4ee110de007bca3bf395b77997319fc8 (patch) | |
| tree | 801ee02881f6619822fae46e7ce52317d14d19d9 | |
| parent | 2d8009ba67f9503ceadf9d5a3b5637cee291ea8d (diff) | |
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>
| -rw-r--r-- | arch/x86/kernel/apic/io_apic.c | 37 | ||||
| -rw-r--r-- | arch/x86/kernel/mpparse.c | 38 |
2 files changed, 8 insertions, 67 deletions
diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c index c6b44f78ac14..bb61a552d8c6 100644 --- a/arch/x86/kernel/apic/io_apic.c +++ b/arch/x86/kernel/apic/io_apic.c | |||
| @@ -126,39 +126,6 @@ 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 */ | 129 | /* Will be called in mpparse/acpi/sfi codes for saving IRQ info */ |
| 163 | void mp_save_irq(struct mpc_intsrc *m) | 130 | void mp_save_irq(struct mpc_intsrc *m) |
| 164 | { | 131 | { |
| @@ -170,11 +137,11 @@ void mp_save_irq(struct mpc_intsrc *m) | |||
| 170 | m->srcbusirq, m->dstapic, m->dstirq); | 137 | m->srcbusirq, m->dstapic, m->dstirq); |
| 171 | 138 | ||
| 172 | for (i = 0; i < mp_irq_entries; i++) { | 139 | for (i = 0; i < mp_irq_entries; i++) { |
| 173 | if (!mp_irq_mpc_intsrc_cmp(&mp_irqs[i], m)) | 140 | if (!memcmp(&mp_irqs[i], m, sizeof(*m))) |
| 174 | return; | 141 | return; |
| 175 | } | 142 | } |
| 176 | 143 | ||
| 177 | assign_to_mp_irq(m, &mp_irqs[mp_irq_entries]); | 144 | memcpy(&mp_irqs[mp_irq_entries], m, sizeof(*m)); |
| 178 | if (++mp_irq_entries == MAX_IRQ_SOURCES) | 145 | if (++mp_irq_entries == MAX_IRQ_SOURCES) |
| 179 | panic("Max # of irq sources exceeded!!\n"); | 146 | panic("Max # of irq sources exceeded!!\n"); |
| 180 | } | 147 | } |
diff --git a/arch/x86/kernel/mpparse.c b/arch/x86/kernel/mpparse.c index 4318687b1c35..01b0f6d06451 100644 --- a/arch/x86/kernel/mpparse.c +++ b/arch/x86/kernel/mpparse.c | |||
| @@ -118,21 +118,8 @@ static void __init MP_bus_info(struct mpc_bus *m) | |||
| 118 | 118 | ||
| 119 | static void __init MP_ioapic_info(struct mpc_ioapic *m) | 119 | static void __init MP_ioapic_info(struct mpc_ioapic *m) |
| 120 | { | 120 | { |
| 121 | if (!(m->flags & MPC_APIC_USABLE)) | 121 | if (m->flags & MPC_APIC_USABLE) |
| 122 | return; | 122 | mp_register_ioapic(m->apicid, m->apicaddr, gsi_top); |
| 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); | ||
| 136 | } | 123 | } |
| 137 | 124 | ||
| 138 | static void __init print_mp_irq_info(struct mpc_intsrc *mp_irq) | 125 | 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 | mp_irq->srcbusirq, mp_irq->dstapic, mp_irq->dstirq); | 131 | mp_irq->srcbusirq, mp_irq->dstapic, mp_irq->dstirq); |
| 145 | } | 132 | } |
| 146 | 133 | ||
| 147 | static void __init assign_to_mpc_intsrc(struct mpc_intsrc *mp_irq, | ||
| 148 | struct mpc_intsrc *m) | ||
| 149 | { | ||
| 150 | m->dstapic = mp_irq->dstapic; | ||
| 151 | m->type = mp_irq->type; | ||
| 152 | m->irqtype = mp_irq->irqtype; | ||
| 153 | m->irqflag = mp_irq->irqflag; | ||
| 154 | m->srcbus = mp_irq->srcbus; | ||
| 155 | m->srcbusirq = mp_irq->srcbusirq; | ||
| 156 | m->dstirq = mp_irq->dstirq; | ||
| 157 | } | ||
| 158 | #else /* CONFIG_X86_IO_APIC */ | 134 | #else /* CONFIG_X86_IO_APIC */ |
| 159 | static inline void __init MP_bus_info(struct mpc_bus *m) {} | 135 | static inline void __init MP_bus_info(struct mpc_bus *m) {} |
| 160 | static inline void __init MP_ioapic_info(struct mpc_ioapic *m) {} | 136 | static inline void __init MP_ioapic_info(struct mpc_ioapic *m) {} |
| 161 | #endif /* CONFIG_X86_IO_APIC */ | 137 | #endif /* CONFIG_X86_IO_APIC */ |
| 162 | 138 | ||
| 163 | |||
| 164 | static void __init MP_lintsrc_info(struct mpc_lintsrc *m) | 139 | static void __init MP_lintsrc_info(struct mpc_lintsrc *m) |
| 165 | { | 140 | { |
| 166 | apic_printk(APIC_VERBOSE, "Lint: type %d, pol %d, trig %d, bus %02x," | 141 | 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 | /* | 147 | /* |
| 173 | * Read/parse the MPC | 148 | * Read/parse the MPC |
| 174 | */ | 149 | */ |
| 175 | |||
| 176 | static int __init smp_check_mpc(struct mpc_table *mpc, char *oem, char *str) | 150 | static int __init smp_check_mpc(struct mpc_table *mpc, char *oem, char *str) |
| 177 | { | 151 | { |
| 178 | 152 | ||
| @@ -718,11 +692,11 @@ static void __init check_irq_src(struct mpc_intsrc *m, int *nr_m_spare) | |||
| 718 | int i; | 692 | int i; |
| 719 | 693 | ||
| 720 | apic_printk(APIC_VERBOSE, "OLD "); | 694 | apic_printk(APIC_VERBOSE, "OLD "); |
| 721 | print_MP_intsrc_info(m); | 695 | print_mp_irq_info(m); |
| 722 | 696 | ||
| 723 | i = get_MP_intsrc_index(m); | 697 | i = get_MP_intsrc_index(m); |
| 724 | if (i > 0) { | 698 | if (i > 0) { |
| 725 | assign_to_mpc_intsrc(&mp_irqs[i], m); | 699 | memcpy(m, &mp_irqs[i], sizeof(*m)); |
| 726 | apic_printk(APIC_VERBOSE, "NEW "); | 700 | apic_printk(APIC_VERBOSE, "NEW "); |
| 727 | print_mp_irq_info(&mp_irqs[i]); | 701 | print_mp_irq_info(&mp_irqs[i]); |
| 728 | return; | 702 | return; |
| @@ -809,14 +783,14 @@ static int __init replace_intsrc_all(struct mpc_table *mpc, | |||
| 809 | if (nr_m_spare > 0) { | 783 | if (nr_m_spare > 0) { |
| 810 | apic_printk(APIC_VERBOSE, "*NEW* found\n"); | 784 | apic_printk(APIC_VERBOSE, "*NEW* found\n"); |
| 811 | nr_m_spare--; | 785 | nr_m_spare--; |
| 812 | assign_to_mpc_intsrc(&mp_irqs[i], m_spare[nr_m_spare]); | 786 | memcpy(m_spare[nr_m_spare], &mp_irqs[i], sizeof(mp_irqs[i])); |
| 813 | m_spare[nr_m_spare] = NULL; | 787 | m_spare[nr_m_spare] = NULL; |
| 814 | } else { | 788 | } else { |
| 815 | struct mpc_intsrc *m = (struct mpc_intsrc *)mpt; | 789 | struct mpc_intsrc *m = (struct mpc_intsrc *)mpt; |
| 816 | count += sizeof(struct mpc_intsrc); | 790 | count += sizeof(struct mpc_intsrc); |
| 817 | if (check_slot(mpc_new_phys, mpc_new_length, count) < 0) | 791 | if (check_slot(mpc_new_phys, mpc_new_length, count) < 0) |
| 818 | goto out; | 792 | goto out; |
| 819 | assign_to_mpc_intsrc(&mp_irqs[i], m); | 793 | memcpy(m, &mp_irqs[i], sizeof(*m)); |
| 820 | mpc->length = count; | 794 | mpc->length = count; |
| 821 | mpt += sizeof(struct mpc_intsrc); | 795 | mpt += sizeof(struct mpc_intsrc); |
| 822 | } | 796 | } |
