public inbox for linux-kbuild@vger.kernel.org
 help / color / mirror / Atom feed
From: Nicolas Schier <nicolas@fjasle.eu>
To: Masahiro Yamada <masahiroy@kernel.org>
Cc: linux-kbuild@vger.kernel.org, Rob Herring <robh+dt@kernel.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	linux-kernel@vger.kernel.org,
	Nathan Chancellor <nathan@kernel.org>
Subject: Re: [PATCH] kbuild: clean up code duplication in cmd_fdtoverlay
Date: Sat, 3 Aug 2024 01:41:40 +0200	[thread overview]
Message-ID: <20240803-cryptic-tan-emu-7c58ce@lindesnes> (raw)
In-Reply-To: <20240725192317.258132-1-masahiroy@kernel.org>

On Fri, Jul 26, 2024 at 04:23:14AM +0900, Masahiro Yamada wrote:
> When resolving a merge conflict, Linus noticed the fdtoverlay command
> duplication introduced by commit 49636c5680b9 ("kbuild: verify dtoverlay
> files against schema"). He suggested a clean-up.
> 
> I eliminated the duplication and refactored the code a little further.
> 
> No functional changes are intended, except for the short logs.
> 
> The log will look as follows:
> 
>   $ make ARCH=arm64 defconfig dtbs_check
>       [ snip ]
>     DTC [C] arch/arm64/boot/dts/freescale/imx93-tqma9352-mba93xxca.dtb
>     DTC [C] arch/arm64/boot/dts/freescale/imx93-tqma9352-mba93xxla.dtb
>     DTC [C] arch/arm64/boot/dts/freescale/imx93-var-som-symphony.dtb
>     DTC [C] arch/arm64/boot/dts/freescale/imx95-19x19-evk.dtb
>     DTC     arch/arm64/boot/dts/freescale/imx8mm-venice-gw72xx-0x-imx219.dtbo
>     OVL [C] arch/arm64/boot/dts/freescale/imx8mm-venice-gw72xx-0x-imx219.dtb
> 
> The tag [C] indicates that the schema check is executed.
> 
> Link: https://lore.kernel.org/lkml/CAHk-=wiF3yeWehcvqY-4X7WNb8n4yw_5t0H1CpEpKi7JMjaMfw@mail.gmail.com/#t
> Requested-by: Linus Torvalds <torvalds@linux-foundation.org>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
> 
>  scripts/Makefile.lib | 28 ++++++++++------------------
>  1 file changed, 10 insertions(+), 18 deletions(-)
> 
> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> index fe3668dc4954..207325eaf1d1 100644
> --- a/scripts/Makefile.lib
> +++ b/scripts/Makefile.lib
> @@ -400,26 +400,23 @@ $(obj)/%.dtb.S: $(obj)/%.dtb FORCE
>  $(obj)/%.dtbo.S: $(obj)/%.dtbo FORCE
>  	$(call if_changed,wrap_S_dtb)
>  
> -quiet_cmd_dtc = DTC     $@
> +quiet_dtb_check_tag = $(if $(dtb-check-enabled),[C],   )
> +cmd_dtb_check = $(if $(dtb-check-enabled),; $(DT_CHECKER) $(DT_CHECKER_FLAGS) -u $(srctree)/$(DT_BINDING_DIR) -p $(DT_TMP_SCHEMA) $@ || true)
> +
> +quiet_cmd_dtc = DTC $(quiet_dtb_check_tag) $@
>  cmd_dtc = $(HOSTCC) -E $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \
>  	$(DTC) -o $@ -b 0 \
>  		$(addprefix -i,$(dir $<) $(DTC_INCLUDE)) $(DTC_FLAGS) \
>  		-d $(depfile).dtc.tmp $(dtc-tmp) ; \
> -	cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile)
> -
> -DT_CHECK_CMD = $(DT_CHECKER) $(DT_CHECKER_FLAGS) -u $(srctree)/$(DT_BINDING_DIR) -p $(DT_TMP_SCHEMA)
> +	cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile) \
> +	$(cmd_dtb_check)
>  
>  # NOTE:
>  # Do not replace $(filter %.dtb %.dtbo, $^) with $(real-prereqs). When a single
>  # DTB is turned into a multi-blob DTB, $^ will contain header file dependencies
>  # recorded in the .*.cmd file.
> -ifneq ($(CHECK_DTBS),)
> -quiet_cmd_fdtoverlay = DTOVLCH $@
> -      cmd_fdtoverlay = $(objtree)/scripts/dtc/fdtoverlay -o $@ -i $(filter %.dtb %.dtbo, $^) ; $(DT_CHECK_CMD) $@ || true
> -else
> -quiet_cmd_fdtoverlay = DTOVL   $@
> -      cmd_fdtoverlay = $(objtree)/scripts/dtc/fdtoverlay -o $@ -i $(filter %.dtb %.dtbo, $^)
> -endif
> +quiet_cmd_fdtoverlay = OVL $(quiet_dtb_check_tag) $@
> +      cmd_fdtoverlay = $(objtree)/scripts/dtc/fdtoverlay -o $@ -i $(filter %.dtb %.dtbo, $^) $(cmd_dtb_check)
>  
>  $(multi-dtb-y): FORCE
>  	$(call if_changed,fdtoverlay)
> @@ -430,16 +427,11 @@ DT_CHECKER ?= dt-validate
>  DT_CHECKER_FLAGS ?= $(if $(DT_SCHEMA_FILES),-l $(DT_SCHEMA_FILES),-m)
>  DT_BINDING_DIR := Documentation/devicetree/bindings
>  DT_TMP_SCHEMA := $(objtree)/$(DT_BINDING_DIR)/processed-schema.json
> -
> -quiet_cmd_dtb =	DTC_CHK $@
> -      cmd_dtb =	$(cmd_dtc) ; $(DT_CHECK_CMD) $@ || true
> -else
> -quiet_cmd_dtb = $(quiet_cmd_dtc)
> -      cmd_dtb = $(cmd_dtc)
> +dtb-check-enabled = $(if $(filter %.dtb, $@),y)
>  endif
>  
>  $(obj)/%.dtb: $(obj)/%.dts $(DTC) $(DT_TMP_SCHEMA) FORCE
> -	$(call if_changed_dep,dtb)
> +	$(call if_changed_dep,dtc)
>  
>  $(obj)/%.dtbo: $(src)/%.dtso $(DTC) FORCE
>  	$(call if_changed_dep,dtc)
> -- 
> 2.43.0
> 

Looks good to me, thanks.

Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>

      reply	other threads:[~2024-08-02 23:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-25 19:23 [PATCH] kbuild: clean up code duplication in cmd_fdtoverlay Masahiro Yamada
2024-08-02 23:41 ` Nicolas Schier [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240803-cryptic-tan-emu-7c58ce@lindesnes \
    --to=nicolas@fjasle.eu \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masahiroy@kernel.org \
    --cc=nathan@kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox