devicetree-compiler.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] checks: Suppress warnings on overlay fragments
@ 2023-01-11  2:34 Qun-Wei Lin
       [not found] ` <20230111023417.24141-1-qun-wei.lin-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Qun-Wei Lin @ 2023-01-11  2:34 UTC (permalink / raw)
  To: david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+
  Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA,
	casper.li-NuS5LvNUpcJWk0Htik3J/w,
	chinwen.chang-NuS5LvNUpcJWk0Htik3J/w,
	kuan-ying.lee-NuS5LvNUpcJWk0Htik3J/w,
	ivan.tseng-NuS5LvNUpcJWk0Htik3J/w,
	ladon.huang-NuS5LvNUpcJWk0Htik3J/w, Qun-Wei Lin

The overlay fragment is a speial case where some properties are not
present in the overlay source file, but in the base file.

example:
+-----------------------------+--------------------+
| base.dts                    | overlay.dts        |
+-----------------------------+--------------------+
| /dts-v1/;                   | /dts-v1/;          |
|                             | /plugin/;          |
| /{                          |                    |
|   parent: test {            | &parent {          |
|     #address-cells = <1>;   |   child@0 {        |
|     #size-cells = <0>;      |     reg = <0x0>;   |
|   };                        |   };               |
| };                          | };                 |
+-----------------------------+--------------------+

It will cause the following false alarms when compiling the overlay dts.

1. /fragment@0/__overlay__: Character '_' not recommended in node name
2. /fragment@0/__overlay__: Relying on default #address-cells value
3. /fragment@0/__overlay__: Relying on default #size-cells value
4. /fragment@0/__overlay__:reg: property has invalid length (4 bytes)
   (#address-cells == 2, #size-cells == 1)

This workaround will fix them by skip checking for node named __overlay__.

Signed-off-by: Qun-Wei Lin <qun-wei.lin-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
---
 checks.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/checks.c b/checks.c
index 9f31d26..afa8f23 100644
--- a/checks.c
+++ b/checks.c
@@ -325,6 +325,9 @@ static void check_node_name_chars_strict(struct check *c, struct dt_info *dti,
 {
 	int n = strspn(node->name, c->data);
 
+	if (streq(node->name, "__overlay__"))
+		return;
+
 	if (n < node->basenamelen)
 		FAIL(c, dti, node, "Character '%c' not recommended in node name",
 		     node->name[n]);
@@ -767,6 +770,9 @@ static void check_reg_format(struct check *c, struct dt_info *dti,
 		return;
 	}
 
+	if (streq(node->parent->name, "__overlay__"))
+		return;
+
 	if (prop->val.len == 0)
 		FAIL_PROP(c, dti, node, prop, "property is empty");
 
@@ -1197,6 +1203,10 @@ static void check_avoid_default_addr_size(struct check *c, struct dt_info *dti,
 	if (!node->parent)
 		return; /* Ignore root node */
 
+
+	if (streq(node->parent->name, "__overlay__"))
+		return;
+
 	reg = get_property(node, "reg");
 	ranges = get_property(node, "ranges");
 
-- 
2.18.0


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

* Re: [PATCH] checks: Suppress warnings on overlay fragments
       [not found] ` <20230111023417.24141-1-qun-wei.lin-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
@ 2023-02-01 11:23   ` Qun-wei Lin (林群崴)
  2023-02-01 20:29   ` Rob Herring
  1 sibling, 0 replies; 3+ messages in thread
From: Qun-wei Lin (林群崴) @ 2023-02-01 11:23 UTC (permalink / raw)
  To: david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org
  Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Casper Li (李中榮),
	Kuan-Ying Lee (李冠穎),
	Ivan Tseng (曾志軒),
	Chinwen Chang (張錦文),
	Ladon Huang (黃柏諭)

