diff mbox series

[1/2] regulator: dt-bindings: gpio-regulator: Fix {gpios-,}states limits

Message ID b20aab137058c02ab5af9aaa1280729a02c6ea49.1706802756.git.geert+renesas@glider.be
State Changes Requested
Headers show
Series regulator: gpio: Miscellaneous state fixes | expand

Checks

Context Check Description
robh/checkpatch warning total: 0 errors, 1 warnings, 16 lines checked
robh/patch-applied success
robh/dt-meta-schema fail build log

Commit Message

Geert Uytterhoeven Feb. 1, 2024, 3:58 p.m. UTC
make dtbs_check:

    arch/arm64/boot/dts/renesas/r8a77951-salvator-xs.dtb: regulator-vccq-sdhi0: Unevaluated properties are not allowed ('gpios-states', 'states' were unexpected)
	    from schema $id: http://devicetree.org/schemas/regulator/gpio-regulator.yaml#

The number of items in "gpios-states" must match the number of items in
"gpios", so their limits should be identical.

The number of items in "states" must lie within the range from zero up
to 2^{number of gpios}.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
The second issue did not cause any dtbs_check errors?
---
 .../devicetree/bindings/regulator/gpio-regulator.yaml         | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Rob Herring (Arm) Feb. 1, 2024, 5:31 p.m. UTC | #1
On Thu, 01 Feb 2024 16:58:41 +0100, Geert Uytterhoeven wrote:
> make dtbs_check:
> 
>     arch/arm64/boot/dts/renesas/r8a77951-salvator-xs.dtb: regulator-vccq-sdhi0: Unevaluated properties are not allowed ('gpios-states', 'states' were unexpected)
> 	    from schema $id: http://devicetree.org/schemas/regulator/gpio-regulator.yaml#
> 
> The number of items in "gpios-states" must match the number of items in
> "gpios", so their limits should be identical.
> 
> The number of items in "states" must lie within the range from zero up
> to 2^{number of gpios}.
> 
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> The second issue did not cause any dtbs_check errors?
> ---
>  .../devicetree/bindings/regulator/gpio-regulator.yaml         | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 

My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check'
on your patch (DT_CHECKER_FLAGS is new in v5.13):

yamllint warnings/errors:

dtschema/dtc warnings/errors:
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/regulator/gpio-regulator.yaml: properties:states:minItems: 0 is less than the minimum of 1
	hint: An array property has at least 1 item or is not present
	from schema $id: http://devicetree.org/meta-schemas/keywords.yaml#

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/b20aab137058c02ab5af9aaa1280729a02c6ea49.1706802756.git.geert+renesas@glider.be

The base for the series is generally the latest rc1. A different dependency
should be noted in *this* patch.

If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure 'yamllint' is installed and dt-schema is up to
date:

pip3 install dtschema --upgrade

Please check and re-submit after running the above command yourself. Note
that DT_SCHEMA_FILES can be set to your schema file to speed up checking
your schema. However, it must be unset to test all examples with your schema.
Geert Uytterhoeven Feb. 1, 2024, 8:05 p.m. UTC | #2
Hi Rob The Robot ;-)

On Thu, Feb 1, 2024 at 6:31 PM Rob Herring <robh@kernel.org> wrote:
> On Thu, 01 Feb 2024 16:58:41 +0100, Geert Uytterhoeven wrote:
> > make dtbs_check:
> >
> >     arch/arm64/boot/dts/renesas/r8a77951-salvator-xs.dtb: regulator-vccq-sdhi0: Unevaluated properties are not allowed ('gpios-states', 'states' were unexpected)
> >           from schema $id: http://devicetree.org/schemas/regulator/gpio-regulator.yaml#
> >
> > The number of items in "gpios-states" must match the number of items in
> > "gpios", so their limits should be identical.
> >
> > The number of items in "states" must lie within the range from zero up
> > to 2^{number of gpios}.
> >
> > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> > ---
> > The second issue did not cause any dtbs_check errors?
> > ---
> >  .../devicetree/bindings/regulator/gpio-regulator.yaml         | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> >
>
> My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check'
> on your patch (DT_CHECKER_FLAGS is new in v5.13):
>
> yamllint warnings/errors:
>
> dtschema/dtc warnings/errors:
> /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/regulator/gpio-regulator.yaml: properties:states:minItems: 0 is less than the minimum of 1
>         hint: An array property has at least 1 item or is not present
>         from schema $id: http://devicetree.org/meta-schemas/keywords.yaml#

Oops, I changed this from 1 to 0 _after_ running dt_binding_check, so
I'm totally to blame for this.

The description says:

    If there are no states in the "states" array, use a fixed regulator instead.

which I misinterpreted as "states can be empty", especially as the
driver does seem to support that?

I guess 1 is the proper minimum?

Gr{oetje,eeting}s,

                        Geert
Rob Herring (Arm) Feb. 1, 2024, 8:27 p.m. UTC | #3
On Thu, Feb 1, 2024 at 2:06 PM Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>
> Hi Rob The Robot ;-)

:)

> On Thu, Feb 1, 2024 at 6:31 PM Rob Herring <robh@kernel.org> wrote:
> > On Thu, 01 Feb 2024 16:58:41 +0100, Geert Uytterhoeven wrote:
> > > make dtbs_check:
> > >
> > >     arch/arm64/boot/dts/renesas/r8a77951-salvator-xs.dtb: regulator-vccq-sdhi0: Unevaluated properties are not allowed ('gpios-states', 'states' were unexpected)
> > >           from schema $id: http://devicetree.org/schemas/regulator/gpio-regulator.yaml#
> > >
> > > The number of items in "gpios-states" must match the number of items in
> > > "gpios", so their limits should be identical.
> > >
> > > The number of items in "states" must lie within the range from zero up
> > > to 2^{number of gpios}.
> > >
> > > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> > > ---
> > > The second issue did not cause any dtbs_check errors?
> > > ---
> > >  .../devicetree/bindings/regulator/gpio-regulator.yaml         | 4 +++-
> > >  1 file changed, 3 insertions(+), 1 deletion(-)
> > >
> >
> > My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check'
> > on your patch (DT_CHECKER_FLAGS is new in v5.13):
> >
> > yamllint warnings/errors:
> >
> > dtschema/dtc warnings/errors:
> > /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/regulator/gpio-regulator.yaml: properties:states:minItems: 0 is less than the minimum of 1
> >         hint: An array property has at least 1 item or is not present
> >         from schema $id: http://devicetree.org/meta-schemas/keywords.yaml#
>
> Oops, I changed this from 1 to 0 _after_ running dt_binding_check, so
> I'm totally to blame for this.
>
> The description says:
>
>     If there are no states in the "states" array, use a fixed regulator instead.
>
> which I misinterpreted as "states can be empty", especially as the
> driver does seem to support that?
>
> I guess 1 is the proper minimum?

Yes. While JSON can for example have "foo: []", that's not really
defined for DT given we store no type info. An empty property is a
boolean.

Rob
Rob Herring (Arm) Feb. 1, 2024, 10:11 p.m. UTC | #4
On Thu, Feb 01, 2024 at 04:58:41PM +0100, Geert Uytterhoeven wrote:
> make dtbs_check:
> 
>     arch/arm64/boot/dts/renesas/r8a77951-salvator-xs.dtb: regulator-vccq-sdhi0: Unevaluated properties are not allowed ('gpios-states', 'states' were unexpected)
> 	    from schema $id: http://devicetree.org/schemas/regulator/gpio-regulator.yaml#

Unevaluated properties warning here is not interesting. If a property 
fails validation, then it is considered unevaluated. It's that warning 
which is interesting:

arch/arm64/boot/dts/renesas/r8a77951-salvator-xs.dtb: regulator-vccq-sdhi0: gpios-states:0: [1] is too short
        from schema $id: http://devicetree.org/schemas/regulator/gpio-regulator.yaml#

> 
> The number of items in "gpios-states" must match the number of items in
> "gpios", so their limits should be identical.
> 
> The number of items in "states" must lie within the range from zero up
> to 2^{number of gpios}.
> 
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> The second issue did not cause any dtbs_check errors?

I'm not seeing 'states' fail, but it looks like you did? Is that the 
issue you mean? Looks like in the matrix case, we're now setting 
minItems if unspecified.

> ---
>  .../devicetree/bindings/regulator/gpio-regulator.yaml         | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/regulator/gpio-regulator.yaml b/Documentation/devicetree/bindings/regulator/gpio-regulator.yaml
> index f4c1f36e52e9c3d8..1cecf8faee5dc374 100644
> --- a/Documentation/devicetree/bindings/regulator/gpio-regulator.yaml
> +++ b/Documentation/devicetree/bindings/regulator/gpio-regulator.yaml
> @@ -47,6 +47,7 @@ properties:
>          1: HIGH
>        Default is LOW if nothing else is specified.
>      $ref: /schemas/types.yaml#/definitions/uint32-array
> +    minItems: 1
>      maxItems: 8
>      items:
>        enum: [0, 1]
> @@ -57,7 +58,8 @@ properties:
>        regulator and matching GPIO configurations to achieve them. If there are
>        no states in the "states" array, use a fixed regulator instead.
>      $ref: /schemas/types.yaml#/definitions/uint32-matrix
> -    maxItems: 8
> +    minItems: 0
> +    maxItems: 256
>      items:
>        items:
>          - description: Voltage in microvolts
> -- 
> 2.34.1
>
Geert Uytterhoeven Feb. 2, 2024, 8:11 a.m. UTC | #5
Hi Rob,

On Thu, Feb 1, 2024 at 11:11 PM Rob Herring <robh@kernel.org> wrote:
> On Thu, Feb 01, 2024 at 04:58:41PM +0100, Geert Uytterhoeven wrote:
> > make dtbs_check:
> >
> >     arch/arm64/boot/dts/renesas/r8a77951-salvator-xs.dtb: regulator-vccq-sdhi0: Unevaluated properties are not allowed ('gpios-states', 'states' were unexpected)
> >           from schema $id: http://devicetree.org/schemas/regulator/gpio-regulator.yaml#
>
> Unevaluated properties warning here is not interesting. If a property
> fails validation, then it is considered unevaluated. It's that warning
> which is interesting:
>
> arch/arm64/boot/dts/renesas/r8a77951-salvator-xs.dtb: regulator-vccq-sdhi0: gpios-states:0: [1] is too short
>         from schema $id: http://devicetree.org/schemas/regulator/gpio-regulator.yaml#

Oops (again, I'm afraid my mind is already living at FOSDEM ;-),
I copy-'n-pasted the wrong message...

> > The number of items in "gpios-states" must match the number of items in
> > "gpios", so their limits should be identical.
> >
> > The number of items in "states" must lie within the range from zero up
> > to 2^{number of gpios}.
> >
> > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> > ---
> > The second issue did not cause any dtbs_check errors?
>
> I'm not seeing 'states' fail, but it looks like you did? Is that the
> issue you mean? Looks like in the matrix case, we're now setting
> minItems if unspecified.

No, I did not see states fail, only gpios-states.
Hence "the second issue did not cause errors".

Gr{oetje,eeting}s,

                        Geert
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/regulator/gpio-regulator.yaml b/Documentation/devicetree/bindings/regulator/gpio-regulator.yaml
index f4c1f36e52e9c3d8..1cecf8faee5dc374 100644
--- a/Documentation/devicetree/bindings/regulator/gpio-regulator.yaml
+++ b/Documentation/devicetree/bindings/regulator/gpio-regulator.yaml
@@ -47,6 +47,7 @@  properties:
         1: HIGH
       Default is LOW if nothing else is specified.
     $ref: /schemas/types.yaml#/definitions/uint32-array
+    minItems: 1
     maxItems: 8
     items:
       enum: [0, 1]
@@ -57,7 +58,8 @@  properties:
       regulator and matching GPIO configurations to achieve them. If there are
       no states in the "states" array, use a fixed regulator instead.
     $ref: /schemas/types.yaml#/definitions/uint32-matrix
-    maxItems: 8
+    minItems: 0
+    maxItems: 256
     items:
       items:
         - description: Voltage in microvolts