All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH RESEND] riscv: kexec: use min to simplify riscv_kexec_elf_load
@ 2026-06-02 22:47 ` Thorsten Blum
  0 siblings, 0 replies; 6+ messages in thread
From: Thorsten Blum @ 2026-06-02 22:47 UTC (permalink / raw)
  To: Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
	Breno Leitao, Andrew Morton, Pasha Tatashin, Alexander Graf,
	Baoquan He, Song Shuai
  Cc: Thorsten Blum, linux-riscv, linux-kernel

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>
---
 arch/riscv/kernel/kexec_elf.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/arch/riscv/kernel/kexec_elf.c b/arch/riscv/kernel/kexec_elf.c
index 531d348db84d..528141df90ba 100644
--- a/arch/riscv/kernel/kexec_elf.c
+++ b/arch/riscv/kernel/kexec_elf.c
@@ -19,6 +19,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,
@@ -27,7 +28,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;
 
@@ -38,12 +38,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;

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH RESEND] riscv: kexec: use min to simplify riscv_kexec_elf_load
@ 2026-06-02 22:47 ` Thorsten Blum
  0 siblings, 0 replies; 6+ messages in thread
From: Thorsten Blum @ 2026-06-02 22:47 UTC (permalink / raw)
  To: Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
	Breno Leitao, Andrew Morton, Pasha Tatashin, Alexander Graf,
	Baoquan He, Song Shuai
  Cc: Thorsten Blum, linux-riscv, linux-kernel

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>
---
 arch/riscv/kernel/kexec_elf.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/arch/riscv/kernel/kexec_elf.c b/arch/riscv/kernel/kexec_elf.c
index 531d348db84d..528141df90ba 100644
--- a/arch/riscv/kernel/kexec_elf.c
+++ b/arch/riscv/kernel/kexec_elf.c
@@ -19,6 +19,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,
@@ -27,7 +28,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;
 
@@ -38,12 +38,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;

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH RESEND] riscv: kexec: use min to simplify riscv_kexec_elf_load
  2026-06-02 22:47 ` Thorsten Blum
@ 2026-06-03  9:31   ` Breno Leitao
  -1 siblings, 0 replies; 6+ messages in thread
From: Breno Leitao @ 2026-06-03  9:31 UTC (permalink / raw)
  To: Thorsten Blum
  Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
	Andrew Morton, Pasha Tatashin, Alexander Graf, Baoquan He,
	Song Shuai, linux-riscv, linux-kernel

On Wed, Jun 03, 2026 at 12:47:22AM +0200, Thorsten Blum wrote:
> 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>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH RESEND] riscv: kexec: use min to simplify riscv_kexec_elf_load
@ 2026-06-03  9:31   ` Breno Leitao
  0 siblings, 0 replies; 6+ messages in thread
From: Breno Leitao @ 2026-06-03  9:31 UTC (permalink / raw)
  To: Thorsten Blum
  Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
	Andrew Morton, Pasha Tatashin, Alexander Graf, Baoquan He,
	Song Shuai, linux-riscv, linux-kernel

On Wed, Jun 03, 2026 at 12:47:22AM +0200, Thorsten Blum wrote:
> 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>

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH RESEND] riscv: kexec: use min to simplify riscv_kexec_elf_load
  2026-06-03  9:31   ` Breno Leitao
@ 2026-06-07  7:08     ` Paul Walmsley
  -1 siblings, 0 replies; 6+ messages in thread
From: Paul Walmsley @ 2026-06-07  7:08 UTC (permalink / raw)
  To: Thorsten Blum, Breno Leitao
  Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
	Andrew Morton, Pasha Tatashin, Alexander Graf, Baoquan He,
	Song Shuai, linux-riscv, linux-kernel

On Wed, 3 Jun 2026, Breno Leitao wrote:

> On Wed, Jun 03, 2026 at 12:47:22AM +0200, Thorsten Blum wrote:
> > 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>

Thanks, queued for v7.2.

- Paul

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH RESEND] riscv: kexec: use min to simplify riscv_kexec_elf_load
@ 2026-06-07  7:08     ` Paul Walmsley
  0 siblings, 0 replies; 6+ messages in thread
From: Paul Walmsley @ 2026-06-07  7:08 UTC (permalink / raw)
  To: Thorsten Blum, Breno Leitao
  Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
	Andrew Morton, Pasha Tatashin, Alexander Graf, Baoquan He,
	Song Shuai, linux-riscv, linux-kernel

On Wed, 3 Jun 2026, Breno Leitao wrote:

> On Wed, Jun 03, 2026 at 12:47:22AM +0200, Thorsten Blum wrote:
> > 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>

Thanks, queued for v7.2.

- Paul

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-06-07  7:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-02 22:47 [PATCH RESEND] riscv: kexec: use min to simplify riscv_kexec_elf_load Thorsten Blum
2026-06-02 22:47 ` Thorsten Blum
2026-06-03  9:31 ` Breno Leitao
2026-06-03  9:31   ` Breno Leitao
2026-06-07  7:08   ` Paul Walmsley
2026-06-07  7:08     ` Paul Walmsley

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.