diff mbox series

[v2,1/4] dt-bindings: iio: hmc425a: add conditional GPIO array size constraints

Message ID 20240110153757.5754-2-mitrutzceclan@gmail.com (mailing list archive)
State Changes Requested
Headers show
Series Add support for LTC6373 | expand

Commit Message

Ceclan, Dumitru Jan. 10, 2024, 3:37 p.m. UTC
ADRF5740 and HMC540S have a 4 bit parallel interface.
Update ctr-gpios description and min/maxItems values depending on the
matched compatible to correctly reflect the hardware properties.

Signed-off-by: Dumitru Ceclan <mitrutzceclan@gmail.com>
---
 .../bindings/iio/amplifiers/adi,hmc425a.yaml  | 33 +++++++++++++++++--
 1 file changed, 30 insertions(+), 3 deletions(-)

Comments

Conor Dooley Jan. 10, 2024, 4:17 p.m. UTC | #1
On Wed, Jan 10, 2024 at 05:37:09PM +0200, Dumitru Ceclan wrote:
> ADRF5740 and HMC540S have a 4 bit parallel interface.
> Update ctr-gpios description and min/maxItems values depending on the
> matched compatible to correctly reflect the hardware properties.
> 
> Signed-off-by: Dumitru Ceclan <mitrutzceclan@gmail.com>

Seems like you need a Fixes: tag, since the original binding was wrong?

> ---
>  .../bindings/iio/amplifiers/adi,hmc425a.yaml  | 33 +++++++++++++++++--
>  1 file changed, 30 insertions(+), 3 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/iio/amplifiers/adi,hmc425a.yaml b/Documentation/devicetree/bindings/iio/amplifiers/adi,hmc425a.yaml
> index 67de9d4e3a1d..a434cb8ddcc9 100644
> --- a/Documentation/devicetree/bindings/iio/amplifiers/adi,hmc425a.yaml
> +++ b/Documentation/devicetree/bindings/iio/amplifiers/adi,hmc425a.yaml
> @@ -33,11 +33,38 @@ properties:
>  
>    ctrl-gpios:
>      description:
> -      Must contain an array of 6 GPIO specifiers, referring to the GPIO pins
> -      connected to the control pins V1-V6.
> -    minItems: 6
> +      Must contain an array of GPIO specifiers, referring to the GPIO pins
> +      connected to the control pins.
> +        ADRF5740  - 4 GPIO connected to D2-D5
> +        HMC540S   - 4 GPIO connected to V1-V4
> +        HMC425A   - 6 GPIO connected to V1-V6
> +    minItems: 1
>      maxItems: 6
>  
> +allOf:
> +  - if:
> +      properties:
> +        compatible:
> +          contains:
> +            const: adi,hmc425a
> +    then:
> +      properties:
> +        ctrl-gpios:
> +          minItems: 6

> +          maxItems: 6

This one should not be needed, it's already set by constraints on the
property above.

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

> +  - if:
> +      properties:
> +        compatible:
> +          contains:
> +            anyOf:
> +              - const: adi,adrf5740
> +              - const: adi,hmc540s
> +    then:
> +      properties:
> +        ctrl-gpios:
> +          minItems: 4
> +          maxItems: 4

I'd say this should be an else, but that clearly would just be churn
since your next patch adds something with a different set of
constraints.

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

Cheers,
Conor.

