]> www.infradead.org Git - users/willy/xarray.git/commitdiff
of: Introduce and apply private is_pseudo_property()
authorZijun Hu <quic_zijuhu@quicinc.com>
Mon, 24 Feb 2025 14:27:58 +0000 (22:27 +0800)
committerRob Herring (Arm) <robh@kernel.org>
Tue, 25 Feb 2025 14:43:00 +0000 (08:43 -0600)
There are several places which check if a property name is one of
'name'|'phandle'|'linux,phandle'.

Introduce and apply private is_pseudo_property() for the check.

Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
Link: https://lore.kernel.org/r/20250224-of_bugfix-v1-2-03640ae8c3a6@quicinc.com
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
drivers/of/base.c
drivers/of/of_private.h
drivers/of/overlay.c
drivers/of/resolver.c

index d2d41601136bc8ee2b97e31b83af1b361ba03261..001ff6ce4abf85c07f13649d5a9f691f549a8ccc 100644 (file)
@@ -1855,9 +1855,7 @@ void of_alias_scan(void * (*dt_alloc)(u64 size, u64 align))
                int id, len;
 
                /* Skip those we do not want to proceed */
-               if (!of_prop_cmp(pp->name, "name") ||
-                   !of_prop_cmp(pp->name, "phandle") ||
-                   !of_prop_cmp(pp->name, "linux,phandle"))
+               if (is_pseudo_property(pp->name))
                        continue;
 
                np = of_find_node_by_path(pp->value);
index f3e1193c8ded4899f39677a76da073e2266a1b9a..b0c077867bf4abc045ca332ebacb988cdead90fc 100644 (file)
@@ -208,4 +208,11 @@ static void __maybe_unused of_dump_addr(const char *s, const __be32 *addr, int n
 static void __maybe_unused of_dump_addr(const char *s, const __be32 *addr, int na) { }
 #endif
 
+static inline bool is_pseudo_property(const char *prop_name)
+{
+       return !of_prop_cmp(prop_name, "name") ||
+               !of_prop_cmp(prop_name, "phandle") ||
+               !of_prop_cmp(prop_name, "linux,phandle");
+}
+
 #endif /* _LINUX_OF_PRIVATE_H */
index 434f6dd6a86c1ffad2b0d490b2b612a5147994c5..5a51c52b9729af2ab77b5a9365cb72d30740f3b0 100644 (file)
@@ -304,9 +304,7 @@ static int add_changeset_property(struct overlay_changeset *ovcs,
        int ret = 0;
 
        if (target->in_livetree)
-               if (!of_prop_cmp(overlay_prop->name, "name") ||
-                   !of_prop_cmp(overlay_prop->name, "phandle") ||
-                   !of_prop_cmp(overlay_prop->name, "linux,phandle"))
+               if (is_pseudo_property(overlay_prop->name))
                        return 0;
 
        if (target->in_livetree)
index 2caad365a665c3cd268c66e014b1841b140e8c64..86424e14591990b76f0ef7dcadb6dcd118e8f80f 100644 (file)
@@ -161,9 +161,7 @@ static int adjust_local_phandle_references(const struct device_node *local_fixup
        for_each_property_of_node(local_fixups, prop_fix) {
 
                /* skip properties added automatically */
-               if (!of_prop_cmp(prop_fix->name, "name") ||
-                   !of_prop_cmp(prop_fix->name, "phandle") ||
-                   !of_prop_cmp(prop_fix->name, "linux,phandle"))
+               if (is_pseudo_property(prop_fix->name))
                        continue;
 
                if ((prop_fix->length % 4) != 0 || prop_fix->length == 0)