Skip to contentSkip to conversation

dt-bindings: leds: Add missing (unevaluated|additional)Properties on child nodes

PATCH In review Rob Herring 2 participants 3 messages Aug 23, 2022 – Aug 24, 2022

Subsystems (3)
lore
Share & tools
lore

Rob Herring

author maintainer
#0 lore raw

PATCH 1/1 dt-bindings: leds: Add missing (unevaluated|additional)Properties on child nodes

In order to ensure only documented properties are present, node schemas must have unevaluatedProperties or additionalProperties set to false (typically).

---
 .../bindings/leds/issi,is31fl319x.yaml           |  1 +
 .../devicetree/bindings/leds/leds-aw2013.yaml    |  1 +
 .../devicetree/bindings/leds/leds-gpio.yaml      |  1 +
 .../devicetree/bindings/leds/leds-lgm.yaml       | 10 +++++++---
 .../devicetree/bindings/leds/leds-max77650.yaml  |  9 ++-------
 .../devicetree/bindings/leds/leds-pwm.yaml       |  1 +
 .../devicetree/bindings/leds/leds-qcom-lpg.yaml  |  6 ++++++
 .../bindings/leds/rohm,bd71828-leds.yaml         | 16 +++-------------
 .../devicetree/bindings/leds/ti,tca6507.yaml     |  1 +
 9 files changed, 23 insertions(+), 23 deletions(-)
Documentation/devicetree/bindings/leds/issi,is31fl319x.yaml +1 -0
index 940333f2d69c..2929382625b6 100644
@@ -57,6 +57,7 @@ patternProperties:
   "^led@[1-9]$":
     type: object
     $ref: common.yaml#
+    unevaluatedProperties: false
 
     properties:
       reg:
Documentation/devicetree/bindings/leds/leds-aw2013.yaml +1 -0
index e24b0d15ef01..6c3ea0f06cef 100644
@@ -33,6 +33,7 @@ patternProperties:
   "^led@[0-2]$":
     type: object
     $ref: common.yaml#
+    unevaluatedProperties: false
 
     properties:
       reg:
Documentation/devicetree/bindings/leds/leds-gpio.yaml +1 -0
index 7ad2baeda0b0..f156d3e47b71 100644
@@ -25,6 +25,7 @@ patternProperties:
     type: object
 
     $ref: common.yaml#
+    unevaluatedProperties: false
 
     properties:
       gpios:
Documentation/devicetree/bindings/leds/leds-lgm.yaml +7 -3
index f8d7963c3a13..8b3b3bf1eaf2 100644
@@ -56,7 +56,8 @@ properties:
 
     patternProperties:
       "^led@[0-2]$":
-        type: object
+        $ref: common.yaml#
+        unevaluatedProperties: false
 
         properties:
           reg:
@@ -64,6 +65,9 @@ properties:
             minimum: 0
             maximum: 2
 
+          led-gpios:
+            maxItems: 1
+
           intel,sso-hw-trigger:
             type: boolean
             description: This property indicates Hardware driven/control LED.
@@ -118,14 +122,14 @@ examples:
           reg = <0>;
           function = "gphy";
           color = <LED_COLOR_ID_GREEN>;
-          led-gpio = <&ssogpio 0 0>;
+          led-gpios = <&ssogpio 0 0>;
         };
 
         led@2 {
           reg = <2>;
           function = LED_FUNCTION_POWER;
           color = <LED_COLOR_ID_GREEN>;
-          led-gpio = <&ssogpio 23 0>;
+          led-gpios = <&ssogpio 23 0>;
         };
       };
     };
Documentation/devicetree/bindings/leds/leds-max77650.yaml +2 -7
index c6f96cabd4d1..fdb08f44a45d 100644
@@ -30,9 +30,8 @@ properties:
 
 patternProperties:
   "^led@[0-2]$":
-    type: object
-    description: |
-      Properties for a single LED.
+    $ref: common.yaml#
+    unevaluatedProperties: false
 
     properties:
       reg:
@@ -41,10 +40,6 @@ patternProperties:
         minimum: 0
         maximum: 2
 
-      label: true
-
-      linux,default-trigger: true
-
 required:
   - compatible
   - "#address-cells"
Documentation/devicetree/bindings/leds/leds-pwm.yaml +1 -0
index fe4d5fd25913..e60009863d07 100644
@@ -22,6 +22,7 @@ patternProperties:
     type: object
 
     $ref: common.yaml#
+    unevaluatedProperties: false
 
     properties:
       pwms:
Documentation/devicetree/bindings/leds/leds-qcom-lpg.yaml +6 -0
index 497db289169d..6f43aadea3be 100644
@@ -72,11 +72,17 @@ properties:
       "^led@[0-9a-f]$":
         type: object
         $ref: common.yaml#
+        unevaluatedProperties: false
+
+        properties:
+          reg:
+            maxItems: 1
 
 patternProperties:
   "^led@[0-9a-f]$":
     type: object
     $ref: common.yaml#
+    unevaluatedProperties: false
 
     properties:
       reg: true
Documentation/devicetree/bindings/leds/rohm,bd71828-leds.yaml +3 -13
index 86a37c92b834..ca92cea56a6f 100644
@@ -26,26 +26,16 @@ properties:
 
 patternProperties:
   "^led-[1-2]$":
-    type: object
-    description:
-      Properties for a single LED.
+    $ref: common.yaml#
+    unevaluatedProperties: false
+
     properties:
-      #allOf:
-        #- $ref: "common.yaml#"
       rohm,led-compatible:
         description: LED identification string
         $ref: "/schemas/types.yaml#/definitions/string"
         enum:
           - bd71828-ambled
           - bd71828-grnled
-      function:
-        description:
-          Purpose of LED as defined in dt-bindings/leds/common.h
-        $ref: "/schemas/types.yaml#/definitions/string"
-      color:
-        description:
-          LED colour as defined in dt-bindings/leds/common.h
-        $ref: "/schemas/types.yaml#/definitions/uint32"
 
 required:
   - compatible
Documentation/devicetree/bindings/leds/ti,tca6507.yaml +1 -0
index 32c600387895..e83964600993 100644
@@ -40,6 +40,7 @@ patternProperties:
     type: object
 
     $ref: common.yaml#
+    unevaluatedProperties: false
 
     properties:
       reg:
Signature · 1 line
2.34.1
#1 lore raw

Hi!

Quoted 5 lines

In order to ensure only documented properties are present, node schemas must have unevaluatedProperties or additionalProperties set to false (typically).

Patch does way more than that:

Can we get some explanation why that's correct?

Best regards,
Pavel

Quoted 40 lines

index f8d7963c3a13..8b3b3bf1eaf2 100644

Documentation/devicetree/bindings/leds/leds-lgm.yaml +7 -3
@@ -56,7 +56,8 @@ properties:
 
     patternProperties:
       "^led@[0-2]$":
-        type: object
+        $ref: common.yaml#
+        unevaluatedProperties: false
 
         properties:
           reg:
@@ -64,6 +65,9 @@ properties:
             minimum: 0
             maximum: 2
 
+          led-gpios:
+            maxItems: 1
+
           intel,sso-hw-trigger:
             type: boolean
             description: This property indicates Hardware driven/control LED.
@@ -118,14 +122,14 @@ examples:
           reg = <0>;
           function = "gphy";
           color = <LED_COLOR_ID_GREEN>;
-          led-gpio = <&ssogpio 0 0>;
+          led-gpios = <&ssogpio 0 0>;
         };
 
         led@2 {
           reg = <2>;
           function = LED_FUNCTION_POWER;
           color = <LED_COLOR_ID_GREEN>;
-          led-gpio = <&ssogpio 23 0>;
+          led-gpios = <&ssogpio 23 0>;
         };
       };
     };
Signature · 1 line
People of Russia, stop Putin before his war on Ukraine escalates.
author maintainer
#2 lore raw
Quoted 10 lines · Pavel Machek

Hi!

Quoted 5 lines

In order to ensure only documented properties are present, node schemas must have unevaluatedProperties or additionalProperties set to false (typically).

Patch does way more than that:

It only 'ensure only documented properties are present', but yeah, it is sometimes more than just adding unevaluatedProperties.

Quoted 1 line

Can we get some explanation why that's correct?

...adds missing $ref if needed, and fixes resulting errors about unevaluatedProperties.

BTW, these are just the simple ones. The led bindings with multi-led nodes are more of a mess. I haven't decided exactly how to fix those.

Rob