Re: [RFC PATCH] dt-bindings: regulator: twl-regulator: convert to yaml

From: Andreas Kemnade
Date: Tue May 28 2024 - 12:56:02 EST


On Tue, 28 May 2024 16:53:46 +0100
Conor Dooley <conor@xxxxxxxxxx> wrote:

> On Tue, May 28, 2024 at 05:48:49PM +0200, Andreas Kemnade wrote:
> > On Tue, 28 May 2024 15:36:40 +0100
> > Conor Dooley <conor@xxxxxxxxxx> wrote:
> >
> > > On Tue, May 28, 2024 at 03:54:05PM +0200, Krzysztof Kozlowski wrote:
> > > > On 28/05/2024 15:06, Andreas Kemnade wrote:
> > > > > On Tue, 28 May 2024 13:25:29 +0200
> > > > > Krzysztof Kozlowski <krzk@xxxxxxxxxx> wrote:
> > > > >
> > > > >> On 28/05/2024 13:16, Andreas Kemnade wrote:
> > > > >>> On Tue, 28 May 2024 12:04:22 +0200
> > > > >>> Krzysztof Kozlowski <krzk@xxxxxxxxxx> wrote:
> > > > >>>
> > > > >>>> On 28/05/2024 08:57, Andreas Kemnade wrote:
> > > > >>>>> Convert the regulator bindings to yaml files. To allow only the regulator
> > > > >>>>> compatible corresponding to the toplevel mfd compatible, split the file
> > > > >>>>> into one per device.
> > > > >>>>>
> > > > >>>>> To not need to allow any subnode name, specify clearly node names
> > > > >>>>> for all the regulators.
> > > > >>>>>
> > > > >>>>> Drop one twl5030 compatible due to no documentation on mfd side and no
> > > > >>>>> users of the twl5030.
> > > > >>>>>
> > > > >>>>> Signed-off-by: Andreas Kemnade <andreas@xxxxxxxxxxxx>
> > > > >>>>> ---
> > > > >>>>> Reason for being RFC:
> > > > >>>>> the integration into ti,twl.yaml seems not to work as expected
> > > > >>>>> make dt_binding_check crashes without any clear error message
> > > > >>>>> if used on the ti,twl.yaml
> > > > >>>>>
> > > > >>>>> .../devicetree/bindings/mfd/ti,twl.yaml | 4 +-
> > > > >>>>> .../regulator/ti,twl4030-regulator.yaml | 402 ++++++++++++++++++
> > > > >>>>> .../regulator/ti,twl6030-regulator.yaml | 292 +++++++++++++
> > > > >>>>> .../regulator/ti,twl6032-regulator.yaml | 238 +++++++++++
> > > > >>>>> .../bindings/regulator/twl-regulator.txt | 80 ----
> > > > >>>>> 5 files changed, 935 insertions(+), 81 deletions(-)
> > > > >>>>> create mode 100644 Documentation/devicetree/bindings/regulator/ti,twl4030-regulator.yaml
> > > > >>>>> create mode 100644 Documentation/devicetree/bindings/regulator/ti,twl6030-regulator.yaml
> > > > >>>>> create mode 100644 Documentation/devicetree/bindings/regulator/ti,twl6032-regulator.yaml
> > > > >>>>> delete mode 100644 Documentation/devicetree/bindings/regulator/twl-regulator.txt
> > > > >>>>>
> > > > >>>>> diff --git a/Documentation/devicetree/bindings/mfd/ti,twl.yaml b/Documentation/devicetree/bindings/mfd/ti,twl.yaml
> > > > >>>>> index c2357fecb56cc..4ced6e471d338 100644
> > > > >>>>> --- a/Documentation/devicetree/bindings/mfd/ti,twl.yaml
> > > > >>>>> +++ b/Documentation/devicetree/bindings/mfd/ti,twl.yaml
> > > > >>>>> @@ -50,7 +50,7 @@ allOf:
> > > > >>>>> properties:
> > > > >>>>> compatible:
> > > > >>>>> const: ti,twl4030-wdt
> > > > >>>>> -
> > > > >>>>> + $ref: /schemas/regulator/ti,twl4030-regulator.yaml
> > > > >>>>
> > > > >>>> That's not needed, just like othehr refs below.
> > > > >>>>
> > > > >>> but how to prevent error messages like this:
> > > > >>>
> > > > >>> arch/arm/boot/dts/ti/omap/omap2430-sdp.dtb: twl@48: Unevaluated properties are not allowed ('gpio', 'keypad', 'pwm', 'pwmled', 'regulator-vaux1', 'regulator-vaux2', 'regulator-vaux3', 'regulator-vaux4', 'regulator-vdac', 'regulator-vdd1', 'regulator-vintana1', 'regulator-vintana2', 'regulator-vintdig', 'regulator-vio', 'regulator-vmmc1', 'regulator-vmmc2', 'regulator-vpll1', 'regulator-vpll2', 'regulator-vsim', 'regulator-vusb1v5', 'regulator-vusb1v8', 'regulator-vusb3v1
> > > > >>>
> > > > >>> esp. the regulator parts without adding stuff to ti,twl.yaml?
> > > > >>
> > > > >> Eh? That's a watchdog, not regulator. Why do you add ref to regulator?
> > > > >>
> > > > > hmm, wrongly indented? At what level doet it belong? But as the regualor.yaml stuff can
> > > > > be shortened, maybe just add it directly to ti,twl.yaml to avoid that trouble.
> > > >
> > > > I don't follow. The diff here and in other two places suggest you add
> > > > twl-regulator reference to wdt/gpio/whatnot nodes, not to regulators.
> > >
> > > The diff may look like that, but I think they're just trying to add it
> > > as a subnode of the pmic. There are other nodes, like the madc that do
> > > this in the same file:
> > > madc:
> > > type: object
> > > $ref: /schemas/iio/adc/ti,twl4030-madc.yaml
> > > unevaluatedProperties: false
> > >
> > > I guess this is what was being attempted, albeit incorrectly.
> >
> > correct. No regulators node, just everything directly as a subnode of
> > the pmic. Well, I have now something using patternProperties directly itn ti,twl.yaml
> > including a more detailed example which does not upset dt_binding_check.
> > I am running dtbs_check to check if anything is odd. the 4030 variant seems
> > to be ok, waiting for some dtbs containing 603X now.
> >
> > But somehow I would feel better if I would understand what was syntactically
> > wrong with my original proposal. I have totally no idea yet.
>
> If you want to create a child node, you can't just reference another
> schema willy nilly. You need to create a property of type object, as was
> done elsewhere in the file.
>
hmm, by $ref regulator.yaml I can successfully create the child node
regulator-state-mem, so what is the difference to creating e.g. a child
node named regulator-vaux1 by $ref ti,twl4030-regulator.yaml

still a bit confused.

> > The error message of dt_binding_check is also meaningless:
> > CHKDT Documentation/devicetree/bindings
> > Traceback (most recent call last):
> > File "/home/andi/.local/bin/dt-doc-validate", line 64, in <module>
> > ret |= check_doc(f)
> > ^^^^^^^^^^^^
> > File "/home/andi/.local/bin/dt-doc-validate", line 32, in check_doc
> > for error in sorted(dtsch.iter_errors(), key=lambda e: e.linecol):
> > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > File "/home/andi/.local/pipx/venvs/dtschema/lib/python3.11/site-packages/dtschema/schema.py", line 125, in iter_errors
> > self.annotate_error(scherr, meta_schema, scherr.schema_path)
> > File "/home/andi/.local/pipx/venvs/dtschema/lib/python3.11/site-packages/dtschema/schema.py", line 104, in annotate_error
> > schema = schema[p]
> > ~~~~~~^^^
> > KeyError: 'type'
> > LINT Documentation/devicetree/bindings
> >
> > IMHO this should be improved.
>
> What I see with your patch applied is:
> /stuff/linux-dt/Documentation/devicetree/bindings/mfd/ti,twl.yaml: ignoring, error in schema: allOf: 0: then: properties: $ref
>
> Not a great error either, but not a crash like you see. What version of
> dt-schema are you using?

2023.9
ok, but there is 2024.4... Upgraded and got your error

Regards,
Andreas