[PATCH 07/10] dt-bindings: mtd: Ensure partition node properties are documented

Rob Herring (Arm) posted 10 patches 1 month ago
There is a newer version of this series
[PATCH 07/10] dt-bindings: mtd: Ensure partition node properties are documented
Posted by Rob Herring (Arm) 1 month ago
Partition nodes without a compatible have no restrictions on additional
properties. Fix this by ensuring 'unevaluatedProperties' is set when
there's no compatible property. If there is a compatible property, then
there should be a specific schema for it which will enforce
'unevaluatedProperties'.

Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
---
 Documentation/devicetree/bindings/mtd/mtd.yaml               |  8 ++------
 .../devicetree/bindings/mtd/partitions/fixed-partitions.yaml |  2 +-
 .../devicetree/bindings/mtd/partitions/partition.yaml        | 12 ++++++++++++
 .../mtd/partitions/tplink,safeloader-partitions.yaml         |  2 +-
 Documentation/devicetree/bindings/mtd/partitions/u-boot.yaml |  2 +-
 Documentation/devicetree/bindings/mtd/ti,gpmc-onenand.yaml   |  2 +-
 6 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/Documentation/devicetree/bindings/mtd/mtd.yaml b/Documentation/devicetree/bindings/mtd/mtd.yaml
index e56dba83f00a..5a2d06c96c0d 100644
--- a/Documentation/devicetree/bindings/mtd/mtd.yaml
+++ b/Documentation/devicetree/bindings/mtd/mtd.yaml
@@ -36,12 +36,8 @@ properties:
       - compatible
 
 patternProperties:
-  "@[0-9a-f]+$":
-    $ref: partitions/partition.yaml
-    deprecated: true
-
-  "^partition@[0-9a-f]+":
-    $ref: partitions/partition.yaml
+  "(^partition)?@[0-9a-f]+$":
+    $ref: /schemas/mtd/partitions/partition.yaml#/$defs/partition-node
     deprecated: true
 
   "^otp(-[0-9]+)?$":
diff --git a/Documentation/devicetree/bindings/mtd/partitions/fixed-partitions.yaml b/Documentation/devicetree/bindings/mtd/partitions/fixed-partitions.yaml
index 26bef777353d..4d79f786fcd5 100644
--- a/Documentation/devicetree/bindings/mtd/partitions/fixed-partitions.yaml
+++ b/Documentation/devicetree/bindings/mtd/partitions/fixed-partitions.yaml
@@ -33,7 +33,7 @@ properties:
 
 patternProperties:
   "@[0-9a-f]+$":
-    $ref: partition.yaml#
+    $ref: partition.yaml#/$defs/partition-node
 
 required:
   - "#address-cells"
diff --git a/Documentation/devicetree/bindings/mtd/partitions/partition.yaml b/Documentation/devicetree/bindings/mtd/partitions/partition.yaml
index fe2f7d622e8b..51fd48af55ec 100644
--- a/Documentation/devicetree/bindings/mtd/partitions/partition.yaml
+++ b/Documentation/devicetree/bindings/mtd/partitions/partition.yaml
@@ -149,6 +149,18 @@ then:
 # This is a generic file other binding inherit from and extend
 additionalProperties: true
 
