Thread (24 messages) flat view 24 messages, 8 authors, 2026-04-27

Re: [PATCH v2 8/9] soc: renesas: don't access of_root directly

From: Bartosz Golaszewski <brgl@kernel.org>
Date: 2026-03-02 17:18:21
Also in: driver-core, imx, linux-arm-kernel, linux-devicetree, linux-renesas-soc, linux-sunxi, lkml

On Mon, Mar 2, 2026 at 5:47 PM Geert Uytterhoeven [off-list ref] wrote:
Hi Bartosz,

On Mon, 23 Feb 2026 at 14:38, Bartosz Golaszewski
[off-list ref] wrote:
quoted
Don't access of_root directly as it reduces the build test coverage for
this driver with COMPILE_TEST=y and OF=n. Use existing helper functions
to retrieve the relevant information.

Suggested-by: Rob Herring <robh@kernel.org>
Signed-off-by: Bartosz Golaszewski <redacted>
quoted
--- a/drivers/soc/renesas/renesas-soc.c
+++ b/drivers/soc/renesas/renesas-soc.c
quoted
@@ -468,7 +469,11 @@ static int __init renesas_soc_init(void)
        const char *soc_id;
        int ret;

-       match = of_match_node(renesas_socs, of_root);
+       struct device_node *root __free(device_node) = of_find_node_by_path("/");
+       if (!root)
+               return -ENOENT;
+
+       match = of_match_node(renesas_socs, root);
        if (!match)
                return -ENODEV;
I still find it silly to add a call to of_find_node_by_path().
In your reply to my comment on v1, you said you don't want to add
another helper.

Currently we have two helpers in this area:
  1. of_machine_device_match(), which returns bool, and tells if a
     match is available,
  2. of_machine_get_match_data(), which returns the match data, if a
     match is available.
But there is no helper to return the actual match?
of_machine_device_match() would be fine, if it wouldn't cast the result
to bool...

As there is no cost (binary size-wise) in having the helper that returns
the match, too, I have sent a series[1] to do that. The last patch[2]
is an alternative to this patch, avoiding the need to add a call to
of_find_node_by_path().

[1] "[PATCH 0/7] of: Add and use of_machine_get_match() helper"
    https://lore.kernel.org/cover.1772468323.git.geert+renesas@glider.be (local)
[2] "[PATCH 7/7] soc: renesas: Convert to of_machine_get_match()"
    https://lore.kernel.org/10876b30a8bdb7d1cfcc2f23fb859f2ffea335fe.1772468323.git.geert+renesas@glider.be (local)
Sure, I'm fine with this patch being dropped and your series queued instead.

Bart
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help