]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
riscv: kexec: use min to simplify riscv_kexec_elf_load
authorThorsten Blum <thorsten.blum@linux.dev>
Tue, 2 Jun 2026 22:47:22 +0000 (00:47 +0200)
committerPaul Walmsley <pjw@kernel.org>
Sun, 7 Jun 2026 07:06:19 +0000 (01:06 -0600)
Use min() to replace the open-coded version and assign the result
directly to kbuf.bufsz. Drop the now-unused local size variable.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Reviewed-by: Breno Leitao <leitao@debian.org>
Link: https://patch.msgid.link/20260602224725.1088385-3-thorsten.blum@linux.dev
Signed-off-by: Paul Walmsley <pjw@kernel.org>
arch/riscv/kernel/kexec_elf.c

index 05fd33104f3d692d63df040205f95fe0e648dac8..3e9a32acb8f219cd7eef349306ffb1d4983dc83f 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/libfdt.h>
 #include <linux/types.h>
 #include <linux/memblock.h>
+#include <linux/minmax.h>
 #include <asm/setup.h>
 
 static int riscv_kexec_elf_load(struct kimage *image, struct elfhdr *ehdr,
@@ -25,7 +26,6 @@ static int riscv_kexec_elf_load(struct kimage *image, struct elfhdr *ehdr,
 {
        int i;
        int ret = 0;
-       size_t size;
        struct kexec_buf kbuf = {};
        const struct elf_phdr *phdr;
 
@@ -36,12 +36,8 @@ static int riscv_kexec_elf_load(struct kimage *image, struct elfhdr *ehdr,
                if (phdr->p_type != PT_LOAD)
                        continue;
 
-               size = phdr->p_filesz;
-               if (size > phdr->p_memsz)
-                       size = phdr->p_memsz;
-
                kbuf.buffer = (void *) elf_info->buffer + phdr->p_offset;
-               kbuf.bufsz = size;
+               kbuf.bufsz = min(phdr->p_filesz, phdr->p_memsz);
                kbuf.buf_align = phdr->p_align;
                kbuf.mem = phdr->p_paddr - old_pbase + new_pbase;
                kbuf.memsz = phdr->p_memsz;