* [PATCH v3] dt-bindings: example-schema: Show example of dependentRequired and dependentSchemas
@ 2026-11-11 18:41 Krzysztof Kozlowski
2026-11-12 1:10 ` Rob Herring (Arm)
0 siblings, 1 reply; 2+ messages in thread
From: Krzysztof Kozlowski @ 2026-11-11 18:41 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, devicetree, linux-kernel
Cc: Krzysztof Kozlowski
Document example usage of dependentRequired, a shorter and preferred
form of conditional property requirement over dependencies and
if:then: block, and dependentSchemas replacing the if:required:then:.
Place both after the "required:" list.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
---
Changes in v3:
1. Replace existing dependencies and add dependentSchemas
Changes in v2:
1. Use clocks/clock-names in the dependentRequired, to avoid conflict
with existing foo-supply constraint.
---
.../devicetree/bindings/example-schema.yaml | 33 ++++++++++---------
1 file changed, 18 insertions(+), 15 deletions(-)
diff --git a/Documentation/devicetree/bindings/example-schema.yaml b/Documentation/devicetree/bindings/example-schema.yaml
index b04f3cc4312c..801677a13755 100644
--- a/Documentation/devicetree/bindings/example-schema.yaml
+++ b/Documentation/devicetree/bindings/example-schema.yaml
@@ -202,8 +202,17 @@ properties:
compatible:
const: vendor,sub-device
+required:
+ - compatible
+ - reg
+ - interrupts
+ - interrupt-controller
+
# Describe the relationship between different properties
-dependencies:
+# Properties might be required only if some other property is present.
+# dependentRequired is a shorter and preferred way to express this, instead of
+# "dependencies" and if:then: block.
+dependentRequired:
# 'vendor,bool-property' is only allowed when 'vendor,string-array-property'
# is present
vendor,bool-property: [ 'vendor,string-array-property' ]
@@ -211,11 +220,14 @@ dependencies:
# must be present or none of them.
vendor,string-array-property: [ 'vendor,bool-property' ]
-required:
- - compatible
- - reg
- - interrupts
- - interrupt-controller
+# When given property is present, entire object must also validate against subschema.
+dependentSchemas:
+ vendor,bool-property:
+ # If vendor,bool-property is present, the vendor,int-property accepts smaller
+ # set of values
+ properties:
+ vendor,int-property:
+ enum: [2, 4, 6]
# if/then schema can be used to handle conditions on a property affecting
# another property. A typical case is a specific 'compatible' value changes the
@@ -238,15 +250,6 @@ allOf:
# If otherwise the property is not allowed:
properties:
foo-supply: false
- # Altering schema depending on presence of properties is usually done by
- # dependencies (see above), however some adjustments might require if:
- - if:
- required:
- - vendor,bool-property
- then:
- properties:
- vendor,int-property:
- enum: [2, 4, 6]
# Ideally, the schema should have this line otherwise any other properties
# present are allowed. There's a few common properties such as 'status' and
--
2.53.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v3] dt-bindings: example-schema: Show example of dependentRequired and dependentSchemas
2026-11-11 18:41 [PATCH v3] dt-bindings: example-schema: Show example of dependentRequired and dependentSchemas Krzysztof Kozlowski
@ 2026-11-12 1:10 ` Rob Herring (Arm)
0 siblings, 0 replies; 2+ messages in thread
From: Rob Herring (Arm) @ 2026-11-12 1:10 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: Conor Dooley, linux-kernel, devicetree, Krzysztof Kozlowski
On Wed, 11 Nov 2026 19:41:40 +0100, Krzysztof Kozlowski wrote:
> Document example usage of dependentRequired, a shorter and preferred
> form of conditional property requirement over dependencies and
> if:then: block, and dependentSchemas replacing the if:required:then:.
>
> Place both after the "required:" list.
>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
>
> ---
>
> Changes in v3:
> 1. Replace existing dependencies and add dependentSchemas
>
> Changes in v2:
> 1. Use clocks/clock-names in the dependentRequired, to avoid conflict
> with existing foo-supply constraint.
> ---
> .../devicetree/bindings/example-schema.yaml | 33 ++++++++++---------
> 1 file changed, 18 insertions(+), 15 deletions(-)
>
Applied, thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-12 1:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-11 18:41 [PATCH v3] dt-bindings: example-schema: Show example of dependentRequired and dependentSchemas Krzysztof Kozlowski
2026-11-12 1:10 ` Rob Herring (Arm)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®