of: base: Improve argument length mismatch error
authorBaruch Siach <baruch@tkos.co.il>
Thu, 30 Dec 2021 16:31:53 +0000 (18:31 +0200)
committerRob Herring <robh@kernel.org>
Sat, 8 Jan 2022 14:50:39 +0000 (08:50 -0600)
The cells_name field of of_phandle_iterator might be NULL. Use the
phandle name instead. With this change instead of:

  OF: /soc/pinctrl@1000000: (null) = 3 found 2

We get:

  OF: /soc/pinctrl@1000000: phandle pinctrl@1000000 needs 3, found 2

Which is a more helpful messages making DT debugging easier.

In this particular example the phandle name looks like duplicate of the
same node name. But note that the first node is the parent node
(it->parent), while the second is the phandle target (it->node). They
happen to be the same in the case that triggered this improvement. See
commit 72cb4c48a46a ("arm64: dts: qcom: ipq6018: Fix gpio-ranges
property").

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/f6a68e0088a552ea9dfd4d8e3b5b586d92594738.1640881913.git.baruch@tkos.co.il
drivers/of/base.c

index 81c890912418b5217d052fdb4ecfac102638e89b..8a24d37153b45de3749784fd1ff2003a0bc98f32 100644 (file)
@@ -1376,9 +1376,14 @@ int of_phandle_iterator_next(struct of_phandle_iterator *it)
                 * property data length
                 */
                if (it->cur + count > it->list_end) {
-                       pr_err("%pOF: %s = %d found %td\n",
-                              it->parent, it->cells_name,
-                              count, it->list_end - it->cur);
+                       if (it->cells_name)
+                               pr_err("%pOF: %s = %d found %td\n",
+                                       it->parent, it->cells_name,
+                                       count, it->list_end - it->cur);
+                       else
+                               pr_err("%pOF: phandle %s needs %d, found %td\n",
+                                       it->parent, of_node_full_name(it->node),
+                                       count, it->list_end - it->cur);
                        goto err;
                }
        }