From d4edb088acd02b904c193d9199229dbc3ad25b97 Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Wed, 18 Nov 2020 11:40:20 -0600 Subject: [PATCH] schemas: Improve graph schema to allow extending The initial graph schema is not flexible enough to handle cases with additional properties in endpoint nodes. The problem is a $ref plus 'unevaluatedProperties: false' only works on immediate properties and doesn't work for child properties in an endpoint schema. So endpoint nodes must have their own $ref. Rework the to add base definitions 'port-base' and 'endpoint-base' which can be used by graph users to extend the schema. For users without additional properties, they can reference '/properties/port' and 'properties/endpoint'. Signed-off-by: Rob Herring --- schemas/graph.yaml | 57 +++++++++++++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 18 deletions(-) diff --git a/schemas/graph.yaml b/schemas/graph.yaml index b1e8519b..617bdc57 100644 --- a/schemas/graph.yaml +++ b/schemas/graph.yaml @@ -33,8 +33,19 @@ maintainers: select: false -properties: - port: +$defs: + endpoint-base: + type: object + properties: + reg: + maxItems: 1 + + remote-endpoint: + description: | + phandle to an 'endpoint' subnode of a remote device node. + $ref: /schemas/types.yaml#/definitions/phandle + + port-base: type: object description: If there is more than one endpoint node or 'reg' property present in @@ -48,17 +59,30 @@ properties: "#size-cells": const: 0 - patternProperties: - "^endpoint(@[0-9a-f]+)?$": + reg: + maxItems: 1 + + endpoint: type: object - properties: - reg: - maxItems: 1 - remote-endpoint: - description: | - phandle to an 'endpoint' subnode of a remote device node. - $ref: /schemas/types.yaml#/definitions/phandle + patternProperties: + "^endpoint@[0-9a-f]+$": + $ref: "#/$defs/endpoint-base" + required: + - reg + +properties: + endpoint: + $ref: "#/$defs/endpoint-base" + unevaluatedProperties: false + + port: + $ref: "#/$defs/port-base" + unevaluatedProperties: false + + patternProperties: + "^endpoint(@[0-9a-f]+)?$": + $ref: "#/properties/endpoint" ports: type: object @@ -75,15 +99,12 @@ properties: "#size-cells": const: 0 - patternProperties: - "^port(@[0-9a-f]+)?$": - $ref: "#/properties/port" + port: type: object - properties: - reg: - maxItems: 1 - + patternProperties: + "^port@[0-9a-f]+$": + type: object required: - reg