Thread (16 messages) 16 messages, 11 authors, 2021-02-06

Re: [PATCH 3/3] dt-bindings: Fix errors in 'if' schemas

From: Geert Uytterhoeven <geert@linux-m68k.org>
Date: 2021-02-03 16:04:37
Also in: dri-devel, linux-clk, linux-devicetree, linux-gpio, linux-i2c, linux-iommu, linux-leds, linux-mmc, linux-watchdog, lkml

Hi Rob,

On Wed, Feb 3, 2021 at 4:55 PM Rob Herring [off-list ref] wrote:
On Wed, Feb 03, 2021 at 09:01:23AM +0100, Geert Uytterhoeven wrote:
quoted
On Tue, Feb 2, 2021 at 9:55 PM Rob Herring [off-list ref] wrote:
quoted
Properties in if/then schemas weren't getting checked by the meta-schemas.
Enabling meta-schema checks finds several errors.

The use of an 'items' schema (as opposed to the list form) is wrong in
some cases as it applies to all entries. 'contains' is the correct schema
to use in the case of multiple entries.
quoted
Signed-off-by: Rob Herring <robh@kernel.org>
Thanks for your patch!
quoted
--- a/Documentation/devicetree/bindings/phy/renesas,usb2-phy.yaml
+++ b/Documentation/devicetree/bindings/phy/renesas,usb2-phy.yaml
@@ -81,9 +81,8 @@ properties:
 if:
   properties:
     compatible:
-      items:
-        enum:
-          - renesas,usb2-phy-r7s9210
+      contains:
+        const: renesas,usb2-phy-r7s9210
Single entry, so "contains" not needed?
No, you are misunderstanding how these work. 'contains' means at least
one entry in an array passes with the subschema. In this case,
'renesas,usb2-phy-r7s9210' must appear somewhere in the 'compatible'
values. (Before, it said *every* entry must be
'renesas,usb2-phy-r7s9210'.) As there is a fallback compatible, we need
'contains'.
quoted
quoted
--- a/Documentation/devicetree/bindings/pinctrl/renesas,pfc.yaml
+++ b/Documentation/devicetree/bindings/pinctrl/renesas,pfc.yaml
@@ -76,11 +76,10 @@ required:
 if:
   properties:
     compatible:
-      items:
-        enum:
-          - renesas,pfc-r8a73a4
-          - renesas,pfc-r8a7740
-          - renesas,pfc-sh73a0
+      enum:
+        - renesas,pfc-r8a73a4
+        - renesas,pfc-r8a7740
+        - renesas,pfc-sh73a0
Missing "contains"?
No. In this case, 'compatible' is always a single entry, so no
'contains' needed (but would work). If compatible is one of these 3
strings, then the 'if' is true.

The original way would actually work in this case (i.e. is valid
json-schema), but we require 'items' to have a size (maxItems/minItems)
in our meta-schema.
Thanks for the explanation!
Acked-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help