dt-bindings: example-schema: Show example of dependentRequired
PATCH 1/1 dt-bindings: example-schema: Show example of dependentRequired
dependentRequired is shorter and preferred form of conditional property requirement, over allOf:if:then: block, so document example usage.
--- Documentation/devicetree/bindings/example-schema.yaml | 8 ++++++++ 1 file changed, 8 insertions(+)
Documentation/devicetree/bindings/example-schema.yaml +8 -0
@@ -217,6 +217,14 @@ required: - interrupts - interrupt-controller +# Properties might be required only if some other property is present. +# dependentRequired is a shorter and preferred way to express this, instead of +# if:then: block. +dependentRequired: + # foo-gpios is not a required property, but if present, then foo-supply must + # be provided as well. + foo-gpios: [ foo-supply ] + # 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 # constraints on other properties.
Signature · 1 line
2.53.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] dt-bindings: example-schema: conflicting and duplicate dependentRequired example --
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Low] dt-bindings: example-schema: conflicting and duplicate dependentRequired example
--
commit a3f4513191420436a3b3975020d020b961833f59
Author: Krzysztof Kozlowski <[email protected]>
dt-bindings: example-schema: Show example of dependentRequired
This commit adds a dependentRequired example to example-schema.yaml to document the preferred way to express conditional property requirements.
Quoted 5 lines
Documentation/devicetree/bindings/example-schema.yaml +0
-0
Documentation/devicetree/bindings/example-schema.yaml required: · line 226
Quoted 10 lines
Documentation/devicetree/bindings/example-schema.yaml +7
-0@@ -217,6 +217,14 @@ required: - interrupts - interrupt-controller +# Properties might be required only if some other property is present. +# dependentRequired is a shorter and preferred way to express this, instead of +# if:then: block. +dependentRequired: + # foo-gpios is not a required property, but if present, then foo-supply must + # be provided as well. + foo-gpios: [ foo-supply ]
[Severity: Low]
Does requiring foo-supply when foo-gpios is present conflict with the allOf conditional block right below?
Documentation/devicetree/bindings/example-schema.yaml:allOf:
then:
required:
- foo-supply
else:
# If otherwise the property is not allowed:
properties:
foo-supply: false
That block already makes foo-supply unconditionally required on vendor,soc2-ip and forbids foo-supply on all other compatibles, which makes it impossible to specify foo-gpios on any compatible other than vendor,soc2-ip.
Also, should this replace the existing dependencies block just above required (and the comment in allOf referring to dependencies) rather than leaving two top-level keywords in the example schema that demonstrate the same construct?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 4 lines · On 11/11/2026 10:14, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Low] dt-bindings: example-schema: conflicting and duplicate dependentRequired example
I should choose different properties...
Best regards,
Krzysztof