+$defs:
+  partition-node:
+    type: object
+    if:
+      not:
+        required: [ compatible ]
+    then:
+      $ref: '#'
+      unevaluatedProperties: false
+    else:
+      $ref: '#'
+
 examples:
   - |
     partitions {
diff --git a/Documentation/devicetree/bindings/mtd/partitions/tplink,safeloader-partitions.yaml b/Documentation/devicetree/bindings/mtd/partitions/tplink,safeloader-partitions.yaml
index a24bbaac3a90..40e6eaab03ce 100644
--- a/Documentation/devicetree/bindings/mtd/partitions/tplink,safeloader-partitions.yaml
+++ b/Documentation/devicetree/bindings/mtd/partitions/tplink,safeloader-partitions.yaml
@@ -38,7 +38,7 @@ properties:
 
 patternProperties:
   "^partition-.*$":
-    $ref: partition.yaml#
+    $ref: partition.yaml#/$defs/partition-node
 
 required:
   - partitions-table-offset
diff --git a/Documentation/devicetree/bindings/mtd/partitions/u-boot.yaml b/Documentation/devicetree/bindings/mtd/partitions/u-boot.yaml
index 327fa872c001..d51bdcb7e585 100644
--- a/Documentation/devicetree/bindings/mtd/partitions/u-boot.yaml
+++ b/Documentation/devicetree/bindings/mtd/partitions/u-boot.yaml
@@ -29,7 +29,7 @@ properties:
 
 patternProperties:
   "^partition-.*$":
-    $ref: partition.yaml#
+    $ref: partition.yaml#/$defs/partition-node
 
 unevaluatedProperties: false
 
diff --git a/Documentation/devicetree/bindings/mtd/ti,gpmc-onenand.yaml b/Documentation/devicetree/bindings/mtd/ti,gpmc-onenand.yaml
index 7d3ace4f5505..8db991dee7eb 100644
--- a/Documentation/devicetree/bindings/mtd/ti,gpmc-onenand.yaml
+++ b/Documentation/devicetree/bindings/mtd/ti,gpmc-onenand.yaml
@@ -36,7 +36,7 @@ properties:
 
 patternProperties:
   "@[0-9a-f]+$":
-    $ref: /schemas/mtd/partitions/partition.yaml
+    $ref: /schemas/mtd/partitions/partition.yaml#/$defs/partition-node
 
 allOf:
   - $ref: /schemas/memory-controllers/ti,gpmc-child.yaml

-- 
2.51.0
Re: [PATCH 07/10] dt-bindings: mtd: Ensure partition node properties are documented
Posted by Krzysztof Kozlowski 1 month ago
On Thu, Jan 08, 2026 at 11:53:16AM -0600, Rob Herring (Arm) wrote:
> Partition nodes without a compatible have no restrictions on additional
> properties. Fix this by ensuring 'unevaluatedProperties' is set when
> there's no compatible property. If there is a compatible property, then
> there should be a specific schema for it which will enforce
> 'unevaluatedProperties'.
> 
> Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
> ---
>  Documentation/devicetree/bindings/mtd/mtd.yaml               |  8 ++------
>  .../devicetree/bindings/mtd/partitions/fixed-partitions.yaml |  2 +-
>  .../devicetree/bindings/mtd/partitions/partition.yaml        | 12 ++++++++++++
>  .../mtd/partitions/tplink,safeloader-partitions.yaml         |  2 +-
>  Documentation/devicetree/bindings/mtd/partitions/u-boot.yaml |  2 +-
>  Documentation/devicetree/bindings/mtd/ti,gpmc-onenand.yaml   |  2 +-
>  6 files changed, 18 insertions(+), 10 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/mtd/mtd.yaml b/Documentation/devicetree/bindings/mtd/mtd.yaml
> index e56dba83f00a..5a2d06c96c0d 100644
> --- a/Documentation/devicetree/bindings/mtd/mtd.yaml
> +++ b/Documentation/devicetree/bindings/mtd/mtd.yaml
> @@ -36,12 +36,8 @@ properties:
>        - compatible
>  
>  patternProperties:
> -  "@[0-9a-f]+$":
> -    $ref: partitions/partition.yaml
> -    deprecated: true
> -
> -  "^partition@[0-9a-f]+":
> -    $ref: partitions/partition.yaml
> +  "(^partition)?@[0-9a-f]+$":
> +    $ref: /schemas/mtd/partitions/partition.yaml#/$defs/partition-node
>      deprecated: true

This makes partition@ deprecated. Looks unintended or needds commit msg
explanation.

>  
>    "^otp(-[0-9]+)?$":
> diff --git a/Documentation/devicetree/bindings/mtd/partitions/fixed-partitions.yaml b/Documentation/devicetree/bindings/mtd/partitions/fixed-partitions.yaml
> index 26bef777353d..4d79f786fcd5 100644
> --- a/Documentation/devicetree/bindings/mtd/partitions/fixed-partitions.yaml
> +++ b/Documentation/devicetree/bindings/mtd/partitions/fixed-partitions.yaml
> @@ -33,7 +33,7 @@ properties:

Best regards,
Krzysztof
Re: [PATCH 07/10] dt-bindings: mtd: Ensure partition node properties are documented
Posted by Rob Herring 1 month ago
On Fri, Jan 9, 2026 at 3:36 AM Krzysztof Kozlowski <krzk@kernel.org> wrote:
>
> On Thu, Jan 08, 2026 at 11:53:16AM -0600, Rob Herring (Arm) wrote:
> > Partition nodes without a compatible have no restrictions on additional
> > properties. Fix this by ensuring 'unevaluatedProperties' is set when
> > there's no compatible property. If there is a compatible property, then
> > there should be a specific schema for it which will enforce
> > 'unevaluatedProperties'.
> >
> > Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
> > ---
> >  Documentation/devicetree/bindings/mtd/mtd.yaml               |  8 ++------
> >  .../devicetree/bindings/mtd/partitions/fixed-partitions.yaml |  2 +-
> >  .../devicetree/bindings/mtd/partitions/partition.yaml        | 12 ++++++++++++
> >  .../mtd/partitions/tplink,safeloader-partitions.yaml         |  2 +-
> >  Documentation/devicetree/bindings/mtd/partitions/u-boot.yaml |  2 +-
> >  Documentation/devicetree/bindings/mtd/ti,gpmc-onenand.yaml   |  2 +-
> >  6 files changed, 18 insertions(+), 10 deletions(-)
> >
> > diff --git a/Documentation/devicetree/bindings/mtd/mtd.yaml b/Documentation/devicetree/bindings/mtd/mtd.yaml
> > index e56dba83f00a..5a2d06c96c0d 100644
> > --- a/Documentation/devicetree/bindings/mtd/mtd.yaml
> > +++ b/Documentation/devicetree/bindings/mtd/mtd.yaml
> > @@ -36,12 +36,8 @@ properties:
> >        - compatible
> >
> >  patternProperties:
> > -  "@[0-9a-f]+$":
> > -    $ref: partitions/partition.yaml
> > -    deprecated: true
> > -
> > -  "^partition@[0-9a-f]+":
> > -    $ref: partitions/partition.yaml
> > +  "(^partition)?@[0-9a-f]+$":
> > +    $ref: /schemas/mtd/partitions/partition.yaml#/$defs/partition-node
> >      deprecated: true
>
> This makes partition@ deprecated. Looks unintended or needds commit msg
> explanation.

No, the only change here is I combined the entries. "partition@" is
deprecated when not under "partitions" node.

Rob
Re: [PATCH 07/10] dt-bindings: mtd: Ensure partition node properties are documented
Posted by Krzysztof Kozlowski 4 weeks ago
On Fri, Jan 09, 2026 at 06:25:32PM -0600, Rob Herring wrote:
> > > -    $ref: partitions/partition.yaml
> > > -    deprecated: true
> > > -
> > > -  "^partition@[0-9a-f]+":
> > > -    $ref: partitions/partition.yaml
> > > +  "(^partition)?@[0-9a-f]+$":
> > > +    $ref: /schemas/mtd/partitions/partition.yaml#/$defs/partition-node
> > >      deprecated: true
> >
> > This makes partition@ deprecated. Looks unintended or needds commit msg
> > explanation.
> 
> No, the only change here is I combined the entries. "partition@" is
> deprecated when not under "partitions" node.

Indeed, I misread the diff.


Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>

Best regards,
Krzysztof
Re: [PATCH 07/10] dt-bindings: mtd: Ensure partition node properties are documented
Posted by Miquel Raynal 1 month ago
Hello Rob,

On 08/01/2026 at 11:53:16 -06, "Rob Herring (Arm)" <robh@kernel.org> wrote:

> Partition nodes without a compatible have no restrictions on additional
> properties. Fix this by ensuring 'unevaluatedProperties' is set when
> there's no compatible property. If there is a compatible property, then
> there should be a specific schema for it which will enforce
> 'unevaluatedProperties'.
>
> Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
> ---

Overall thank you very much for this series, I've been sruggling while
defining these and your approach seems very relevant. I am fine with all
the patches in this series, but will wait a bit for others to make a bit
of feedback.

[...]

> +$defs:
> +  partition-node:
> +    type: object
> +    if:
> +      not:
> +        required: [ compatible ]
> +    then:
> +      $ref: '#'
> +      unevaluatedProperties: false
> +    else:
> +      $ref: '#'

This, however, is total blackmagic to me. Would you mind explaining what

      $ref: '#'

indicates? Is this a placeholder indicating "a reference must be given?

Also I do not understand the final else case, what is it covering?

Thanks for the little explanation (or you can give me a pointer to some
relevant doc I could read).

Thanks,
Miquèl
Re: [PATCH 07/10] dt-bindings: mtd: Ensure partition node properties are documented
Posted by Rob Herring 1 month ago
On Fri, Jan 9, 2026 at 3:02 AM Miquel Raynal <miquel.raynal@bootlin.com> wrote:
>
> Hello Rob,
>
> On 08/01/2026 at 11:53:16 -06, "Rob Herring (Arm)" <robh@kernel.org> wrote:
>
> > Partition nodes without a compatible have no restrictions on additional
> > properties. Fix this by ensuring 'unevaluatedProperties' is set when
> > there's no compatible property. If there is a compatible property, then
> > there should be a specific schema for it which will enforce
> > 'unevaluatedProperties'.
> >
> > Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
> > ---
>
> Overall thank you very much for this series, I've been sruggling while
> defining these and your approach seems very relevant. I am fine with all
> the patches in this series, but will wait a bit for others to make a bit
> of feedback.
>
> [...]
>
> > +$defs:
> > +  partition-node:
> > +    type: object
> > +    if:
> > +      not:
> > +        required: [ compatible ]
> > +    then:
> > +      $ref: '#'
> > +      unevaluatedProperties: false
> > +    else:
> > +      $ref: '#'
>
> This, however, is total blackmagic to me. Would you mind explaining what
>
>       $ref: '#'
>
> indicates? Is this a placeholder indicating "a reference must be given?

It's what's known as JSON pointers. The '#' is a reference to the top
level of this schema.

> Also I do not understand the final else case, what is it covering?

It's really just there so a $ref to
partition.yaml#/$defs/partition-node applies the schema (all of
partition.yaml) whether there's a compatible property or not.

