dt-bindings: mtd: partitions: make partition an NVMEM provider

Message ID 20240111121940.15628-1-zajec5@gmail.com
State New
Headers
Series dt-bindings: mtd: partitions: make partition an NVMEM provider |

Commit Message

Rafał Miłecki Jan. 11, 2024, 12:19 p.m. UTC
  From: Rafał Miłecki <rafal@milecki.pl>

MTD partition provides flash device data and can be used as NVMEM
device.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
 .../bindings/mtd/partitions/partition.yaml       | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
  

Comments

Rafał Miłecki Jan. 11, 2024, 12:26 p.m. UTC | #1
Cc Srini & Greg (please keep them in loop in case or replies)

On 11.01.2024 13:19, Rafał Miłecki wrote:
> From: Rafał Miłecki <rafal@milecki.pl>
> 
> MTD partition provides flash device data and can be used as NVMEM
> device.
> 
> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
> ---
>   .../bindings/mtd/partitions/partition.yaml       | 16 +++++++++-------
>   1 file changed, 9 insertions(+), 7 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/mtd/partitions/partition.yaml b/Documentation/devicetree/bindings/mtd/partitions/partition.yaml
> index 1ebe9e2347ea..7b1d84ce5ef5 100644
> --- a/Documentation/devicetree/bindings/mtd/partitions/partition.yaml
> +++ b/Documentation/devicetree/bindings/mtd/partitions/partition.yaml
> @@ -57,13 +57,15 @@ properties:
>         user space from
>       type: boolean
>   
> -if:
> -  not:
> -    required: [ reg ]
> -then:
> -  properties:
> -    $nodename:
> -      pattern: '^partition-.*$'
> +allOf:
> +  - $ref: /schemas/nvmem/nvmem.yaml
> +  - if:
> +      not:
> +        required: [ reg ]
> +    then:
> +      properties:
> +        $nodename:
> +          pattern: '^partition-.*$'
>   
>   # This is a generic file other binding inherit from and extend
>   additionalProperties: true
  
Rob Herring Jan. 19, 2024, 10:33 p.m. UTC | #2
On Thu, Jan 11, 2024 at 01:19:40PM +0100, Rafał Miłecki wrote:
> From: Rafał Miłecki <rafal@milecki.pl>
> 
> MTD partition provides flash device data and can be used as NVMEM
> device.

I don't follow what is the relationship between this and your other 
series.

> 
> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
> ---
>  .../bindings/mtd/partitions/partition.yaml       | 16 +++++++++-------
>  1 file changed, 9 insertions(+), 7 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/mtd/partitions/partition.yaml b/Documentation/devicetree/bindings/mtd/partitions/partition.yaml
> index 1ebe9e2347ea..7b1d84ce5ef5 100644
> --- a/Documentation/devicetree/bindings/mtd/partitions/partition.yaml
> +++ b/Documentation/devicetree/bindings/mtd/partitions/partition.yaml
> @@ -57,13 +57,15 @@ properties:
>        user space from
>      type: boolean
>  
> -if:
> -  not:
> -    required: [ reg ]
> -then:
> -  properties:
> -    $nodename:
> -      pattern: '^partition-.*$'
> +allOf:
> +  - $ref: /schemas/nvmem/nvmem.yaml

Only some partitions are nvmem nodes, so we shouldn't always include it. 
Then we can't exclude nvmem properties from partition nodes which 
aren't. We should identify those nodes by compatible and their schema 
should reference partition.yaml and nvmem.yaml.

There's a general problem with the partition related schemas that 
undefined properties are not caught. This is partly because 
partition nodes can be nested and expressing that with the schema is 
hard.

Rob
  

Patch

diff --git a/Documentation/devicetree/bindings/mtd/partitions/partition.yaml b/Documentation/devicetree/bindings/mtd/partitions/partition.yaml
index 1ebe9e2347ea..7b1d84ce5ef5 100644
--- a/Documentation/devicetree/bindings/mtd/partitions/partition.yaml
+++ b/Documentation/devicetree/bindings/mtd/partitions/partition.yaml
@@ -57,13 +57,15 @@  properties:
       user space from
     type: boolean
 
-if:
-  not:
-    required: [ reg ]
-then:
-  properties:
-    $nodename:
-      pattern: '^partition-.*$'
+allOf:
+  - $ref: /schemas/nvmem/nvmem.yaml
+  - if:
+      not:
+        required: [ reg ]
+    then:
+      properties:
+        $nodename:
+          pattern: '^partition-.*$'
 
 # This is a generic file other binding inherit from and extend
 additionalProperties: true