> +
>  required:
>    - compatible
>    - ctrl-gpios
> -- 
> 2.42.0
>
Ceclan, Dumitru Jan. 11, 2024, 8:17 a.m. UTC | #2
On 1/10/24 18:17, Conor Dooley wrote:
> On Wed, Jan 10, 2024 at 05:37:09PM +0200, Dumitru Ceclan wrote:...
>>    ctrl-gpios:
>>      description:
>> -      Must contain an array of 6 GPIO specifiers, referring to the GPIO pins
>> -      connected to the control pins V1-V6.
>> -    minItems: 6
>> +      Must contain an array of GPIO specifiers, referring to the GPIO pins
>> +      connected to the control pins.
>> +        ADRF5740  - 4 GPIO connected to D2-D5
>> +        HMC540S   - 4 GPIO connected to V1-V4
>> +        HMC425A   - 6 GPIO connected to V1-V6
>> +    minItems: 1
>>      maxItems: 6
>>  
>> +allOf:
>> +  - if:
>> +      properties:
>> +        compatible:
>> +          contains:
>> +            const: adi,hmc425a
>> +    then:
>> +      properties:
>> +        ctrl-gpios:
>> +          minItems: 6
> 
>> +          maxItems: 6
> 
> This one should not be needed, it's already set by constraints on the
> property above.
> 

No, not needed, just inspired from:
 /bindings/clock/samsung,exynos7-clock.yaml

Specifically, the top constraints:
  clocks:

    minItems: 1

    maxItems: 13

One of the conditional constraints:
  clocks:

    minItems: 13

    maxItems: 13


I would only have two arguments for this staying here:
 - It stays consistent with other cases
 - In the case a new device with more than 6 GPIOs is added, this would
need to be put back in
Conor Dooley Jan. 11, 2024, 4:31 p.m. UTC | #3
On Thu, Jan 11, 2024 at 10:17:58AM +0200, Ceclan Dumitru wrote:
> 
> 
> On 1/10/24 18:17, Conor Dooley wrote:
> > On Wed, Jan 10, 2024 at 05:37:09PM +0200, Dumitru Ceclan wrote:...
> >>    ctrl-gpios:
> >>      description:
> >> -      Must contain an array of 6 GPIO specifiers, referring to the GPIO pins
> >> -      connected to the control pins V1-V6.
> >> -    minItems: 6
> >> +      Must contain an array of GPIO specifiers, referring to the GPIO pins
> >> +      connected to the control pins.
> >> +        ADRF5740  - 4 GPIO connected to D2-D5
> >> +        HMC540S   - 4 GPIO connected to V1-V4
> >> +        HMC425A   - 6 GPIO connected to V1-V6
> >> +    minItems: 1
> >>      maxItems: 6
> >>  
> >> +allOf:
> >> +  - if:
> >> +      properties:
> >> +        compatible:
> >> +          contains:
> >> +            const: adi,hmc425a
> >> +    then:
> >> +      properties:
> >> +        ctrl-gpios:
> >> +          minItems: 6
> > 
> >> +          maxItems: 6
> > 
> > This one should not be needed, it's already set by constraints on the
> > property above.
> > 
> 
> No, not needed, just inspired from:
>  /bindings/clock/samsung,exynos7-clock.yaml
> 
> Specifically, the top constraints:
>   clocks:
> 
>     minItems: 1
> 
>     maxItems: 13
> 
> One of the conditional constraints:
>   clocks:
> 
>     minItems: 13
> 
>     maxItems: 13
> 
> 
> I would only have two arguments for this staying here:
>  - It stays consistent with other cases
>  - In the case a new device with more than 6 GPIOs is added, this would
> need to be put back in

Okay.
Conor Dooley Jan. 11, 2024, 4:33 p.m. UTC | #4
On Thu, Jan 11, 2024 at 04:31:40PM +0000, Conor Dooley wrote:
> On Thu, Jan 11, 2024 at 10:17:58AM +0200, Ceclan Dumitru wrote:
> > 
> > 
> > On 1/10/24 18:17, Conor Dooley wrote:
> > > On Wed, Jan 10, 2024 at 05:37:09PM +0200, Dumitru Ceclan wrote:...
> > >>    ctrl-gpios:
> > >>      description:
> > >> -      Must contain an array of 6 GPIO specifiers, referring to the GPIO pins
> > >> -      connected to the control pins V1-V6.
> > >> -    minItems: 6
> > >> +      Must contain an array of GPIO specifiers, referring to the GPIO pins
> > >> +      connected to the control pins.
> > >> +        ADRF5740  - 4 GPIO connected to D2-D5
> > >> +        HMC540S   - 4 GPIO connected to V1-V4
> > >> +        HMC425A   - 6 GPIO connected to V1-V6
> > >> +    minItems: 1
> > >>      maxItems: 6
> > >>  
> > >> +allOf:
> > >> +  - if:
> > >> +      properties:
> > >> +        compatible:
> > >> +          contains:
> > >> +            const: adi,hmc425a
> > >> +    then:
> > >> +      properties:
> > >> +        ctrl-gpios:
> > >> +          minItems: 6
> > > 
> > >> +          maxItems: 6
> > > 
> > > This one should not be needed, it's already set by constraints on the
> > > property above.
> > > 
> > 
> > No, not needed, just inspired from:
> >  /bindings/clock/samsung,exynos7-clock.yaml
> > 
> > Specifically, the top constraints:
> >   clocks:
> > 
> >     minItems: 1
> > 
> >     maxItems: 13
> > 
> > One of the conditional constraints:
> >   clocks:
> > 
> >     minItems: 13
> > 
> >     maxItems: 13
> > 
> > 
> > I would only have two arguments for this staying here:
> >  - It stays consistent with other cases
> >  - In the case a new device with more than 6 GPIOs is added, this would
> > need to be put back in
> 
> Okay.

Sorry, that's probably super unclear. I meant it's okay to leave it.
Jonathan Cameron Jan. 13, 2024, 3:36 p.m. UTC | #5
On Wed, 10 Jan 2024 16:17:45 +0000
Conor Dooley <conor@kernel.org> wrote:

> On Wed, Jan 10, 2024 at 05:37:09PM +0200, Dumitru Ceclan wrote:
> > ADRF5740 and HMC540S have a 4 bit parallel interface.
> > Update ctr-gpios description and min/maxItems values depending on the
> > matched compatible to correctly reflect the hardware properties.
> > 
> > Signed-off-by: Dumitru Ceclan <mitrutzceclan@gmail.com>  
> 
> Seems like you need a Fixes: tag, since the original binding was wrong?
If you aren't doing a v3 as nothing else to change then just replying with
an appropriate fixes tag to this email is fine as b4 will work it's magic
when I pull the patches off the archive.

Thanks,

Jonathan
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/iio/amplifiers/adi,hmc425a.yaml b/Documentation/devicetree/bindings/iio/amplifiers/adi,hmc425a.yaml
index 67de9d4e3a1d..a434cb8ddcc9 100644
--- a/Documentation/devicetree/bindings/iio/amplifiers/adi,hmc425a.yaml
+++ b/Documentation/devicetree/bindings/iio/amplifiers/adi,hmc425a.yaml
@@ -33,11 +33,38 @@  properties:
 
   ctrl-gpios:
     description:
-      Must contain an array of 6 GPIO specifiers, referring to the GPIO pins
-      connected to the control pins V1-V6.
-    minItems: 6
+      Must contain an array of GPIO specifiers, referring to the GPIO pins
+      connected to the control pins.
+        ADRF5740  - 4 GPIO connected to D2-D5
+        HMC540S   - 4 GPIO connected to V1-V4
+        HMC425A   - 6 GPIO connected to V1-V6
+    minItems: 1
     maxItems: 6
 
+allOf:
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: adi,hmc425a
+    then:
+      properties:
+        ctrl-gpios:
+          minItems: 6
+          maxItems: 6
+  - if:
+      properties:
+        compatible:
+          contains:
+            anyOf:
+              - const: adi,adrf5740
+              - const: adi,hmc540s
+    then:
+      properties:
+        ctrl-gpios:
+          minItems: 4
+          maxItems: 4
+
 required:
   - compatible
   - ctrl-gpios