All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kbuild: remove unneeded -O option to dtc
@ 2021-03-10 11:08 Masahiro Yamada
  2021-03-10 14:41 ` Viresh Kumar
  2021-03-10 16:54 ` Rob Herring
  0 siblings, 2 replies; 3+ messages in thread
From: Masahiro Yamada @ 2021-03-10 11:08 UTC (permalink / raw)
  To: linux-kbuild
  Cc: devicetree, Viresh Kumar, Masahiro Yamada, Michal Marek, linux-kernel

This piece of code converts the target suffix to the dtc -O option:

    *.dtb      ->  -O dtb
    *.dt.yaml  ->  -O yaml

Commit ce88c9c79455 ("kbuild: Add support to build overlays (%.dtbo)")
added the third case:

    *.dtbo     ->  -O dtbo

This works thanks to commit 163f0469bf2e ("dtc: Allow overlays to have
.dtbo extension") in the upstream DTC, which has already been pulled in
the kernel.

However, I think it is a bit odd because "dtbo" is not a format name.
At least, it does not show up in the help message of dtc.

$ scripts/dtc/dtc --help
  [ snip ]
  -O, --out-format <arg>
        Output formats are:
                dts - device tree source text
                dtb - device tree blob
                yaml - device tree encoded as YAML
                asm - assembler source

So, I am not a big fan of the second hunk of that change:

        } else if (streq(outform, "dtbo")) {
                dt_to_blob(outf, dti, outversion);

Anyway, we did not need to do this in Makefile in the first place.

guess_type_by_name() had already understood ".yaml" before commit
4f0e3a57d6eb ("kbuild: Add support for DT binding schema checks"),
and now does ".dtbo" as well.

Makefile does not need to duplicate the same logic. Let's leave it
to dtc.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 scripts/Makefile.lib | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index eee59184de64..90a4e04cd8f5 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -327,7 +327,7 @@ $(obj)/%.dtb.S: $(obj)/%.dtb FORCE
 
 quiet_cmd_dtc = DTC     $@
 cmd_dtc = $(HOSTCC) -E $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \
-	$(DTC) -O $(patsubst .%,%,$(suffix $@)) -o $@ -b 0 \
+	$(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)
-- 
2.27.0


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

* Re: [PATCH] kbuild: remove unneeded -O option to dtc
  2021-03-10 11:08 [PATCH] kbuild: remove unneeded -O option to dtc Masahiro Yamada
@ 2021-03-10 14:41 ` Viresh Kumar
  2021-03-10 16:54 ` Rob Herring
  1 sibling, 0 replies; 3+ messages in thread
From: Viresh Kumar @ 2021-03-10 14:41 UTC (permalink / raw)
  To: Masahiro Yamada, robh+dt
  Cc: linux-kbuild, devicetree, Michal Marek, linux-kernel

On 10-03-21, 20:08, Masahiro Yamada wrote:
> This piece of code converts the target suffix to the dtc -O option:
> 
>     *.dtb      ->  -O dtb
>     *.dt.yaml  ->  -O yaml
> 
> Commit ce88c9c79455 ("kbuild: Add support to build overlays (%.dtbo)")
> added the third case:
> 
>     *.dtbo     ->  -O dtbo
> 
> This works thanks to commit 163f0469bf2e ("dtc: Allow overlays to have
> .dtbo extension") in the upstream DTC, which has already been pulled in
> the kernel.
> 
> However, I think it is a bit odd because "dtbo" is not a format name.
> At least, it does not show up in the help message of dtc.
> 
> $ scripts/dtc/dtc --help
>   [ snip ]
>   -O, --out-format <arg>
>         Output formats are:
>                 dts - device tree source text
>                 dtb - device tree blob
>                 yaml - device tree encoded as YAML
>                 asm - assembler source
> 
> So, I am not a big fan of the second hunk of that change:
> 
>         } else if (streq(outform, "dtbo")) {
>                 dt_to_blob(outf, dti, outversion);

Looking at the very first version of the patch I sent,

https://lore.kernel.org/lkml/7aa70809eff3f32d821761d2a763e4fb72ecc8fb.1609844956.git.viresh.kumar@linaro.org/

this change was the only thing that was required to make it work.

I think the reason was that "outform != NULL" as -O option was passed
by the kernel.

> Anyway, we did not need to do this in Makefile in the first place.
> 
> guess_type_by_name() had already understood ".yaml" before commit
> 4f0e3a57d6eb ("kbuild: Add support for DT binding schema checks"),
> and now does ".dtbo" as well.
> 
> Makefile does not need to duplicate the same logic. Let's leave it
> to dtc.
> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
> 
>  scripts/Makefile.lib | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> index eee59184de64..90a4e04cd8f5 100644
> --- a/scripts/Makefile.lib
> +++ b/scripts/Makefile.lib
> @@ -327,7 +327,7 @@ $(obj)/%.dtb.S: $(obj)/%.dtb FORCE
>  
>  quiet_cmd_dtc = DTC     $@
>  cmd_dtc = $(HOSTCC) -E $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \
> -	$(DTC) -O $(patsubst .%,%,$(suffix $@)) -o $@ -b 0 \
> +	$(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)

LGTM.

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>

-- 
viresh

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

* Re: [PATCH] kbuild: remove unneeded -O option to dtc
  2021-03-10 11:08 [PATCH] kbuild: remove unneeded -O option to dtc Masahiro Yamada
  2021-03-10 14:41 ` Viresh Kumar
@ 2021-03-10 16:54 ` Rob Herring
  1 sibling, 0 replies; 3+ messages in thread
From: Rob Herring @ 2021-03-10 16:54 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Linux Kbuild mailing list, devicetree, Viresh Kumar,
	Michal Marek, linux-kernel

On Wed, Mar 10, 2021 at 4:09 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> This piece of code converts the target suffix to the dtc -O option:
>
>     *.dtb      ->  -O dtb
>     *.dt.yaml  ->  -O yaml
>
> Commit ce88c9c79455 ("kbuild: Add support to build overlays (%.dtbo)")
> added the third case:
>
>     *.dtbo     ->  -O dtbo
>
> This works thanks to commit 163f0469bf2e ("dtc: Allow overlays to have
> .dtbo extension") in the upstream DTC, which has already been pulled in
> the kernel.
>
> However, I think it is a bit odd because "dtbo" is not a format name.
> At least, it does not show up in the help message of dtc.
>
> $ scripts/dtc/dtc --help
>   [ snip ]
>   -O, --out-format <arg>
>         Output formats are:
>                 dts - device tree source text
>                 dtb - device tree blob
>                 yaml - device tree encoded as YAML
>                 asm - assembler source
>
> So, I am not a big fan of the second hunk of that change:
>
>         } else if (streq(outform, "dtbo")) {
>                 dt_to_blob(outf, dti, outversion);
>
> Anyway, we did not need to do this in Makefile in the first place.
>
> guess_type_by_name() had already understood ".yaml" before commit
> 4f0e3a57d6eb ("kbuild: Add support for DT binding schema checks"),
> and now does ".dtbo" as well.
>
> Makefile does not need to duplicate the same logic. Let's leave it
> to dtc.
>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
>
>  scripts/Makefile.lib | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> index eee59184de64..90a4e04cd8f5 100644
> --- a/scripts/Makefile.lib
> +++ b/scripts/Makefile.lib
> @@ -327,7 +327,7 @@ $(obj)/%.dtb.S: $(obj)/%.dtb FORCE
>
>  quiet_cmd_dtc = DTC     $@
>  cmd_dtc = $(HOSTCC) -E $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \
> -       $(DTC) -O $(patsubst .%,%,$(suffix $@)) -o $@ -b 0 \
> +       $(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)

I think you should also drop 'yaml' from:

$(call if_changed_rule,dtc,yaml)

Though that's somewhat separate, so either way:

Acked-by: Rob Herring <robh@kernel.org>

Rob

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

end of thread, other threads:[~2021-03-10 16:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-10 11:08 [PATCH] kbuild: remove unneeded -O option to dtc Masahiro Yamada
2021-03-10 14:41 ` Viresh Kumar
2021-03-10 16:54 ` Rob Herring

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.