Re: [PATCH v2] kbuild: allow validating individual dtb files against schema

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jul 6, 2022 at 8:44 PM Dmitry Baryshkov
<dmitry.baryshkov@xxxxxxxxxx> wrote:
>
> While it is possible to validate all generated dtb files against the
> schema, it typically results in huge pile of warnings. While working on
> a platform it is quite useful to validate just a single file against
> schema.
>
> Allow specifying CHECK_DTBS=1 on a make command line to enable
> validation while building dtb files. This reuses the infrastructure
> existing for `make dtbs_check`, making dtbs_check a shortcut for
> `make CHECK_DTBS=1 dt_binding_check dtbs`.
>
> Cc: Bjorn Andersson <bjorn.andersson@xxxxxxxxxx>
> Cc: Tom Rini <trini@xxxxxxxxxxxx>
> Cc: Masahiro Yamada <masahiroy@xxxxxxxxxx>
> Cc: linux-kbuild@xxxxxxxxxxxxxxx
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@xxxxxxxxxx>
> ---
>
> Changes since v1:
> - Added dependency to rebuild schema if `make dtbs` was used.
>
> ---
>  Makefile | 20 +++++++++++++++-----
>  1 file changed, 15 insertions(+), 5 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index 9aa7de1ca58f..5a9858aa4934 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1464,14 +1464,18 @@ endif
>
>  ifneq ($(dtstree),)
>
> -%.dtb: include/config/kernel.release scripts_dtc
> +ifneq ($(CHECK_DTBS),)
> +DT_TMP_BINDING := dt_binding
> +endif
> +
> +%.dtb: include/config/kernel.release scripts_dtc $(DT_TMP_BINDING)
>         $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@
>
> -%.dtbo: include/config/kernel.release scripts_dtc
> +%.dtbo: include/config/kernel.release scripts_dtc $(DT_TMP_BINDING)
>         $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@
>
>  PHONY += dtbs dtbs_install dtbs_check
> -dtbs: include/config/kernel.release scripts_dtc
> +dtbs: include/config/kernel.release scripts_dtc $(DT_TMP_BINDING)
>         $(Q)$(MAKE) $(build)=$(dtstree)
>
>  ifneq ($(filter dtbs_check, $(MAKECMDGOALS)),)
> @@ -1498,8 +1502,10 @@ ifneq ($(filter dt_binding_check, $(MAKECMDGOALS)),)
>  export CHECK_DT_BINDING=y
>  endif
>
> -PHONY += dt_binding_check
> -dt_binding_check: scripts_dtc
> +dt_binding_check: dt_binding
> +
> +PHONY += dt_binding
> +dt_binding: scripts_dtc
>         $(Q)$(MAKE) $(build)=Documentation/devicetree/bindings
>
>  # ---------------------------------------------------------------------------
> @@ -1774,6 +1780,10 @@ help:
>         @echo  '                3: more obscure warnings, can most likely be ignored'
>         @echo  '                e: warnings are being treated as errors'
>         @echo  '                Multiple levels can be combined with W=12 or W=123'
> +       @$(if $(dtstree), \
> +               echo '  make CHECK_DTBS=1 [targets] Check all generated dtb files against schema'; \
> +               echo '         This can be applied both to "dtbs" and to individual "foo.dtb" targets' ; \
> +               )
>         @echo  ''
>         @echo  'Execute "make" or "make all" to build all targets marked with [*] '
>         @echo  'For further info see the ./README file'
> --
> 2.35.1
>


I think the idea seems OK to me, but we can make it simpler.


First, apply the following clean-up patch to reduce the code duplication.
https://lore.kernel.org/all/20220716093122.137494-1-masahiroy@xxxxxxxxxx/T/#u


Then, apply the attached patch.diff

Please try it.







-- 
Best Regards
Masahiro Yamada
diff --git a/Makefile b/Makefile
index 8aa4dbb8f878..cc80b6b8d5f8 100644
--- a/Makefile
+++ b/Makefile
@@ -1383,13 +1383,16 @@ dtbs: dtbs_prepare
 # targets (, which may run as root) must not modify the tree.
 dtbs_prepare: include/config/kernel.release scripts_dtc
 
+# 'make dtbs_check' is a shorthand of 'make CHECK_DTBS=y dtbs'
 ifneq ($(filter dtbs_check, $(MAKECMDGOALS)),)
 export CHECK_DTBS=y
-dtbs: dt_binding_check
 endif
-
 dtbs_check: dtbs
 
+ifneq ($(CHECK_DTBS),)
+dtbs_prepare: dt_binding_check
+endif
+
 dtbs_install:
 	$(Q)$(MAKE) $(dtbinst)=$(dtstree) dst=$(INSTALL_DTBS_PATH)
 

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [Linux for Sparc]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux