Re: [PATCH RFC] dt-bindings: mfd: ams,as3711: Convert to json-schema

From: Rob Herring
Date: Tue Oct 24 2023 - 16:58:34 EST


On Mon, Oct 23, 2023 at 08:38:07PM +0200, Geert Uytterhoeven wrote:
> Convert the Austria MicroSystems AS3711 Quad Buck High Current PMIC with
> Charger Device Tree binding documentation to json-schema.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@xxxxxxxxx>
> ---
> RFC, as I couldn't get the multiple dependencies right (see FIXMEs):
> 1. How to incorporate "su2-dev: [ su2-max-uA ]" and
> "su2-feedback-curr-auto: [ su2-dev ]"?
> 2. su2-dev requiring one of su2-fbprot-* does not seem to work?
>
> Anyone with better *Of foo? Thanks!
> ---
> .../devicetree/bindings/mfd/ams,as3711.yaml | 223 ++++++++++++++++++
> .../devicetree/bindings/mfd/as3711.txt | 73 ------
> 2 files changed, 223 insertions(+), 73 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/mfd/ams,as3711.yaml
> delete mode 100644 Documentation/devicetree/bindings/mfd/as3711.txt


> + dependencies:
> + # To use the SU1 converter as a backlight source the following two
> + # properties must be provided:
> + su1-dev: [ su1-max-uA ]
> + su1-max-uA: [ su1-dev ]
> +
> + # To use the SU2 converter as a backlight source the following two
> + # properties must be provided:
> + # FIXME How to incorporate "su2-dev: [ su2-max-uA ]"?

You've stumbled into the evolution of jsonschema. Newer versions split
'dependencies' into 'dependentSchemas' and 'dependentRequired' (more
generally, they split keywords that could be either a list or schema).
That will let you have both forms. The new keywords are already
supported and you can use them (internally, dtschema is converting
every 'dependencies' to the new forms because json-schema likes flag
days, sigh).


> + # FIXME su2-dev requiring one of su2-fbprot-* does not seem to work?
> + su2-dev:
> + allOf:
> + - oneOf:
> + - required:
> + - su2-feedback-voltage
> + - required:
> + - su2-feedback-curr1
> + - required:
> + - su2-feedback-curr2
> + - required:
> + - su2-feedback-curr3
> + - required:
> + - su2-feedback-curr-auto
> + - oneof:

Your second problem is here.

s/oneof/oneOf/

Got to love json-schema's default silence on unknown keywords. I'll
figure out why we don't descend here and find this.

> + - required:
> + - su2-fbprot-lx-sd4
> + - required:
> + - su2-fbprot-gpio2
> + - required:
> + - su2-fbprot-gpio3
> + - required:
> + - su2-fbprot-gpio4