On Wed, 2023-01-11 at 10:34 +0800, Qun-Wei Lin wrote:
> The overlay fragment is a speial case where some properties are not
> present in the overlay source file, but in the base file.
> 
> example:
> +-----------------------------+--------------------+
> > base.dts                    | overlay.dts        |
> 
> +-----------------------------+--------------------+
> > /dts-v1/;                   | /dts-v1/;          |
> >                             | /plugin/;          |
> > /{                          |                    |
> >   parent: test {            | &parent {          |
> >     #address-cells = <1>;   |   child@0 {        |
> >     #size-cells = <0>;      |     reg = <0x0>;   |
> >   };                        |   };               |
> > };                          | };                 |
> 
> +-----------------------------+--------------------+
> 
> It will cause the following false alarms when compiling the overlay
> dts.
> 
> 1. /fragment@0/__overlay__: Character '_' not recommended in node
> name
> 2. /fragment@0/__overlay__: Relying on default #address-cells value
> 3. /fragment@0/__overlay__: Relying on default #size-cells value
> 4. /fragment@0/__overlay__:reg: property has invalid length (4 bytes)
>    (#address-cells == 2, #size-cells == 1)
> 
> This workaround will fix them by skip checking for node named
> __overlay__.
> 
> Signed-off-by: Qun-Wei Lin <qun-wei.lin@mediatek.com>
> ---
>  checks.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/checks.c b/checks.c
> index 9f31d26..afa8f23 100644
> --- a/checks.c
> +++ b/checks.c
> @@ -325,6 +325,9 @@ static void check_node_name_chars_strict(struct
> check *c, struct dt_info *dti,
>  {
>  	int n = strspn(node->name, c->data);
>  
> +	if (streq(node->name, "__overlay__"))
> +		return;
> +
>  	if (n < node->basenamelen)
>  		FAIL(c, dti, node, "Character '%c' not recommended in
> node name",
>  		     node->name[n]);
> @@ -767,6 +770,9 @@ static void check_reg_format(struct check *c,
> struct dt_info *dti,
>  		return;
>  	}
>  
> +	if (streq(node->parent->name, "__overlay__"))
> +		return;
> +
>  	if (prop->val.len == 0)
>  		FAIL_PROP(c, dti, node, prop, "property is empty");
>  
> @@ -1197,6 +1203,10 @@ static void
> check_avoid_default_addr_size(struct check *c, struct dt_info *dti,
>  	if (!node->parent)
>  		return; /* Ignore root node */
>  
> +
> +	if (streq(node->parent->name, "__overlay__"))
> +		return;
> +
>  	reg = get_property(node, "reg");
>  	ranges = get_property(node, "ranges");
>  

Hi, maintainers, kindly ping...
Please help to review this patch.

Thanks!

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

* Re: [PATCH] checks: Suppress warnings on overlay fragments
       [not found] ` <20230111023417.24141-1-qun-wei.lin-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
  2023-02-01 11:23   ` Qun-wei Lin (林群崴)
@ 2023-02-01 20:29   ` Rob Herring
  1 sibling, 0 replies; 3+ messages in thread
From: Rob Herring @ 2023-02-01 20:29 UTC (permalink / raw)
  To: Qun-Wei Lin
  Cc: david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+,
	devicetree-compiler-u79uwXL29TY76Z2rM5mHXA,
	casper.li-NuS5LvNUpcJWk0Htik3J/w,
	chinwen.chang-NuS5LvNUpcJWk0Htik3J/w,
	kuan-ying.lee-NuS5LvNUpcJWk0Htik3J/w,
	ivan.tseng-NuS5LvNUpcJWk0Htik3J/w,
	ladon.huang-NuS5LvNUpcJWk0Htik3J/w

On Tue, Jan 10, 2023 at 8:35 PM Qun-Wei Lin <qun-wei.lin-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org> wrote:
>
> The overlay fragment is a speial case where some properties are not

special

> present in the overlay source file, but in the base file.
>
> example:
> +-----------------------------+--------------------+
> | base.dts                    | overlay.dts        |
> +-----------------------------+--------------------+
> | /dts-v1/;                   | /dts-v1/;          |
> |                             | /plugin/;          |
> | /{                          |                    |
> |   parent: test {            | &parent {          |
> |     #address-cells = <1>;   |   child@0 {        |
> |     #size-cells = <0>;      |     reg = <0x0>;   |
> |   };                        |   };               |
> | };                          | };                 |
> +-----------------------------+--------------------+
>
> It will cause the following false alarms when compiling the overlay dts.
>
> 1. /fragment@0/__overlay__: Character '_' not recommended in node name
> 2. /fragment@0/__overlay__: Relying on default #address-cells value
> 3. /fragment@0/__overlay__: Relying on default #size-cells value
> 4. /fragment@0/__overlay__:reg: property has invalid length (4 bytes)
>    (#address-cells == 2, #size-cells == 1)
>
> This workaround will fix them by skip checking for node named __overlay__.
>
> Signed-off-by: Qun-Wei Lin <qun-wei.lin-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
> ---
>  checks.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/checks.c b/checks.c
> index 9f31d26..afa8f23 100644
> --- a/checks.c
> +++ b/checks.c
> @@ -325,6 +325,9 @@ static void check_node_name_chars_strict(struct check *c, struct dt_info *dti,
>  {
>         int n = strspn(node->name, c->data);
>
> +       if (streq(node->name, "__overlay__"))

Do we hit the same thing with __fixups__ or __local_fixups__? If so,
just skip anything starting with "__".

> +               return;
> +
>         if (n < node->basenamelen)
>                 FAIL(c, dti, node, "Character '%c' not recommended in node name",
>                      node->name[n]);
> @@ -767,6 +770,9 @@ static void check_reg_format(struct check *c, struct dt_info *dti,
>                 return;
>         }
>
> +       if (streq(node->parent->name, "__overlay__"))

Move this to a helper: is_overlay_node(node->parent)

> +               return;
> +
>         if (prop->val.len == 0)
>                 FAIL_PROP(c, dti, node, prop, "property is empty");
>
> @@ -1197,6 +1203,10 @@ static void check_avoid_default_addr_size(struct check *c, struct dt_info *dti,
>         if (!node->parent)
>                 return; /* Ignore root node */
>
> +

Extra blank line.

> +       if (streq(node->parent->name, "__overlay__"))
> +               return;
> +
>         reg = get_property(node, "reg");
>         ranges = get_property(node, "ranges");
>
> --
> 2.18.0
>

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

end of thread, other threads:[~2023-02-01 20:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-11  2:34 [PATCH] checks: Suppress warnings on overlay fragments Qun-Wei Lin
     [not found] ` <20230111023417.24141-1-qun-wei.lin-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
2023-02-01 11:23   ` Qun-wei Lin (林群崴)
2023-02-01 20:29   ` Rob Herring

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 read-only IMAP folder(s) and NNTP newsgroup(s).