Thread (27 messages) 27 messages, 9 authors, 2026-02-23

Re: [PATCH 3/8] base: soc: export soc_device_get_machine()

From: Geert Uytterhoeven <geert@linux-m68k.org>
Date: 2026-01-19 19:23:34
Also in: imx, linux-arm-kernel, linux-devicetree, linux-renesas-soc, linux-sunxi, lkml

Hi Bartosz,

On Mon, 19 Jan 2026 at 11:40, Bartosz Golaszewski
[off-list ref] wrote:
Some SoC drivers reimplement the functionality of
soc_device_get_machine(). Make this function accessible through the
sys_soc.h header. Rework it slightly to return a negative error number
on failure to read the machine string (SoC core can keep on ignoring
it). While at it: make it use the __free() helper from cleanup.h.

Signed-off-by: Bartosz Golaszewski <redacted>
Thanks for your patch!
quoted hunk ↗ jump to hunk
--- a/drivers/base/soc.c
+++ b/drivers/base/soc.c
@@ -5,6 +5,7 @@
  * Author: Lee Jones <lee.jones@linaro.org> for ST-Ericsson.
  */

+#include <linux/cleanup.h>
 #include <linux/err.h>
 #include <linux/glob.h>
 #include <linux/idr.h>
@@ -111,17 +112,18 @@ static void soc_release(struct device *dev)
        kfree(soc_dev);
 }

-static void soc_device_get_machine(struct soc_device_attribute *soc_dev_attr)
+int soc_device_get_machine(struct soc_device_attribute *soc_dev_attr)
 {
-       struct device_node *np;
-
        if (soc_dev_attr->machine)
-               return;
+               return -EBUSY;
+
+       struct device_node *np __free(device_node) = of_find_node_by_path("/");
+       if (!np)
+               return -ENOENT;

-       np = of_find_node_by_path("/");
-       of_property_read_string(np, "model", &soc_dev_attr->machine);
-       of_node_put(np);
+       return of_property_read_string(np, "model", &soc_dev_attr->machine);
I am not so fond of these of_find_node_by_path("/") + something replacements.
What about adding an of_machine_get_model() helper?
 }
+EXPORT_SYMBOL_GPL(soc_device_get_machine);

 static struct soc_device_attribute *early_soc_dev_attr;
Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help