devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] docs: dt: writing-schema: Describe defining properties in top-level
@ 2025-09-04 14:24 Krzysztof Kozlowski
  2025-09-04 15:30 ` Frank Li
  2025-09-09 15:06 ` Rob Herring (Arm)
  0 siblings, 2 replies; 5+ messages in thread
From: Krzysztof Kozlowski @ 2025-09-04 14:24 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, devicetree,
	linux-kernel
  Cc: Krzysztof Kozlowski

Document established Devicetree bindings maintainers review practice:
Properties having differences per each device in the binding, e.g.
different constraints for lists or different allowed values, should
still be defined in top-level 'properties' section and only customized
in 'if:then:'.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
 Documentation/devicetree/bindings/writing-schema.rst | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/Documentation/devicetree/bindings/writing-schema.rst b/Documentation/devicetree/bindings/writing-schema.rst
index 470d1521fa17..e0859094575d 100644
--- a/Documentation/devicetree/bindings/writing-schema.rst
+++ b/Documentation/devicetree/bindings/writing-schema.rst
@@ -165,6 +165,14 @@ The YAML Devicetree format also makes all string values an array and scalar
 values a matrix (in order to define groupings) even when only a single value
 is present. Single entries in schemas are fixed up to match this encoding.
 
+When bindings cover multiple similar devices that differ in some properties,
+those properties should be constrained for each device. This usually means:
+
+ * In top level 'properties' define the property with the broadest constraints.
+ * In 'if:then:' blocks, further narrow the constraints for those properties.
+ * Do not define the properties within an 'if:then:' block (note that
+   'additionalItems' also won't allow that).
+
 Coding style
 ------------
 
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] docs: dt: writing-schema: Describe defining properties in top-level
  2025-09-04 14:24 [PATCH] docs: dt: writing-schema: Describe defining properties in top-level Krzysztof Kozlowski
@ 2025-09-04 15:30 ` Frank Li
  2025-09-05  6:49   ` Krzysztof Kozlowski
  2025-09-09 15:06 ` Rob Herring (Arm)
  1 sibling, 1 reply; 5+ messages in thread
From: Frank Li @ 2025-09-04 15:30 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, devicetree,
	linux-kernel

On Thu, Sep 04, 2025 at 04:24:01PM +0200, Krzysztof Kozlowski wrote:
> Document established Devicetree bindings maintainers review practice:
> Properties having differences per each device in the binding, e.g.
> different constraints for lists or different allowed values, should
> still be defined in top-level 'properties' section and only customized
> in 'if:then:'.

'customized' is not easy understand in my view.

only restrict (such as limit number of item, limit data range, disabllow
properties) in 'if: then:' section.

>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> ---
>  Documentation/devicetree/bindings/writing-schema.rst | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/writing-schema.rst b/Documentation/devicetree/bindings/writing-schema.rst
> index 470d1521fa17..e0859094575d 100644
> --- a/Documentation/devicetree/bindings/writing-schema.rst
> +++ b/Documentation/devicetree/bindings/writing-schema.rst
> @@ -165,6 +165,14 @@ The YAML Devicetree format also makes all string values an array and scalar
>  values a matrix (in order to define groupings) even when only a single value
>  is present. Single entries in schemas are fixed up to match this encoding.
>
> +When bindings cover multiple similar devices that differ in some properties,
> +those properties should be constrained for each device. This usually means:
> +
> + * In top level 'properties' define the property with the broadest constraints.
> + * In 'if:then:' blocks, further narrow the constraints for those properties.
> + * Do not define the properties within an 'if:then:' block (note that
> +   'additionalItems' also won't allow that).
> +

I can understand what your said. I think it would be better if add some
simple examples.

Frank

>  Coding style
>  ------------
>
> --
> 2.48.1
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] docs: dt: writing-schema: Describe defining properties in top-level
  2025-09-04 15:30 ` Frank Li
@ 2025-09-05  6:49   ` Krzysztof Kozlowski
  2025-09-05 14:35     ` Frank Li
  0 siblings, 1 reply; 5+ messages in thread
From: Krzysztof Kozlowski @ 2025-09-05  6:49 UTC (permalink / raw)
  To: Frank Li
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, devicetree,
	linux-kernel

