diff mbox series

[1/3] dt-bindings: mtd: Relax BCM4908 partition schema

Message ID 20241009215046.1449389-2-CFSworks@gmail.com (mailing list archive)
State New, archived
Headers show
Series Resolve BCMBCA DT validation errors | expand

Commit Message

Sam Edwards Oct. 9, 2024, 9:50 p.m. UTC
The BCM4908 partition "parser" is really just a fixed partitions table,
with a special partition compatible (`brcm,bcm4908-firmware`) that
automatically labels the partition as "firmware" or "backup" depending
on what CFE is communicating as the selected active partition.

The bcm4908-partitions schema is currently too restrictive, requiring
that all child nodes use this special compatible or none at all. This
not only contracits what is allowed by the "parser" but also causes
warnings for an existing file ("bcm4908-asus-gt-ac5300.dts").

Modify the schema to be strict only for child partitions that use the
-firmware compatible. Also update the child name regex to agree with
fixed-partitions, so that these differences apply consistently.

Signed-off-by: Sam Edwards <CFSworks@gmail.com>
---
 .../mtd/partitions/brcm,bcm4908-partitions.yaml | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

Comments

Rob Herring (Arm) Oct. 10, 2024, 2:06 a.m. UTC | #1
On Wed, 09 Oct 2024 14:50:44 -0700, Sam Edwards wrote:
> The BCM4908 partition "parser" is really just a fixed partitions table,
> with a special partition compatible (`brcm,bcm4908-firmware`) that
> automatically labels the partition as "firmware" or "backup" depending
> on what CFE is communicating as the selected active partition.
> 
> The bcm4908-partitions schema is currently too restrictive, requiring
> that all child nodes use this special compatible or none at all. This
> not only contracits what is allowed by the "parser" but also causes
> warnings for an existing file ("bcm4908-asus-gt-ac5300.dts").
> 
> Modify the schema to be strict only for child partitions that use the
> -firmware compatible. Also update the child name regex to agree with
> fixed-partitions, so that these differences apply consistently.
> 
> Signed-off-by: Sam Edwards <CFSworks@gmail.com>
> ---
>  .../mtd/partitions/brcm,bcm4908-partitions.yaml | 17 +++++++++++------
>  1 file changed, 11 insertions(+), 6 deletions(-)
> 

My bot found errors running 'make dt_binding_check' on your patch:

yamllint warnings/errors:

dtschema/dtc warnings/errors:
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/mtd/partitions/brcm,bcm4908-partitions.yaml: patternProperties:^partition(-.+|@[0-9a-f]+)$: 'if' is not one of ['type', 'description', 'dependencies', 'dependentRequired', 'dependentSchemas', 'properties', 'patternProperties', 'additionalProperties', 'unevaluatedProperties', 'deprecated', 'required', 'not', 'allOf', 'anyOf', 'oneOf', '$ref']
	from schema $id: http://devicetree.org/meta-schemas/nodes.yaml#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/mtd/partitions/brcm,bcm4908-partitions.yaml: patternProperties:^partition(-.+|@[0-9a-f]+)$: 'then' is not one of ['type', 'description', 'dependencies', 'dependentRequired', 'dependentSchemas', 'properties', 'patternProperties', 'additionalProperties', 'unevaluatedProperties', 'deprecated', 'required', 'not', 'allOf', 'anyOf', 'oneOf', '$ref']
	from schema $id: http://devicetree.org/meta-schemas/nodes.yaml#

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/20241009215046.1449389-2-CFSworks@gmail.com

The base for the series is generally the latest rc1. A different dependency
should be noted in *this* patch.

If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure 'yamllint' is installed and dt-schema is up to
date:

pip3 install dtschema --upgrade

Please check and re-submit after running the above command yourself. Note
that DT_SCHEMA_FILES can be set to your schema file to speed up checking
your schema. However, it must be unset to test all examples with your schema.
Rob Herring (Arm) Oct. 10, 2024, 2:38 a.m. UTC | #2
On Wed, Oct 09, 2024 at 02:50:44PM -0700, Sam Edwards wrote:
> The BCM4908 partition "parser" is really just a fixed partitions table,
> with a special partition compatible (`brcm,bcm4908-firmware`) that
> automatically labels the partition as "firmware" or "backup" depending
> on what CFE is communicating as the selected active partition.
> 
> The bcm4908-partitions schema is currently too restrictive, requiring
> that all child nodes use this special compatible or none at all. This
> not only contracits what is allowed by the "parser" but also causes
> warnings for an existing file ("bcm4908-asus-gt-ac5300.dts").
> 
> Modify the schema to be strict only for child partitions that use the
> -firmware compatible. Also update the child name regex to agree with
> fixed-partitions, so that these differences apply consistently.
> 
> Signed-off-by: Sam Edwards <CFSworks@gmail.com>
> ---
>  .../mtd/partitions/brcm,bcm4908-partitions.yaml | 17 +++++++++++------
>  1 file changed, 11 insertions(+), 6 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/mtd/partitions/brcm,bcm4908-partitions.yaml b/Documentation/devicetree/bindings/mtd/partitions/brcm,bcm4908-partitions.yaml
> index 94f0742b375c..aed37922a5fc 100644
> --- a/Documentation/devicetree/bindings/mtd/partitions/brcm,bcm4908-partitions.yaml
> +++ b/Documentation/devicetree/bindings/mtd/partitions/brcm,bcm4908-partitions.yaml
> @@ -30,12 +30,17 @@ properties:
>      enum: [ 1, 2 ]
>  
>  patternProperties:
> -  "^partition@[0-9a-f]+$":
> -    $ref: partition.yaml#
> -    properties:
> -      compatible:
> -        const: brcm,bcm4908-firmware
> -    unevaluatedProperties: false
> +  "^partition(-.+|@[0-9a-f]+)$":
> +    type: object
> +    if:
> +      properties:
> +        compatible:
> +          const: brcm,bcm4908-firmware

What schema applies to the node if this is not true? That needs to be 
addressed. You should be able to use oneOf here rather than if/then 
schema.

> +    then:
> +      $ref: partition.yaml#
> +      properties:
> +        compatible: true
> +      unevaluatedProperties: false
>  
>  required:
>    - "#address-cells"
> -- 
> 2.44.2
>
Sam Edwards Oct. 10, 2024, 3:37 a.m. UTC | #3
On Wed, Oct 9, 2024 at 7:38 PM Rob Herring <robh@kernel.org> wrote:
>
> On Wed, Oct 09, 2024 at 02:50:44PM -0700, Sam Edwards wrote:
> > The BCM4908 partition "parser" is really just a fixed partitions table,
> > with a special partition compatible (`brcm,bcm4908-firmware`) that
> > automatically labels the partition as "firmware" or "backup" depending
> > on what CFE is communicating as the selected active partition.
> >
> > The bcm4908-partitions schema is currently too restrictive, requiring
> > that all child nodes use this special compatible or none at all. This
> > not only contracits what is allowed by the "parser" but also causes
> > warnings for an existing file ("bcm4908-asus-gt-ac5300.dts").
> >
> > Modify the schema to be strict only for child partitions that use the
> > -firmware compatible. Also update the child name regex to agree with
> > fixed-partitions, so that these differences apply consistently.
> >
> > Signed-off-by: Sam Edwards <CFSworks@gmail.com>
> > ---
> >  .../mtd/partitions/brcm,bcm4908-partitions.yaml | 17 +++++++++++------
> >  1 file changed, 11 insertions(+), 6 deletions(-)
> >
> > diff --git a/Documentation/devicetree/bindings/mtd/partitions/brcm,bcm4908-partitions.yaml b/Documentation/devicetree/bindings/mtd/partitions/brcm,bcm4908-partitions.yaml
> > index 94f0742b375c..aed37922a5fc 100644
> > --- a/Documentation/devicetree/bindings/mtd/partitions/brcm,bcm4908-partitions.yaml
> > +++ b/Documentation/devicetree/bindings/mtd/partitions/brcm,bcm4908-partitions.yaml
> > @@ -30,12 +30,17 @@ properties:
> >      enum: [ 1, 2 ]
> >
> >  patternProperties:
> > -  "^partition@[0-9a-f]+$":
> > -    $ref: partition.yaml#
> > -    properties:
> > -      compatible:
> > -        const: brcm,bcm4908-firmware
> > -    unevaluatedProperties: false
> > +  "^partition(-.+|@[0-9a-f]+)$":
> > +    type: object
> > +    if:
> > +      properties:
> > +        compatible:
> > +          const: brcm,bcm4908-firmware

Hi Rob,

Thanks for your attention on this one! This is an odd case where I'm
not sure what else could be done, and I'm a newbie to modifying DT
schemata, so I'm glad to be receiving your feedback. :)

> What schema applies to the node if this is not true? That needs to be
> addressed. You should be able to use oneOf here rather than if/then
> schema.

The schema that should apply "in general" is partition.yaml, though
moving the '$ref:' outside of 'then:' made the 'unevaluatedProperties:
false' disallow everything. The if block here is just trying to
memorialize bcm4908-firmware as a valid compatible at this level, and
(ideally) disallow unevaluated properties if so.

Could that be done with a oneOf? I would think if one of the arms of
the oneOf was "unmodified $partition.yaml, unevaluated allowed" it
would always match, rendering the "unevaluated disallowed when
compatible=bcm4908-firmware" arm unused.

Best,
Sam

>
> > +    then:
> > +      $ref: partition.yaml#
> > +      properties:
> > +        compatible: true
> > +      unevaluatedProperties: false
> >
> >  required:
> >    - "#address-cells"
> > --
> > 2.44.2
> >
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/mtd/partitions/brcm,bcm4908-partitions.yaml b/Documentation/devicetree/bindings/mtd/partitions/brcm,bcm4908-partitions.yaml
index 94f0742b375c..aed37922a5fc 100644
--- a/Documentation/devicetree/bindings/mtd/partitions/brcm,bcm4908-partitions.yaml
+++ b/Documentation/devicetree/bindings/mtd/partitions/brcm,bcm4908-partitions.yaml
@@ -30,12 +30,17 @@  properties:
     enum: [ 1, 2 ]
 
 patternProperties:
-  "^partition@[0-9a-f]+$":
-    $ref: partition.yaml#
-    properties:
-      compatible:
-        const: brcm,bcm4908-firmware
-    unevaluatedProperties: false
+  "^partition(-.+|@[0-9a-f]+)$":
+    type: object
+    if:
+      properties:
+        compatible:
+          const: brcm,bcm4908-firmware
+    then:
+      $ref: partition.yaml#
+      properties:
+        compatible: true
+      unevaluatedProperties: false
 
 required:
   - "#address-cells"