This all just works around that a schema like this doesn't work:

$ref: foo.yaml
if:
  ...
then:
  unevaluatedProperties: false

The evaluation of unevaluatedProperties doesn't "see" the $ref being
in the parent. So we can't factor out the $ref.

Hope that makes sense.

Rob
Re: [PATCH 07/10] dt-bindings: mtd: Ensure partition node properties are documented
Posted by Miquel Raynal 3 weeks, 4 days ago
Hi Rob,

>> > +$defs:
>> > +  partition-node:
>> > +    type: object
>> > +    if:
>> > +      not:
>> > +        required: [ compatible ]
>> > +    then:
>> > +      $ref: '#'
>> > +      unevaluatedProperties: false
>> > +    else:
>> > +      $ref: '#'
>>
>> This, however, is total blackmagic to me. Would you mind explaining what
>>
>>       $ref: '#'
>>
>> indicates? Is this a placeholder indicating "a reference must be given?
>
> It's what's known as JSON pointers. The '#' is a reference to the top
> level of this schema.
>
>> Also I do not understand the final else case, what is it covering?
>
> It's really just there so a $ref to
> partition.yaml#/$defs/partition-node applies the schema (all of
> partition.yaml) whether there's a compatible property or not.
>
> This all just works around that a schema like this doesn't work:
>
> $ref: foo.yaml
> if:
>   ...
> then:
>   unevaluatedProperties: false
>
> The evaluation of unevaluatedProperties doesn't "see" the $ref being
> in the parent. So we can't factor out the $ref.