On 04/09/2025 17:30, Frank Li wrote:
>> diff --git a/Documentation/devicetree/bindings/writing-schema.rst b/Documentation/devicetree/bindings/writing-schema.rst
>> index 470d1521fa17..e0859094575d 100644
>> --- a/Documentation/devicetree/bindings/writing-schema.rst
>> +++ b/Documentation/devicetree/bindings/writing-schema.rst
>> @@ -165,6 +165,14 @@ The YAML Devicetree format also makes all string values an array and scalar
>>  values a matrix (in order to define groupings) even when only a single value
>>  is present. Single entries in schemas are fixed up to match this encoding.
>>
>> +When bindings cover multiple similar devices that differ in some properties,
>> +those properties should be constrained for each device. This usually means:
>> +
>> + * In top level 'properties' define the property with the broadest constraints.
>> + * In 'if:then:' blocks, further narrow the constraints for those properties.
>> + * Do not define the properties within an 'if:then:' block (note that
>> +   'additionalItems' also won't allow that).
>> +
> 
> I can understand what your said. I think it would be better if add some
> simple examples.
Example for that is already there - at the bottom of this file.

Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] docs: dt: writing-schema: Describe defining properties in top-level
  2025-09-05  6:49   ` Krzysztof Kozlowski
@ 2025-09-05 14:35     ` Frank Li
  0 siblings, 0 replies; 5+ messages in thread
From: Frank Li @ 2025-09-05 14:35 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, devicetree,
	linux-kernel

On Fri, Sep 05, 2025 at 08:49:01AM +0200, Krzysztof Kozlowski wrote:
> On 04/09/2025 17:30, Frank Li wrote:
> >> diff --git a/Documentation/devicetree/bindings/writing-schema.rst b/Documentation/devicetree/bindings/writing-schema.rst
> >> index 470d1521fa17..e0859094575d 100644
> >> --- a/Documentation/devicetree/bindings/writing-schema.rst
> >> +++ b/Documentation/devicetree/bindings/writing-schema.rst
> >> @@ -165,6 +165,14 @@ The YAML Devicetree format also makes all string values an array and scalar
> >>  values a matrix (in order to define groupings) even when only a single value
> >>  is present. Single entries in schemas are fixed up to match this encoding.
> >>
> >> +When bindings cover multiple similar devices that differ in some properties,
> >> +those properties should be constrained for each device. This usually means:
> >> +
> >> + * In top level 'properties' define the property with the broadest constraints.
> >> + * In 'if:then:' blocks, further narrow the constraints for those properties.
> >> + * Do not define the properties within an 'if:then:' block (note that
> >> +   'additionalItems' also won't allow that).
> >> +
> >
> > I can understand what your said. I think it would be better if add some
> > simple examples.
> Example for that is already there - at the bottom of this file.

example-schema.yaml is big, it is hard to match to this specific rule. some
small section will be helpful

              properties:
                a:               # define 'a' at top
                  enum: [0, 1]   # width range in here
              allOf:
                - if:
                    ...          # some condition
                  then:
                    properties:
                      a:
                        const: 0 # allow only 0 for some specific condition.

Frank


>
> Best regards,
> Krzysztof

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] docs: dt: writing-schema: Describe defining properties in top-level
  2025-09-04 14:24 [PATCH] docs: dt: writing-schema: Describe defining properties in top-level Krzysztof Kozlowski
  2025-09-04 15:30 ` Frank Li
@ 2025-09-09 15:06 ` Rob Herring (Arm)
  1 sibling, 0 replies; 5+ messages in thread
From: Rob Herring (Arm) @ 2025-09-09 15:06 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Krzysztof Kozlowski, linux-kernel, Conor Dooley, devicetree


On Thu, 04 Sep 2025 16:24:01 +0200, Krzysztof Kozlowski wrote:
> Document established Devicetree bindings maintainers review practice:
> Properties having differences per each device in the binding, e.g.
> different constraints for lists or different allowed values, should
> still be defined in top-level 'properties' section and only customized
> in 'if:then:'.
> 
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> ---
>  Documentation/devicetree/bindings/writing-schema.rst | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 

Applied, thanks!


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-09-09 15:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-04 14:24 [PATCH] docs: dt: writing-schema: Describe defining properties in top-level Krzysztof Kozlowski
2025-09-04 15:30 ` Frank Li
2025-09-05  6:49   ` Krzysztof Kozlowski
2025-09-05 14:35     ` Frank Li
2025-09-09 15:06 ` Rob Herring (Arm)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).