Skip to content

Commit 8cd3029

Browse files
leoliu-ocopsiff
authored andcommitted
x86/microcode: Simplify Zhaoxin microcode patch saving
This patch simplifies the save_microcode_patch() function in the Zhaoxin microcode driver by removing unnecessary variables and streamlining the memory allocation and copying logic. The changes include: - Remove the unused local variable 'mc'. - Directly handle memory allocation failure without redundant checks. - Simplify the memcpy and assignment to zhaoxin_ucode_patch. This improves code readability and reduces complexity without changing functionality. Signed-off-by: LeoLiu-oc <leoliu-oc@zhaoxin.com>
1 parent f8c9c3c commit 8cd3029

1 file changed

Lines changed: 6 additions & 11 deletions

File tree

arch/x86/kernel/cpu/microcode/zhaoxin.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ static int zhaoxin_microcode_sanity_check(void *mc, bool print_err, int hdr_type
176176
static void save_microcode_patch(struct microcode_zhaoxin *patch)
177177
{
178178
unsigned int size = patch->hdr.total_size;
179-
struct microcode_zhaoxin *mc = NULL;
180179
struct page *pg = NULL;
181180
void *dst = NULL;
182181

@@ -186,18 +185,14 @@ static void save_microcode_patch(struct microcode_zhaoxin *patch)
186185
* the memory allocation to this range.
187186
*/
188187
pg = alloc_pages(GFP_DMA32 | GFP_KERNEL, get_order(size));
189-
190-
if (pg) {
191-
dst = page_address(pg);
192-
memcpy(dst, patch, size);
193-
mc = dst;
194-
if (mc) {
195-
zhaoxin_ucode_patch = mc;
196-
return;
197-
}
188+
if (!pg) {
189+
pr_err("Unable to allocate microcode memory size: %u\n", size);
190+
return;
198191
}
199192

200-
pr_err("Unable to allocate microcode memory size: %u\n", size);
193+
dst = page_address(pg);
194+
memcpy(dst, patch, size);
195+
zhaoxin_ucode_patch = dst;
201196
}
202197

203198
static inline u32

0 commit comments

Comments
 (0)