Skip to content

Commit

Permalink
schemas: Enforce simple-bus child nodes unit-addresses
Browse files Browse the repository at this point in the history
The current simple-bus child node schema checks nodes matching a correct
unit-address (plus uppercase), but don't check for incorrect unit-addresses
(though dtc will). Rework the schema such that all child nodes must have
a unit-address and the unit-address format is correct.

Really, additional DT properties shouldn't be allowed at all, but there's
already too many cases of extra properties.

Signed-off-by: Rob Herring <robh@kernel.org>
  • Loading branch information
robherring committed Feb 8, 2021
1 parent 1e15328 commit f754e83
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions schemas/simple-bus.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# SPDX-License-Identifier: BSD-2-Clause
# Copyright 2018 Linaro Ltd.
# Copyright 2021 Arm Ltd.
%YAML 1.2
---
$id: http://devicetree.org/schemas/simple-bus.yaml#
Expand All @@ -19,14 +20,15 @@ properties:
contains:
const: simple-bus
ranges: true
dma-ranges: true
"#address-cells":
enum: [ 1, 2 ]
"#size-cells":
enum: [ 1, 2 ]

patternProperties:
# All other properties should be child nodes with unit-address and 'reg'
"^[a-zA-Z][a-zA-Z0-9,+\\-._]{0,63}@[0-9a-fA-F]+$":
"@(0|[1-9a-f][0-9a-f]*)$":
type: object
properties:
reg:
Expand All @@ -49,7 +51,12 @@ patternProperties:
- required:
- ranges

additionalProperties: true
"^[^@]+$":
# Only additional properties should be properties, not nodes.
not:
type: object

additionalProperties: false

required:
- compatible
Expand Down

0 comments on commit f754e83

Please sign in to comment.