Skip to contentSkip to conversation

riscv: merge two if-blocks for KBUILD_IMAGE

PATCH Applied Masahiro Yamada 3 participants 3 messages Mar 23, 2024 – Apr 10, 2024 RISC-V

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 riscv: merge two if-blocks for KBUILD_IMAGE

In arch/riscv/Makefile, KBUILD_IMAGE is assigned in two separate if-blocks.

When CONFIG_XIP_KERNEL is disabled, the decision made by the first if-block is overwritten by the second one, which is redundant and unreadable.

Merge the two if-blocks.

---

 arch/riscv/Makefile | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)
arch/riscv/Makefile +8 -11
index 252d63942f34..a74e70405d3f 100644
@@ -133,7 +133,15 @@ boot		:= arch/riscv/boot
 ifeq ($(CONFIG_XIP_KERNEL),y)
 KBUILD_IMAGE := $(boot)/xipImage
 else
+ifeq ($(CONFIG_RISCV_M_MODE)$(CONFIG_ARCH_CANAAN),yy)
+KBUILD_IMAGE := $(boot)/loader.bin
+else
+ifeq ($(CONFIG_EFI_ZBOOT),)
 KBUILD_IMAGE	:= $(boot)/Image.gz
+else
+KBUILD_IMAGE := $(boot)/vmlinuz.efi
+endif
+endif
 endif
 
 libs-y += arch/riscv/lib/
@@ -153,17 +161,6 @@ endif
 vdso-install-y			+= arch/riscv/kernel/vdso/vdso.so.dbg
 vdso-install-$(CONFIG_COMPAT)	+= arch/riscv/kernel/compat_vdso/compat_vdso.so.dbg:../compat_vdso/compat_vdso.so
 
-ifneq ($(CONFIG_XIP_KERNEL),y)
-ifeq ($(CONFIG_RISCV_M_MODE)$(CONFIG_ARCH_CANAAN),yy)
-KBUILD_IMAGE := $(boot)/loader.bin
-else
-ifeq ($(CONFIG_EFI_ZBOOT),)
-KBUILD_IMAGE := $(boot)/Image.gz
-else
-KBUILD_IMAGE := $(boot)/vmlinuz.efi
-endif
-endif
-endif
 BOOT_TARGETS := Image Image.gz loader loader.bin xipImage vmlinuz.efi
 
 all:	$(notdir $(KBUILD_IMAGE))
Signature · 1 line
2.40.1
reviewer Reviewed-by on v1 1/1
#1 lore raw

Hi Masahiro,

Quoted 43 lines · Masahiro Yamada

In arch/riscv/Makefile, KBUILD_IMAGE is assigned in two separate if-blocks.

When CONFIG_XIP_KERNEL is disabled, the decision made by the first if-block is overwritten by the second one, which is redundant and unreadable.

Merge the two if-blocks.

---

  arch/riscv/Makefile | 19 ++++++++-----------
  1 file changed, 8 insertions(+), 11 deletions(-)
arch/riscv/Makefile +8 -4
index 252d63942f34..a74e70405d3f 100644
@@ -133,7 +133,15 @@ boot		:= arch/riscv/boot
  ifeq ($(CONFIG_XIP_KERNEL),y)
  KBUILD_IMAGE := $(boot)/xipImage
  else
+ifeq ($(CONFIG_RISCV_M_MODE)$(CONFIG_ARCH_CANAAN),yy)
+KBUILD_IMAGE := $(boot)/loader.bin
+else
+ifeq ($(CONFIG_EFI_ZBOOT),)
  KBUILD_IMAGE	:= $(boot)/Image.gz
+else
+KBUILD_IMAGE := $(boot)/vmlinuz.efi
+endif
+endif
  endif
 
  libs-y += arch/riscv/lib/
@@ -153,17 +161,6 @@ endif
  vdso-install-y			+= arch/riscv/kernel/vdso/vdso.so.dbg
  vdso-install-$(CONFIG_COMPAT)	+= arch/riscv/kernel/compat_vdso/compat_vdso.so.dbg:../compat_vdso/compat_vdso.so
 
-ifneq ($(CONFIG_XIP_KERNEL),y)
-ifeq ($(CONFIG_RISCV_M_MODE)$(CONFIG_ARCH_CANAAN),yy)
-KBUILD_IMAGE := $(boot)/loader.bin
-else

arch/riscv/Makefile endif · line 166

Quoted 10 lines
arch/riscv/Makefile +0 -7
-ifeq ($(CONFIG_EFI_ZBOOT),)
-KBUILD_IMAGE := $(boot)/Image.gz
-else
-KBUILD_IMAGE := $(boot)/vmlinuz.efi
-endif
-endif
-endif
  BOOT_TARGETS := Image Image.gz loader loader.bin xipImage vmlinuz.efi
 
  all:	$(notdir $(KBUILD_IMAGE))

You can add:

Thanks,

Alex

#2 lore raw
In reply to Masahiro Yamada
This patch was applied to riscv/linux.git (for-next) by Palmer Dabbelt <[email protected]>:

Hello:

This patch was applied to riscv/linux.git (for-next) by Palmer Dabbelt <[email protected]>:

Quoted 8 lines · On Sat, 23 Mar 2024 20:35:00 +0900 you wrote:

In arch/riscv/Makefile, KBUILD_IMAGE is assigned in two separate if-blocks.

When CONFIG_XIP_KERNEL is disabled, the decision made by the first if-block is overwritten by the second one, which is redundant and unreadable.

[...]

Here is the summary with links:
- riscv: merge two if-blocks for KBUILD_IMAGE

    https://git.kernel.org/riscv/c/3b938e231b66

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html