Re: [PATCH] dt-bindings: Improve phandle-array schemas

From
Rob Herring <robh@kernel.org>
Date
2022-01-19 15:29:23
Also in
alsa-devel, dmaengine, dri-devel, linux-can, linux-crypto, linux-devicetree, linux-gpio, linux-ide, linux-iommu, linux-leds, linux-media, linux-phy, linux-pm, linux-remoteproc, linux-riscv, linux-usb, linux-wireless, lkml
Reply to
Vladimir Oltean, 2022-01-19
On Wed, Jan 19, 2022 at 4:35 AM Vladimir Oltean [off-list ref] wrote:
On Tue, Jan 18, 2022 at 07:50:38PM -0600, Rob Herring wrote:
quoted
The 'phandle-array' type is a bit ambiguous. It can be either just an
array of phandles or an array of phandles plus args. Many schemas for
phandle-array properties aren't clear in the schema which case applies
though the description usually describes it.

The array of phandles case boils down to needing:

items:
  maxItems: 1

The phandle plus args cases should typically take this form:

items:
  - items:
      - description: A phandle
      - description: 1st arg cell
      - description: 2nd arg cell

With this change, some examples need updating so that the bracketing of
property values matches the schema.
---
(...)
quoted
diff --git a/Documentation/devicetree/bindings/net/dsa/dsa-port.yaml b/Documentation/devicetree/bindings/net/dsa/dsa-port.yaml
index 702df848a71d..c504feeec6db 100644
--- a/Documentation/devicetree/bindings/net/dsa/dsa-port.yaml
+++ b/Documentation/devicetree/bindings/net/dsa/dsa-port.yaml
@@ -34,6 +34,8 @@ properties:
       full routing information must be given, not just the one hop
       routes to neighbouring switches
     $ref: /schemas/types.yaml#/definitions/phandle-array
+    items:
+      maxItems: 1

   ethernet:
     description:
For better or worse, the mainline cases of this property all take the
form of:

arch/arm64/boot/dts/marvell/armada-3720-turris-mox.dts
                                link = <&switch1port9 &switch2port9>;
                                link = <&switch1port10 &switch0port10>;
arch/arm/boot/dts/vf610-zii-dev-rev-b.dts
                                                link = <&switch1port6
                                                        &switch2port9>;
                                                link = <&switch1port5
                                                        &switch0port5>;
arch/arm/boot/dts/vf610-zii-scu4-aib.dts
                                                link = <&switch1port10
                                                        &switch3port10
                                                        &switch2port10>;
                                                link = <&switch3port10
                                                        &switch2port10>;
                                                link = <&switch1port9
                                                        &switch0port10>;

So not really an array of phandles.
Either form is an array. The DT yaml encoding maintains the
bracketing, so how the schema is defined matters. To some extent the
tools will process the schema to support both forms of bracketing, but
this has turned out to be fragile and just doesn't work for phandle
arrays. I'm working on further changes that will get rid of the yaml
encoded DT format and validate DTB files directly. These obviously
have no bracketing and needing the DTS source files to change goes
away. However, to be able to construct the internal format for
validation, I do need the schemas to have more information on what
exactly the phandle-array contains.

Rob
Thread (14 messages) 14 messages, 12 authors, last reply 2022-01-20
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help