[PATCH v2] checks: Suppress warnings on overlay fragments

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



The overlay fragment is a special 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@xxxxxxxxxxxx>
---
V1 -> V2:
 - Add is_overlay_node() helper
 - Skip anything starting with "__" in check_node_name_chars_strict()

 checks.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/checks.c b/checks.c
index 69f2649..637c6da 100644
--- a/checks.c
+++ b/checks.c
@@ -151,6 +151,11 @@ static bool is_multiple_of(int multiple, int divisor)
 		return (multiple % divisor) == 0;
 }
 
+static bool is_overlay_node(struct node *node)
+{
+	return streq(node->name, "__overlay__");
+}
+
 static bool run_check(struct check *c, struct dt_info *dti)
 {
 	struct node *dt = dti->dt;
@@ -325,6 +330,13 @@ static void check_node_name_chars_strict(struct check *c, struct dt_info *dti,
 {
 	int n = strspn(node->name, c->data);
 
+	/*
+	 * Do not check __overlay__, __fixups__, __local_fixups__, etc.
+	 * These node names starting with "__" are automatically generated by DTC.
+	 */
+	if (!strncmp(node->name, "__", 2))
+		return;
+
 	if (n < node->basenamelen)
 		FAIL(c, dti, node, "Character '%c' not recommended in node name",
 		     node->name[n]);
@@ -767,6 +779,9 @@ static void check_reg_format(struct check *c, struct dt_info *dti,
 		return;
 	}
 
+	if (is_overlay_node(node->parent))
+		return;
+
 	if (prop->val.len == 0)
 		FAIL_PROP(c, dti, node, prop, "property is empty");
 
@@ -1197,6 +1212,9 @@ static void check_avoid_default_addr_size(struct check *c, struct dt_info *dti,
 	if (!node->parent)
 		return; /* Ignore root node */
 
+	if (is_overlay_node(node->parent))
+		return;
+
 	reg = get_property(node, "reg");
 	ranges = get_property(node, "ranges");
 
-- 
2.18.0




[Index of Archives]     [Device Tree]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux