Skip to contentSkip to conversation

dt-bindings: example-schema: Show example of dependentRequired

PATCH New Krzysztof Kozlowski 2 participants 2 messages Nov 11 Device tree bindings

lore
Share & tools
lore
#0 lore raw

PATCH v2 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.

---

Changes in v2:
1. Use clocks/clock-names in the dependentRequired, to avoid conflict with existing foo-supply constraint.

---
 Documentation/devicetree/bindings/example-schema.yaml | 8 ++++++++
 1 file changed, 8 insertions(+)
Documentation/devicetree/bindings/example-schema.yaml +8 -0
index b04f3cc4312c..a37d10ff7469 100644
@@ -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:
+  # clocks is not a required property in this binding, but if present, then
+  # clock-names must be provided as well.
+  clocks: [ clock-names ]
+
 # 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
#1 lore raw
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] dt-bindings: example-schema: duplicate dependencies and dependentRequired --

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Low] dt-bindings: example-schema: duplicate dependencies and dependentRequired
--

commit 1be156d7b94f469cc7bb5216878b759c591f8b64
Author: Krzysztof Kozlowski <[email protected]>

dt-bindings: example-schema: Show example of dependentRequired

This commit adds a dependentRequired block to example-schema.yaml to demonstrate conditional property requirements.

Quoted 9 lines
Documentation/devicetree/bindings/example-schema.yaml +1 -0
index b04f3cc4312c0..a37d10ff7469a 100644
@@ -217,6 +217,14 @@ required:
   - interrupts
   - interrupt-controller
 
+# Properties might be required only if some other property is present.

Documentation/devicetree/bindings/example-schema.yaml required: · line 230

Quoted 10 lines
Documentation/devicetree/bindings/example-schema.yaml +7 -0
+# dependentRequired is a shorter and preferred way to express this, instead of
+# if:then: block.
+dependentRequired:
+  # clocks is not a required property in this binding, but if present, then
+  # clock-names must be provided as well.
+  clocks: [ clock-names ]
+
 # 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.

[Severity: Low]
Should this replace the existing dependencies block just above required instead of adding a second section for the same construct?

example-schema.yaml already demonstrates conditional property presence under the Draft-07 dependencies keyword (which is also referenced in the allOf comment below), so keeping both leaves the example showing the legacy and Draft 2019-09 keywords side by side.

Also, requiring clock-names whenever clocks is present conflicts with the clocks and clock-names definitions earlier in this file, where clocks has
maxItems: 1 and the comment on clock-names advises skipping xxx-names for single-entry lists.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1