Oooh, ok, fully understood. I think I already faced that problem
before. First time I hear about JSON pointers, thanks a lot for the
heads up.

Regarding this series, it feels like in the end, if I understood the
discussion with Krzysztof correctly, there is no modification to bring?
Let me know if you plan on sending a v2 of if I shall take v1 otherwise.

Thanks,
Miquèl
Re: [PATCH 07/10] dt-bindings: mtd: Ensure partition node properties are documented
Posted by Rob Herring 3 weeks, 4 days ago
On Wed, Jan 14, 2026 at 7:58 AM Miquel Raynal <miquel.raynal@bootlin.com> wrote:
>
> Hi Rob,
>
> >> > +$defs:
> >> > +  partition-node:
> >> > +    type: object
> >> > +    if:
> >> > +      not:
> >> > +        required: [ compatible ]
> >> > +    then:
> >> > +      $ref: '#'
> >> > +      unevaluatedProperties: false
> >> > +    else:
> >> > +      $ref: '#'
> >>
> >> This, however, is total blackmagic to me. Would you mind explaining what
> >>
> >>       $ref: '#'
> >>
> >> indicates? Is this a placeholder indicating "a reference must be given?
> >
> > It's what's known as JSON pointers. The '#' is a reference to the top
> > level of this schema.
> >
> >> Also I do not understand the final else case, what is it covering?
> >
> > It's really just there so a $ref to
> > partition.yaml#/$defs/partition-node applies the schema (all of
> > partition.yaml) whether there's a compatible property or not.
> >
> > This all just works around that a schema like this doesn't work:
> >
> > $ref: foo.yaml
> > if:
> >   ...
> > then:
> >   unevaluatedProperties: false
> >
> > The evaluation of unevaluatedProperties doesn't "see" the $ref being
> > in the parent. So we can't factor out the $ref.
>
> Oooh, ok, fully understood. I think I already faced that problem
> before. First time I hear about JSON pointers, thanks a lot for the
> heads up.
>
> Regarding this series, it feels like in the end, if I understood the
> discussion with Krzysztof correctly, there is no modification to bring?
> Let me know if you plan on sending a v2 of if I shall take v1 otherwise.

Right, I think v1 is good to go.

Rob