Commit 9e02bb46 authored by Borislav Petkov's avatar Borislav Petkov

x86/microcode/intel: Simplify generic_load_microcode_early()

* remove state variable and out label
* get rid of completely unused mc_size
* shorten variable names
* get rid of local variables
* don't do assignments in local var declarations for less cluttered code
* finally rename it to the shorter and perfectly fine load_microcode_early()

No functionality change.
Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
parent 58ce8d6d
...@@ -35,38 +35,35 @@ static struct mc_saved_data { ...@@ -35,38 +35,35 @@ static struct mc_saved_data {
} mc_saved_data; } mc_saved_data;
static enum ucode_state static enum ucode_state
generic_load_microcode_early(struct microcode_intel **mc_saved_p, load_microcode_early(struct microcode_intel **saved,
unsigned int mc_saved_count, unsigned int num_saved, struct ucode_cpu_info *uci)
struct ucode_cpu_info *uci)
{ {
struct microcode_intel *ucode_ptr, *new_mc = NULL; struct microcode_intel *ucode_ptr, *new_mc = NULL;
int new_rev = uci->cpu_sig.rev; struct microcode_header_intel *mc_hdr;
enum ucode_state state = UCODE_OK; int new_rev, ret, i;
unsigned int mc_size;
struct microcode_header_intel *mc_header;
unsigned int csig = uci->cpu_sig.sig;
unsigned int cpf = uci->cpu_sig.pf;
int i;
for (i = 0; i < mc_saved_count; i++) { new_rev = uci->cpu_sig.rev;
ucode_ptr = mc_saved_p[i];
mc_header = (struct microcode_header_intel *)ucode_ptr; for (i = 0; i < num_saved; i++) {
mc_size = get_totalsize(mc_header); ucode_ptr = saved[i];
if (get_matching_microcode(csig, cpf, ucode_ptr, new_rev)) { mc_hdr = (struct microcode_header_intel *)ucode_ptr;
new_rev = mc_header->rev;
ret = get_matching_microcode(uci->cpu_sig.sig,
uci->cpu_sig.pf,
ucode_ptr,
new_rev);
if (!ret)
continue;
new_rev = mc_hdr->rev;
new_mc = ucode_ptr; new_mc = ucode_ptr;
} }
}
if (!new_mc) { if (!new_mc)
state = UCODE_NFOUND; return UCODE_NFOUND;
goto out;
}
uci->mc = (struct microcode_intel *)new_mc; uci->mc = (struct microcode_intel *)new_mc;
out: return UCODE_OK;
return state;
} }
static void static void
...@@ -114,13 +111,13 @@ load_microcode(struct mc_saved_data *mc_saved_data, ...@@ -114,13 +111,13 @@ load_microcode(struct mc_saved_data *mc_saved_data,
microcode_pointer(mc_saved_tmp, mc_saved_in_initrd, microcode_pointer(mc_saved_tmp, mc_saved_in_initrd,
initrd_start, count); initrd_start, count);
return generic_load_microcode_early(mc_saved_tmp, count, uci); return load_microcode_early(mc_saved_tmp, count, uci);
} else { } else {
#ifdef CONFIG_X86_32 #ifdef CONFIG_X86_32
microcode_phys(mc_saved_tmp, mc_saved_data); microcode_phys(mc_saved_tmp, mc_saved_data);
return generic_load_microcode_early(mc_saved_tmp, count, uci); return load_microcode_early(mc_saved_tmp, count, uci);
#else #else
return generic_load_microcode_early(mc_saved_data->mc_saved, return load_microcode_early(mc_saved_data->mc_saved,
count, uci); count, uci);
#endif #endif
} }
...@@ -773,7 +770,7 @@ void reload_ucode_intel(void) ...@@ -773,7 +770,7 @@ void reload_ucode_intel(void)
collect_cpu_info_early(&uci); collect_cpu_info_early(&uci);
ret = generic_load_microcode_early(mc_saved_data.mc_saved, ret = load_microcode_early(mc_saved_data.mc_saved,
mc_saved_data.mc_saved_count, &uci); mc_saved_data.mc_saved_count, &uci);
if (ret != UCODE_OK) if (ret != UCODE_OK)
return; return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment