diff mbox series

[v3,11/11] dt-bindings: leds: aw200xx: fix led pattern and add reg constraints

Message ID 20231101142445.8753-12-ddrokosov@salutedevices.com
State Superseded
Headers show
Series leds: aw200xx: several driver updates | expand

Commit Message

Dmitry Rokosov Nov. 1, 2023, 2:24 p.m. UTC
AW200XX controllers have the capability to declare more than 0xf LEDs,
therefore, it is necessary to accept LED names using an appropriate
regex pattern.

The register offsets can be adjusted within the specified range, with
the maximum value corresponding to the highest number of LEDs that can
be connected to the controller.

Fixes: e338a05e76ca ("dt-bindings: leds: Add binding for AW200xx")
Signed-off-by: Dmitry Rokosov <ddrokosov@salutedevices.com>
---
 .../bindings/leds/awinic,aw200xx.yaml         | 64 +++++++++++++++++--
 1 file changed, 58 insertions(+), 6 deletions(-)

Comments

Conor Dooley Nov. 1, 2023, 3:31 p.m. UTC | #1
On Wed, Nov 01, 2023 at 05:24:45PM +0300, Dmitry Rokosov wrote:
> AW200XX controllers have the capability to declare more than 0xf LEDs,
> therefore, it is necessary to accept LED names using an appropriate
> regex pattern.
> 
> The register offsets can be adjusted within the specified range, with
> the maximum value corresponding to the highest number of LEDs that can
> be connected to the controller.
> 
> Fixes: e338a05e76ca ("dt-bindings: leds: Add binding for AW200xx")
> Signed-off-by: Dmitry Rokosov <ddrokosov@salutedevices.com>

You did correctly guess what I was getting at on the previous version.
Apologies for not replying - I got sick and things probably fell a bit
through the cracks.

Reviewed-by: Conor Dooley <conor.dooley@microchip.com>

Cheers,
Conor.

> ---
>  .../bindings/leds/awinic,aw200xx.yaml         | 64 +++++++++++++++++--
>  1 file changed, 58 insertions(+), 6 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/leds/awinic,aw200xx.yaml b/Documentation/devicetree/bindings/leds/awinic,aw200xx.yaml
> index 67c1d960db1d..ba4511664fb8 100644
> --- a/Documentation/devicetree/bindings/leds/awinic,aw200xx.yaml
> +++ b/Documentation/devicetree/bindings/leds/awinic,aw200xx.yaml
> @@ -45,17 +45,12 @@ properties:
>      maxItems: 1
>  
>  patternProperties:
> -  "^led@[0-9a-f]$":
> +  "^led@[0-9a-f]+$":
>      type: object
>      $ref: common.yaml#
>      unevaluatedProperties: false
>  
>      properties:
> -      reg:
> -        description:
> -          LED number
> -        maxItems: 1
> -
>        led-max-microamp:
>          default: 9780
>          description: |
> @@ -69,6 +64,63 @@ patternProperties:
>            where max-current-switch-number is determinated by led configuration
>            and depends on how leds are physically connected to the led driver.
>  
> +allOf:
> +  - if:
> +      properties:
> +        compatible:
> +          contains:
> +            const: awinic,aw20036
> +    then:
> +      patternProperties:
> +        "^led@[0-9a-f]+$":
> +          properties:
> +            reg:
> +              items:
> +                minimum: 0
> +                maximum: 36
> +
> +  - if:
> +      properties:
> +        compatible:
> +          contains:
> +            const: awinic,aw20054
> +    then:
> +      patternProperties:
> +        "^led@[0-9a-f]+$":
> +          properties:
> +            reg:
> +              items:
> +                minimum: 0
> +                maximum: 54
> +
> +  - if:
> +      properties:
> +        compatible:
> +          contains:
> +            const: awinic,aw20072
> +    then:
> +      patternProperties:
> +        "^led@[0-9a-f]+$":
> +          properties:
> +            reg:
> +              items:
> +                minimum: 0
> +                maximum: 72
> +
> +  - if:
> +      properties:
> +        compatible:
> +          contains:
> +            const: awinic,aw20108
> +    then:
> +      patternProperties:
> +        "^led@[0-9a-f]+$":
> +          properties:
> +            reg:
> +              items:
> +                minimum: 0
> +                maximum: 108
> +
>  required:
>    - compatible
>    - reg
> -- 
> 2.36.0
>
Dmitry Rokosov Nov. 1, 2023, 5:48 p.m. UTC | #2
Conor,

On Wed, Nov 01, 2023 at 03:31:28PM +0000, Conor Dooley wrote:
> On Wed, Nov 01, 2023 at 05:24:45PM +0300, Dmitry Rokosov wrote:
> > AW200XX controllers have the capability to declare more than 0xf LEDs,
> > therefore, it is necessary to accept LED names using an appropriate
> > regex pattern.
> > 
> > The register offsets can be adjusted within the specified range, with
> > the maximum value corresponding to the highest number of LEDs that can
> > be connected to the controller.
> > 
> > Fixes: e338a05e76ca ("dt-bindings: leds: Add binding for AW200xx")
> > Signed-off-by: Dmitry Rokosov <ddrokosov@salutedevices.com>
> 
> You did correctly guess what I was getting at on the previous version.
> Apologies for not replying - I got sick and things probably fell a bit
> through the cracks.

Don't worry! Take care and get well soon!

> 
> Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
> 

Should I include this tag in the next version with a fix for the 'reg'
maxItems, or would you review this patch again?

> Cheers,
> Conor.
> 
> > ---
> >  .../bindings/leds/awinic,aw200xx.yaml         | 64 +++++++++++++++++--
> >  1 file changed, 58 insertions(+), 6 deletions(-)
> > 
> > diff --git a/Documentation/devicetree/bindings/leds/awinic,aw200xx.yaml b/Documentation/devicetree/bindings/leds/awinic,aw200xx.yaml
> > index 67c1d960db1d..ba4511664fb8 100644
> > --- a/Documentation/devicetree/bindings/leds/awinic,aw200xx.yaml
> > +++ b/Documentation/devicetree/bindings/leds/awinic,aw200xx.yaml
> > @@ -45,17 +45,12 @@ properties:
> >      maxItems: 1
> >  
> >  patternProperties:
> > -  "^led@[0-9a-f]$":
> > +  "^led@[0-9a-f]+$":
> >      type: object
> >      $ref: common.yaml#
> >      unevaluatedProperties: false
> >  
> >      properties:
> > -      reg:
> > -        description:
> > -          LED number
> > -        maxItems: 1
> > -
> >        led-max-microamp:
> >          default: 9780
> >          description: |
> > @@ -69,6 +64,63 @@ patternProperties:
> >            where max-current-switch-number is determinated by led configuration
> >            and depends on how leds are physically connected to the led driver.
> >  
> > +allOf:
> > +  - if:
> > +      properties:
> > +        compatible:
> > +          contains:
> > +            const: awinic,aw20036
> > +    then:
> > +      patternProperties:
> > +        "^led@[0-9a-f]+$":
> > +          properties:
> > +            reg:
> > +              items:
> > +                minimum: 0
> > +                maximum: 36
> > +
> > +  - if:
> > +      properties:
> > +        compatible:
> > +          contains:
> > +            const: awinic,aw20054
> > +    then:
> > +      patternProperties:
> > +        "^led@[0-9a-f]+$":
> > +          properties:
> > +            reg:
> > +              items:
> > +                minimum: 0
> > +                maximum: 54
> > +
> > +  - if:
> > +      properties:
> > +        compatible:
> > +          contains:
> > +            const: awinic,aw20072
> > +    then:
> > +      patternProperties:
> > +        "^led@[0-9a-f]+$":
> > +          properties:
> > +            reg:
> > +              items:
> > +                minimum: 0
> > +                maximum: 72
> > +
> > +  - if:
> > +      properties:
> > +        compatible:
> > +          contains:
> > +            const: awinic,aw20108
> > +    then:
> > +      patternProperties:
> > +        "^led@[0-9a-f]+$":
> > +          properties:
> > +            reg:
> > +              items:
> > +                minimum: 0
> > +                maximum: 108
> > +
> >  required:
> >    - compatible
> >    - reg
> > -- 
> > 2.36.0
> >
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/leds/awinic,aw200xx.yaml b/Documentation/devicetree/bindings/leds/awinic,aw200xx.yaml
index 67c1d960db1d..ba4511664fb8 100644
--- a/Documentation/devicetree/bindings/leds/awinic,aw200xx.yaml
+++ b/Documentation/devicetree/bindings/leds/awinic,aw200xx.yaml
@@ -45,17 +45,12 @@  properties:
     maxItems: 1
 
 patternProperties:
-  "^led@[0-9a-f]$":
+  "^led@[0-9a-f]+$":
     type: object
     $ref: common.yaml#
     unevaluatedProperties: false
 
     properties:
-      reg:
-        description:
-          LED number
-        maxItems: 1
-
       led-max-microamp:
         default: 9780
         description: |
@@ -69,6 +64,63 @@  patternProperties:
           where max-current-switch-number is determinated by led configuration
           and depends on how leds are physically connected to the led driver.
 
+allOf:
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: awinic,aw20036
+    then:
+      patternProperties:
+        "^led@[0-9a-f]+$":
+          properties:
+            reg:
+              items:
+                minimum: 0
+                maximum: 36
+
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: awinic,aw20054
+    then:
+      patternProperties:
+        "^led@[0-9a-f]+$":
+          properties:
+            reg:
+              items:
+                minimum: 0
+                maximum: 54
+
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: awinic,aw20072
+    then:
+      patternProperties:
+        "^led@[0-9a-f]+$":
+          properties:
+            reg:
+              items:
+                minimum: 0
+                maximum: 72
+
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: awinic,aw20108
+    then:
+      patternProperties:
+        "^led@[0-9a-f]+$":
+          properties:
+            reg:
+              items:
+                minimum: 0
+                maximum: 108
+
 required:
   - compatible
   - reg