Re: [PATCH 2/2] kbuild: Build DT binding examples with dtc warnings enabled

Masahiro Yamada
2020-02-22T16:50:50Z

Hi Rob,

On Sat, Feb 22, 2020 at 7:29 AM Rob Herring <robh@kernel.org> wrote:
>
> Now that we have a separate rule for DT binding examples, we can customize
> the dtc options. Let's adjust the dtc warnings to me more strict by
> default so the examples get cleaned up as they get converted to schema.
>
> Leaving 'avoid_unnecessary_addr_size' and 'graph_child_address' warnings
> disabled as examples tend to be incomplete and they generates a lot of
> warnings.
>
> Cc: Masahiro Yamada <masahiroy@kernel.org>
> Cc: Michal Marek <michal.lkml@markovi.net>
> Cc: linux-kbuild@vger.kernel.org
> Signed-off-by: Rob Herring <robh@kernel.org>
> ---
> scripts/Makefile.lib | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> index 78fa1a3d983a..1a149e680308 100644
> --- a/scripts/Makefile.lib
> +++ b/scripts/Makefile.lib
> @@ -308,6 +308,10 @@ define rule_dtc_dt_yaml
> $(call cmd,dtb_check,$(word 2, $(real-prereqs)))
> endef
>
> +$(obj)/%.example.dt.yaml: DTC_FLAGS = \
> + -Wno-avoid_unnecessary_addr_size \
> + -Wno-graph_child_address
> +

This does not work since I suggested to
not add this pattern rule in 1/2.

Instead, you can override DTC_FLAGS
from Documentation/devicetree/bindings/Makefile

So, alternative solution is like follows
(on top of my suggestion in 1/2)

diff --git a/Documentation/devicetree/bindings/Makefile
b/Documentation/devicetree/bindings/Makefile
index 7c40d5ba1b51..e44c972849e6 100644
--- a/Documentation/devicetree/bindings/Makefile
+++ b/Documentation/devicetree/bindings/Makefile
@@ -12,6 +12,8 @@ $(obj)/%.example.dts: $(src)/%.yaml FORCE

# Use full schemas when checking %.example.dts
DT_TMP_SCHEMA := $(obj)/processed-schema-examples.yaml
+# More strict checks for examples
+override DTC_FLAGS := -Wno-avoid_unnecessary_addr_size -Wno-graph_child_address

quiet_cmd_mk_schema = SCHEMA $@
cmd_mk_schema = $(DT_MK_SCHEMA) $(DT_MK_SCHEMA_FLAGS) -o $@
$(real-prereqs)

One limitation for this way is that
you cannot use W=1, W=2, W=3 for example DT.

> $(obj)/%.example.dt.yaml: $(src)/%.example.dts $(DT_EXAMPLES_SCHEMA) $(DTC) FORCE
> $(call if_changed_rule,dtc_dt_yaml)

--
Best Regards
Masahiro Yamada