]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
dt-bindings: kbuild: Support single binding targets
authorRob Herring (Arm) <robh@kernel.org>
Mon, 8 Dec 2025 22:43:03 +0000 (16:43 -0600)
committerRob Herring (Arm) <robh@kernel.org>
Wed, 17 Dec 2025 15:16:14 +0000 (09:16 -0600)
Running the full 'make dt_binding_check' is slow. A shortcut is to set
DT_SCHEMA_FILES env variable to a substring of DT schema files to test.
It both limits which examples are validated and which schemas are used
to validate the examples. This is a problem because errors from other
schemas are missed. What makes validation slow is checking all examples,
so we really just need a way to test a single example.

Add a %.yaml target to validate the schema and validate the example:

make example-schema.yaml

The behavior for 'make dt_binding_check DT_SCHEMA_FILES=example-schema'
is unchanged. Really it should mirror dtbs_check and validate all the
examples with a subset of schemas, but there are lots of users of
expecting the existing behavior.

Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Link: https://patch.msgid.link/20251208224304.2907913-1-robh@kernel.org
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
Documentation/devicetree/bindings/Makefile
Documentation/devicetree/bindings/writing-schema.rst
Makefile

index 8d6f85f4455da2a82a216772db715fc57eb545db..1e116425ad704e1930017de5b10acccce6a4c44c 100644 (file)
@@ -82,5 +82,8 @@ clean-files = $(shell find $(obj) \( -name '*.example.dts' -o \
 dt_compatible_check: $(obj)/processed-schema.json
        $(Q)$(srctree)/scripts/dtc/dt-extract-compatibles $(srctree) | xargs dt-check-compatible -v -s $<
 
+PHONY += dt_binding_check_one
+dt_binding_check_one: $(obj)/.dt-binding.checked $(obj)/.yamllint.checked
+
 PHONY += dt_binding_check
-dt_binding_check: $(obj)/.dt-binding.checked $(obj)/.yamllint.checked $(CHK_DT_EXAMPLES)
+dt_binding_check: dt_binding_check_one $(CHK_DT_EXAMPLES)
index 05c34248e5447d47ea90002f1e007a776b9e2514..2ff5b0565a313d7d4686b6dd9b8e266e683e6ec5 100644 (file)
@@ -214,6 +214,10 @@ binding schema. All of the DT binding documents can be validated using the
 
     make dt_binding_check
 
+Or to validate a single schema and its example::
+
+    make sram/sram.yaml
+
 In order to perform validation of DT source files, use the ``dtbs_check`` target::
 
     make dtbs_check
@@ -226,10 +230,10 @@ It is possible to run both in a single command::
 
     make dt_binding_check dtbs_check
 
-It is also possible to run checks with a subset of matching schema files by
-setting the ``DT_SCHEMA_FILES`` variable to 1 or more specific schema files or
-patterns (partial match of a fixed string). Each file or pattern should be
-separated by ':'.
+It is also possible to combine running the above commands with a subset of
+matching schema files by setting the ``DT_SCHEMA_FILES`` variable to 1 or more
+specific schema files or patterns (partial match of a fixed string). Each file
+or pattern should be separated by ':'.
 
 ::
 
index e404e4767944ed158560228304fc862b7fbfd83e..54eb78206d2d986cea527d26aa538dd7a9bb5763 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1506,6 +1506,12 @@ ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/boot/dts/),)
 dtstree := arch/$(SRCARCH)/boot/dts
 endif
 
+dtbindingtree := Documentation/devicetree/bindings
+
+%.yaml: dtbs_prepare
+       $(Q)$(MAKE) $(build)=$(dtbindingtree) \
+                   $(dtbindingtree)/$(patsubst %.yaml,%.example.dtb,$@) dt_binding_check_one
+
 ifneq ($(dtstree),)
 
 %.dtb: dtbs_prepare
@@ -1523,7 +1529,7 @@ dtbs: dtbs_prepare
 # dtbs_install depend on it as dtbs_install may run as root.
 dtbs_prepare: include/config/kernel.release scripts_dtc
 
-ifneq ($(filter dtbs_check, $(MAKECMDGOALS)),)
+ifneq ($(filter dtbs_check %.yaml, $(MAKECMDGOALS)),)
 export CHECK_DTBS=y
 endif
 
@@ -1556,14 +1562,14 @@ endif
 
 PHONY += dt_binding_check dt_binding_schemas
 dt_binding_check: dt_binding_schemas scripts_dtc
-       $(Q)$(MAKE) $(build)=Documentation/devicetree/bindings $@
+       $(Q)$(MAKE) $(build)=$(dtbindingtree) $@
 
 dt_binding_schemas:
-       $(Q)$(MAKE) $(build)=Documentation/devicetree/bindings
+       $(Q)$(MAKE) $(build)=$(dtbindingtree)
 
 PHONY += dt_compatible_check
 dt_compatible_check: dt_binding_schemas
-       $(Q)$(MAKE) $(build)=Documentation/devicetree/bindings $@
+       $(Q)$(MAKE) $(build)=$(dtbindingtree) $@
 
 # ---------------------------------------------------------------------------
 # Modules