Merge branch 'x86-microcode-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip

* 'x86-microcode-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
x86, microcode, AMD: Cleanup code a bit
x86, microcode, AMD: Replace vmalloc+memset with vzalloc

+16 -24
+6
arch/x86/include/asm/microcode.h
··· 48 48 49 49 #ifdef CONFIG_MICROCODE_AMD 50 50 extern struct microcode_ops * __init init_amd_microcode(void); 51 + 52 + static inline void get_ucode_data(void *to, const u8 *from, size_t n) 53 + { 54 + memcpy(to, from, n); 55 + } 56 + 51 57 #else 52 58 static inline struct microcode_ops * __init init_amd_microcode(void) 53 59 {
+10 -24
arch/x86/kernel/microcode_amd.c
··· 155 155 return 0; 156 156 } 157 157 158 - static int get_ucode_data(void *to, const u8 *from, size_t n) 159 - { 160 - memcpy(to, from, n); 161 - return 0; 162 - } 163 - 164 158 static void * 165 159 get_next_ucode(const u8 *buf, unsigned int size, unsigned int *mc_size) 166 160 { ··· 162 168 u8 section_hdr[UCODE_CONTAINER_SECTION_HDR]; 163 169 void *mc; 164 170 165 - if (get_ucode_data(section_hdr, buf, UCODE_CONTAINER_SECTION_HDR)) 166 - return NULL; 171 + get_ucode_data(section_hdr, buf, UCODE_CONTAINER_SECTION_HDR); 167 172 168 173 if (section_hdr[0] != UCODE_UCODE_TYPE) { 169 174 pr_err("error: invalid type field in container file section header\n"); ··· 176 183 return NULL; 177 184 } 178 185 179 - mc = vmalloc(UCODE_MAX_SIZE); 180 - if (mc) { 181 - memset(mc, 0, UCODE_MAX_SIZE); 182 - if (get_ucode_data(mc, buf + UCODE_CONTAINER_SECTION_HDR, 183 - total_size)) { 184 - vfree(mc); 185 - mc = NULL; 186 - } else 187 - *mc_size = total_size + UCODE_CONTAINER_SECTION_HDR; 188 - } 186 + mc = vzalloc(UCODE_MAX_SIZE); 187 + if (!mc) 188 + return NULL; 189 + 190 + get_ucode_data(mc, buf + UCODE_CONTAINER_SECTION_HDR, total_size); 191 + *mc_size = total_size + UCODE_CONTAINER_SECTION_HDR; 192 + 189 193 return mc; 190 194 } 191 195 ··· 192 202 unsigned int *buf_pos = (unsigned int *)container_hdr; 193 203 unsigned long size; 194 204 195 - if (get_ucode_data(&container_hdr, buf, UCODE_CONTAINER_HEADER_SIZE)) 196 - return 0; 205 + get_ucode_data(&container_hdr, buf, UCODE_CONTAINER_HEADER_SIZE); 197 206 198 207 size = buf_pos[2]; 199 208 ··· 208 219 } 209 220 210 221 buf += UCODE_CONTAINER_HEADER_SIZE; 211 - if (get_ucode_data(equiv_cpu_table, buf, size)) { 212 - vfree(equiv_cpu_table); 213 - return 0; 214 - } 222 + get_ucode_data(equiv_cpu_table, buf, size); 215 223 216 224 return size + UCODE_CONTAINER_HEADER_SIZE; /* add header length */ 217 225 }