public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/8] soc: remove direct accesses to of_root from drivers/soc/
@ 2026-01-19 10:40 Bartosz Golaszewski
  2026-01-19 10:40 ` [PATCH 1/8] of: provide of_machine_get_compatible() Bartosz Golaszewski
                   ` (7 more replies)
  0 siblings, 8 replies; 27+ messages in thread
From: Bartosz Golaszewski @ 2026-01-19 10:40 UTC (permalink / raw)
  To: Rob Herring, Saravana Kannan, Greg Kroah-Hartman,
	Rafael J. Wysocki, Danilo Krummrich, Christophe Leroy (CS GROUP),
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Geert Uytterhoeven, Magnus Damm, Chen-Yu Tsai, Jernej Skrabec,
	Samuel Holland
  Cc: devicetree, linux-kernel, linuxppc-dev, linux-arm-kernel, imx,
	linux-renesas-soc, linux-sunxi, Bartosz Golaszewski

linux/of.h declares a set of variables providing addresses of certain
key OF nodes. The pointers being variables can't profit from stubs
provided for when CONFIG_OF is disabled which means that drivers
accessing these variables can't profit from CONFIG_COMPILE_TEST=y
coverage.

There are drivers under drivers/soc/ that access the of_root node. This
series introduces a new OF helper for reading the machine compatible
string, exports an existing SoC helper that reads the machine string
from the root node and finally replaces all direct accesses to of_root
with new or already existing helper functions.

Merging strategy: other than patch 1, everything else can go via the SoC
tree. I suggest Rob taking patch 1 for v7.0 through the OF tree and the
rest can be picked up after v7.0-rc1 is tagged.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
Bartosz Golaszewski (8):
      of: provide of_machine_get_compatible()
      base: soc: order includes alphabetically
      base: soc: export soc_device_get_machine()
      soc: fsl: guts: don't access of_root directly
      soc: imx8m: don't access of_root directly
      soc: imx9: don't access of_root directly
      soc: renesas: don't access of_root directly
      soc: sunxi: mbus: don't access of_root directly

 drivers/base/soc.c                | 26 ++++++++++++++------------
 drivers/of/base.c                 | 13 +++++++++++++
 drivers/soc/fsl/guts.c            | 12 +++---------
 drivers/soc/imx/soc-imx8m.c       | 11 +++--------
 drivers/soc/imx/soc-imx9.c        |  4 ++--
 drivers/soc/renesas/renesas-soc.c |  7 ++++++-
 drivers/soc/sunxi/sunxi_mbus.c    |  2 +-
 include/linux/of.h                |  2 ++
 include/linux/sys_soc.h           | 10 ++++++++++
 9 files changed, 54 insertions(+), 33 deletions(-)
---
base-commit: 46fe65a2c28ecf5df1a7475aba1f08ccf4c0ac1b
change-id: 20260119-soc-of-root-77c86c54010f

Best regards,
-- 
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH 1/8] of: provide of_machine_get_compatible()
  2026-01-19 10:40 [PATCH 0/8] soc: remove direct accesses to of_root from drivers/soc/ Bartosz Golaszewski
@ 2026-01-19 10:40 ` Bartosz Golaszewski
  2026-01-19 11:06   ` Christophe Leroy (CS GROUP)
                     ` (2 more replies)
  2026-01-19 10:40 ` [PATCH 2/8] base: soc: order includes alphabetically Bartosz Golaszewski
                   ` (6 subsequent siblings)
  7 siblings, 3 replies; 27+ messages in thread
From: Bartosz Golaszewski @ 2026-01-19 10:40 UTC (permalink / raw)
  To: Rob Herring, Saravana Kannan, Greg Kroah-Hartman,
	Rafael J. Wysocki, Danilo Krummrich, Christophe Leroy (CS GROUP),
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Geert Uytterhoeven, Magnus Damm, Chen-Yu Tsai, Jernej Skrabec,
	Samuel Holland
  Cc: devicetree, linux-kernel, linuxppc-dev, linux-arm-kernel, imx,
	linux-renesas-soc, linux-sunxi, Bartosz Golaszewski

Provide a helper function allowing users to read the compatible string
of the machine, hiding the access to the root node.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
 drivers/of/base.c  | 13 +++++++++++++
 include/linux/of.h |  2 ++
 2 files changed, 15 insertions(+)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index 0b65039ece53aa90f30da2420a893a02ab4c6dd8..a7e27d5355929abd6d156b80c52f8f8b08fe6da1 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -434,6 +434,19 @@ bool of_machine_compatible_match(const char *const *compats)
 }
 EXPORT_SYMBOL(of_machine_compatible_match);
 
+/**
+ * of_machine_get_compatible - Get the compatible string of this machine
+ * @compatible: address at which the compatible string will be stored
+ *
+ * Returns:
+ * 0 on success, negative error number on failure.
+ */
+int of_machine_get_compatible(const char **compatible)
+{
+	return of_property_read_string(of_root, "compatible", compatible);
+}
+EXPORT_SYMBOL_GPL(of_machine_get_compatible);
+
 /**
  * of_machine_device_match - Test root of device tree against a of_device_id array
  * @matches:	NULL terminated array of of_device_id match structures to search in
diff --git a/include/linux/of.h b/include/linux/of.h
index 9bbdcf25a2b448ba4ec5ddee8b35a105ca4aab8b..75423fb556ee4c108ce25144a0bdc252a89f7d1d 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -426,6 +426,8 @@ static inline bool of_machine_is_compatible(const char *compat)
 	return of_machine_compatible_match(compats);
 }
 
+int of_machine_get_compatible(const char **compatible);
+
 extern int of_add_property(struct device_node *np, struct property *prop);
 extern int of_remove_property(struct device_node *np, struct property *prop);
 extern int of_update_property(struct device_node *np, struct property *newprop);

-- 
2.47.3


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 2/8] base: soc: order includes alphabetically
  2026-01-19 10:40 [PATCH 0/8] soc: remove direct accesses to of_root from drivers/soc/ Bartosz Golaszewski
  2026-01-19 10:40 ` [PATCH 1/8] of: provide of_machine_get_compatible() Bartosz Golaszewski
@ 2026-01-19 10:40 ` Bartosz Golaszewski
  2026-01-19 11:07   ` Christophe Leroy (CS GROUP)
  2026-01-19 10:40 ` [PATCH 3/8] base: soc: export soc_device_get_machine() Bartosz Golaszewski
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 27+ messages in thread
From: Bartosz Golaszewski @ 2026-01-19 10:40 UTC (permalink / raw)
  To: Rob Herring, Saravana Kannan, Greg Kroah-Hartman,
	Rafael J. Wysocki, Danilo Krummrich, Christophe Leroy (CS GROUP),
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Geert Uytterhoeven, Magnus Damm, Chen-Yu Tsai, Jernej Skrabec,
	Samuel Holland
  Cc: devicetree, linux-kernel, linuxppc-dev, linux-arm-kernel, imx,
	linux-renesas-soc, linux-sunxi, Bartosz Golaszewski

For easier readability and maintenance, order the included headers
alphabetically.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
 drivers/base/soc.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/base/soc.c b/drivers/base/soc.c
index 282c38aece0de88049dc1e6e9bea00df52bed1ea..6f42632d2b0fcc8a729484e6ad270f9bcabe4a0b 100644
--- a/drivers/base/soc.c
+++ b/drivers/base/soc.c
@@ -5,16 +5,16 @@
  * Author: Lee Jones <lee.jones@linaro.org> for ST-Ericsson.
  */
 
-#include <linux/sysfs.h>
+#include <linux/err.h>
+#include <linux/glob.h>
+#include <linux/idr.h>
 #include <linux/init.h>
 #include <linux/of.h>
-#include <linux/stat.h>
 #include <linux/slab.h>
-#include <linux/idr.h>
 #include <linux/spinlock.h>
+#include <linux/stat.h>
+#include <linux/sysfs.h>
 #include <linux/sys_soc.h>
-#include <linux/err.h>
-#include <linux/glob.h>
 
 static DEFINE_IDA(soc_ida);
 

-- 
2.47.3


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 3/8] base: soc: export soc_device_get_machine()
  2026-01-19 10:40 [PATCH 0/8] soc: remove direct accesses to of_root from drivers/soc/ Bartosz Golaszewski
  2026-01-19 10:40 ` [PATCH 1/8] of: provide of_machine_get_compatible() Bartosz Golaszewski
  2026-01-19 10:40 ` [PATCH 2/8] base: soc: order includes alphabetically Bartosz Golaszewski
@ 2026-01-19 10:40 ` Bartosz Golaszewski
  2026-01-19 11:08   ` Christophe Leroy (CS GROUP)
                     ` (2 more replies)
  2026-01-19 10:40 ` [PATCH 4/8] soc: fsl: guts: don't access of_root directly Bartosz Golaszewski
                   ` (4 subsequent siblings)
  7 siblings, 3 replies; 27+ messages in thread
From: Bartosz Golaszewski @ 2026-01-19 10:40 UTC (permalink / raw)
  To: Rob Herring, Saravana Kannan, Greg Kroah-Hartman,
	Rafael J. Wysocki, Danilo Krummrich, Christophe Leroy (CS GROUP),
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Geert Uytterhoeven, Magnus Damm, Chen-Yu Tsai, Jernej Skrabec,
	Samuel Holland
  Cc: devicetree, linux-kernel, linuxppc-dev, linux-arm-kernel, imx,
	linux-renesas-soc, linux-sunxi, Bartosz Golaszewski

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 <bartosz.golaszewski@oss.qualcomm.com>
---
 drivers/base/soc.c      | 16 +++++++++-------
 include/linux/sys_soc.h | 10 ++++++++++
 2 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/drivers/base/soc.c b/drivers/base/soc.c
index 6f42632d2b0fcc8a729484e6ad270f9bcabe4a0b..bec8771d40f0590d4d7c3985c08fedfd4043a394 100644
--- 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);
 }
+EXPORT_SYMBOL_GPL(soc_device_get_machine);
 
 static struct soc_device_attribute *early_soc_dev_attr;
 
diff --git a/include/linux/sys_soc.h b/include/linux/sys_soc.h
index d9b3cf0f410c8cfb509a4c1a4d6c83fde6fe33c6..2d2dbc18462a39ddee95e38826a769fab089026f 100644
--- a/include/linux/sys_soc.h
+++ b/include/linux/sys_soc.h
@@ -37,6 +37,16 @@ void soc_device_unregister(struct soc_device *soc_dev);
  */
 struct device *soc_device_to_device(struct soc_device *soc);
 
+/**
+ * soc_device_get_machine - retrieve the machine model and store it in
+ *                          the soc_device_attribute structure
+ * @soc_dev_attr: SoC attribute structure to store the model in
+ *
+ * Returns:
+ * 0 on success, negative error number on failure.
+ */
+int soc_device_get_machine(struct soc_device_attribute *soc_dev_attr);
+
 #ifdef CONFIG_SOC_BUS
 const struct soc_device_attribute *soc_device_match(
 	const struct soc_device_attribute *matches);

-- 
2.47.3


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 4/8] soc: fsl: guts: don't access of_root directly
  2026-01-19 10:40 [PATCH 0/8] soc: remove direct accesses to of_root from drivers/soc/ Bartosz Golaszewski
                   ` (2 preceding siblings ...)
  2026-01-19 10:40 ` [PATCH 3/8] base: soc: export soc_device_get_machine() Bartosz Golaszewski
@ 2026-01-19 10:40 ` Bartosz Golaszewski
  2026-01-19 11:05   ` LEROY Christophe
  2026-01-19 11:06   ` Christophe Leroy (CS GROUP)
  2026-01-19 10:40 ` [PATCH 5/8] soc: imx8m: " Bartosz Golaszewski
                   ` (3 subsequent siblings)
  7 siblings, 2 replies; 27+ messages in thread
From: Bartosz Golaszewski @ 2026-01-19 10:40 UTC (permalink / raw)
  To: Rob Herring, Saravana Kannan, Greg Kroah-Hartman,
	Rafael J. Wysocki, Danilo Krummrich, Christophe Leroy (CS GROUP),
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Geert Uytterhoeven, Magnus Damm, Chen-Yu Tsai, Jernej Skrabec,
	Samuel Holland
  Cc: devicetree, linux-kernel, linuxppc-dev, linux-arm-kernel, imx,
	linux-renesas-soc, linux-sunxi, Bartosz Golaszewski

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 <bartosz.golaszewski@oss.qualcomm.com>
---
 drivers/soc/fsl/guts.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/soc/fsl/guts.c b/drivers/soc/fsl/guts.c
index 6bf3e6a980ffc67c21ed7b62b5b638e37f27454e..88ba32a40f6a27f8ffd13624e940aa0edf48586f 100644
--- a/drivers/soc/fsl/guts.c
+++ b/drivers/soc/fsl/guts.c
@@ -186,7 +186,6 @@ static int __init fsl_guts_init(void)
 	const struct fsl_soc_data *soc_data;
 	const struct of_device_id *match;
 	struct ccsr_guts __iomem *regs;
-	const char *machine = NULL;
 	struct device_node *np;
 	bool little_endian;
 	u64 soc_uid = 0;
@@ -217,13 +216,9 @@ static int __init fsl_guts_init(void)
 	if (!soc_dev_attr)
 		return -ENOMEM;
 
-	if (of_property_read_string(of_root, "model", &machine))
-		of_property_read_string_index(of_root, "compatible", 0, &machine);
-	if (machine) {
-		soc_dev_attr->machine = kstrdup(machine, GFP_KERNEL);
-		if (!soc_dev_attr->machine)
-			goto err_nomem;
-	}
+	ret = soc_device_get_machine(soc_dev_attr);
+	if (ret)
+		of_machine_get_compatible(&soc_dev_attr->machine);
 
 	soc_die = fsl_soc_die_match(svr, fsl_soc_die);
 	if (soc_die) {
@@ -267,7 +262,6 @@ static int __init fsl_guts_init(void)
 err_nomem:
 	ret = -ENOMEM;
 err:
-	kfree(soc_dev_attr->machine);
 	kfree(soc_dev_attr->family);
 	kfree(soc_dev_attr->soc_id);
 	kfree(soc_dev_attr->revision);

-- 
2.47.3


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 5/8] soc: imx8m: don't access of_root directly
  2026-01-19 10:40 [PATCH 0/8] soc: remove direct accesses to of_root from drivers/soc/ Bartosz Golaszewski
                   ` (3 preceding siblings ...)
  2026-01-19 10:40 ` [PATCH 4/8] soc: fsl: guts: don't access of_root directly Bartosz Golaszewski
@ 2026-01-19 10:40 ` Bartosz Golaszewski
  2026-01-19 10:40 ` [PATCH 6/8] soc: imx9: " Bartosz Golaszewski
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 27+ messages in thread
From: Bartosz Golaszewski @ 2026-01-19 10:40 UTC (permalink / raw)
  To: Rob Herring, Saravana Kannan, Greg Kroah-Hartman,
	Rafael J. Wysocki, Danilo Krummrich, Christophe Leroy (CS GROUP),
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Geert Uytterhoeven, Magnus Damm, Chen-Yu Tsai, Jernej Skrabec,
	Samuel Holland
  Cc: devicetree, linux-kernel, linuxppc-dev, linux-arm-kernel, imx,
	linux-renesas-soc, linux-sunxi, Bartosz Golaszewski

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 <bartosz.golaszewski@oss.qualcomm.com>
---
 drivers/soc/imx/soc-imx8m.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/soc/imx/soc-imx8m.c b/drivers/soc/imx/soc-imx8m.c
index 04a1b60f2f2b52cc374714f9a1205496c1762f39..925a9aed756103a5a74d5d840b54a2179cd78061 100644
--- a/drivers/soc/imx/soc-imx8m.c
+++ b/drivers/soc/imx/soc-imx8m.c
@@ -222,7 +222,6 @@ static int imx8m_soc_probe(struct platform_device *pdev)
 	const struct imx8_soc_data *data;
 	struct imx8_soc_drvdata *drvdata;
 	struct device *dev = &pdev->dev;
-	const struct of_device_id *id;
 	struct soc_device *soc_dev;
 	u32 soc_rev = 0;
 	u64 soc_uid[2] = {0, 0};
@@ -240,15 +239,11 @@ static int imx8m_soc_probe(struct platform_device *pdev)
 
 	soc_dev_attr->family = "Freescale i.MX";
 
-	ret = of_property_read_string(of_root, "model", &soc_dev_attr->machine);
+	ret = soc_device_get_machine(soc_dev_attr);
 	if (ret)
 		return ret;
 
-	id = of_match_node(imx8_soc_match, of_root);
-	if (!id)
-		return -ENODEV;
-
-	data = id->data;
+	data = device_get_match_data(dev);
 	if (data) {
 		soc_dev_attr->soc_id = data->name;
 		ret = imx8m_soc_prepare(pdev, data->ocotp_compatible);
@@ -322,7 +317,7 @@ static int __init imx8_soc_init(void)
 	int ret;
 
 	/* No match means this is non-i.MX8M hardware, do nothing. */
-	if (!of_match_node(imx8_soc_match, of_root))
+	if (!of_machine_device_match(imx8_soc_match))
 		return 0;
 
 	ret = platform_driver_register(&imx8m_soc_driver);

-- 
2.47.3


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 6/8] soc: imx9: don't access of_root directly
  2026-01-19 10:40 [PATCH 0/8] soc: remove direct accesses to of_root from drivers/soc/ Bartosz Golaszewski
                   ` (4 preceding siblings ...)
  2026-01-19 10:40 ` [PATCH 5/8] soc: imx8m: " Bartosz Golaszewski
@ 2026-01-19 10:40 ` Bartosz Golaszewski
  2026-01-27  2:39   ` Peng Fan
  2026-01-19 10:40 ` [PATCH 7/8] soc: renesas: " Bartosz Golaszewski
  2026-01-19 10:40 ` [PATCH 8/8] soc: sunxi: mbus: " Bartosz Golaszewski
  7 siblings, 1 reply; 27+ messages in thread
From: Bartosz Golaszewski @ 2026-01-19 10:40 UTC (permalink / raw)
  To: Rob Herring, Saravana Kannan, Greg Kroah-Hartman,
	Rafael J. Wysocki, Danilo Krummrich, Christophe Leroy (CS GROUP),
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Geert Uytterhoeven, Magnus Damm, Chen-Yu Tsai, Jernej Skrabec,
	Samuel Holland
  Cc: devicetree, linux-kernel, linuxppc-dev, linux-arm-kernel, imx,
	linux-renesas-soc, linux-sunxi, Bartosz Golaszewski

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 <bartosz.golaszewski@oss.qualcomm.com>
---
 drivers/soc/imx/soc-imx9.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/soc/imx/soc-imx9.c b/drivers/soc/imx/soc-imx9.c
index b46d22cf0212c3f40f61ec5be85ca11e5d3207ac..0cea4307ac3923f416a63bca793a78835d868448 100644
--- a/drivers/soc/imx/soc-imx9.c
+++ b/drivers/soc/imx/soc-imx9.c
@@ -29,7 +29,7 @@ static int imx9_soc_probe(struct platform_device *pdev)
 	if (!attr)
 		return -ENOMEM;
 
-	err = of_property_read_string(of_root, "model", &attr->machine);
+	err = soc_device_get_machine(attr);
 	if (err) {
 		pr_err("%s: missing model property: %d\n", __func__, err);
 		goto attr;
@@ -103,7 +103,7 @@ static int __init imx9_soc_init(void)
 	struct platform_device *pdev;
 
 	/* No match means it is not an i.MX 9 series SoC, do nothing. */
-	if (!of_match_node(imx9_soc_match, of_root))
+	if (!of_machine_device_match(imx9_soc_match))
 		return 0;
 
 	ret = platform_driver_register(&imx9_soc_driver);

-- 
2.47.3


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 7/8] soc: renesas: don't access of_root directly
  2026-01-19 10:40 [PATCH 0/8] soc: remove direct accesses to of_root from drivers/soc/ Bartosz Golaszewski
                   ` (5 preceding siblings ...)
  2026-01-19 10:40 ` [PATCH 6/8] soc: imx9: " Bartosz Golaszewski
@ 2026-01-19 10:40 ` Bartosz Golaszewski
  2026-01-19 19:25   ` Geert Uytterhoeven
  2026-01-19 10:40 ` [PATCH 8/8] soc: sunxi: mbus: " Bartosz Golaszewski
  7 siblings, 1 reply; 27+ messages in thread
From: Bartosz Golaszewski @ 2026-01-19 10:40 UTC (permalink / raw)
  To: Rob Herring, Saravana Kannan, Greg Kroah-Hartman,
	Rafael J. Wysocki, Danilo Krummrich, Christophe Leroy (CS GROUP),
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Geert Uytterhoeven, Magnus Damm, Chen-Yu Tsai, Jernej Skrabec,
	Samuel Holland
  Cc: devicetree, linux-kernel, linuxppc-dev, linux-arm-kernel, imx,
	linux-renesas-soc, linux-sunxi, Bartosz Golaszewski

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 <bartosz.golaszewski@oss.qualcomm.com>
---
 drivers/soc/renesas/renesas-soc.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/soc/renesas/renesas-soc.c b/drivers/soc/renesas/renesas-soc.c
index ee4f17bb4db45db7b96c782b770e5bb4eb139e09..7c54b39b9cdc6b070a7cb6c1c03cc1356bbf0309 100644
--- a/drivers/soc/renesas/renesas-soc.c
+++ b/drivers/soc/renesas/renesas-soc.c
@@ -6,6 +6,7 @@
  */
 
 #include <linux/bitfield.h>
+#include <linux/cleanup.h>
 #include <linux/io.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
@@ -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;
 

-- 
2.47.3


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 8/8] soc: sunxi: mbus: don't access of_root directly
  2026-01-19 10:40 [PATCH 0/8] soc: remove direct accesses to of_root from drivers/soc/ Bartosz Golaszewski
                   ` (6 preceding siblings ...)
  2026-01-19 10:40 ` [PATCH 7/8] soc: renesas: " Bartosz Golaszewski
@ 2026-01-19 10:40 ` Bartosz Golaszewski
  2026-01-19 15:36   ` Jernej Škrabec
  2026-01-20  7:55   ` Chen-Yu Tsai
  7 siblings, 2 replies; 27+ messages in thread
From: Bartosz Golaszewski @ 2026-01-19 10:40 UTC (permalink / raw)
  To: Rob Herring, Saravana Kannan, Greg Kroah-Hartman,
	Rafael J. Wysocki, Danilo Krummrich, Christophe Leroy (CS GROUP),
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Geert Uytterhoeven, Magnus Damm, Chen-Yu Tsai, Jernej Skrabec,
	Samuel Holland
  Cc: devicetree, linux-kernel, linuxppc-dev, linux-arm-kernel, imx,
	linux-renesas-soc, linux-sunxi, Bartosz Golaszewski

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 <bartosz.golaszewski@oss.qualcomm.com>
---
 drivers/soc/sunxi/sunxi_mbus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/soc/sunxi/sunxi_mbus.c b/drivers/soc/sunxi/sunxi_mbus.c
index 1734da357ca21b249740e089698275507ea98a8a..8bc5f62ff258837d3f3b30cb84b60d1872b31c27 100644
--- a/drivers/soc/sunxi/sunxi_mbus.c
+++ b/drivers/soc/sunxi/sunxi_mbus.c
@@ -118,7 +118,7 @@ static const char * const sunxi_mbus_platforms[] __initconst = {
 
 static int __init sunxi_mbus_init(void)
 {
-	if (!of_device_compatible_match(of_root, sunxi_mbus_platforms))
+	if (!of_machine_compatible_match(sunxi_mbus_platforms))
 		return 0;
 
 	bus_register_notifier(&platform_bus_type, &sunxi_mbus_nb);

-- 
2.47.3


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* Re: [PATCH 4/8] soc: fsl: guts: don't access of_root directly
  2026-01-19 10:40 ` [PATCH 4/8] soc: fsl: guts: don't access of_root directly Bartosz Golaszewski
@ 2026-01-19 11:05   ` LEROY Christophe
  2026-01-19 11:06   ` Christophe Leroy (CS GROUP)
  1 sibling, 0 replies; 27+ messages in thread
From: LEROY Christophe @ 2026-01-19 11:05 UTC (permalink / raw)
  To: Bartosz Golaszewski, Rob Herring, Saravana Kannan,
	Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich,
	Christophe Leroy (CS GROUP), Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Geert Uytterhoeven,
	Magnus Damm, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland
  Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linuxppc-dev@lists.ozlabs.org,
	linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev,
	linux-renesas-soc@vger.kernel.org, linux-sunxi@lists.linux.dev



Le 19/01/2026 à 11:40, Bartosz Golaszewski a écrit :
> 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 <bartosz.golaszewski@oss.qualcomm.com>

Reviewed-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>
Acked-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>

> ---
>   drivers/soc/fsl/guts.c | 12 +++---------
>   1 file changed, 3 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/soc/fsl/guts.c b/drivers/soc/fsl/guts.c
> index 6bf3e6a980ffc67c21ed7b62b5b638e37f27454e..88ba32a40f6a27f8ffd13624e940aa0edf48586f 100644
> --- a/drivers/soc/fsl/guts.c
> +++ b/drivers/soc/fsl/guts.c
> @@ -186,7 +186,6 @@ static int __init fsl_guts_init(void)
>   	const struct fsl_soc_data *soc_data;
>   	const struct of_device_id *match;
>   	struct ccsr_guts __iomem *regs;
> -	const char *machine = NULL;
>   	struct device_node *np;
>   	bool little_endian;
>   	u64 soc_uid = 0;
> @@ -217,13 +216,9 @@ static int __init fsl_guts_init(void)
>   	if (!soc_dev_attr)
>   		return -ENOMEM;
>   
> -	if (of_property_read_string(of_root, "model", &machine))
> -		of_property_read_string_index(of_root, "compatible", 0, &machine);
> -	if (machine) {
> -		soc_dev_attr->machine = kstrdup(machine, GFP_KERNEL);
> -		if (!soc_dev_attr->machine)
> -			goto err_nomem;
> -	}
> +	ret = soc_device_get_machine(soc_dev_attr);
> +	if (ret)
> +		of_machine_get_compatible(&soc_dev_attr->machine);
>   
>   	soc_die = fsl_soc_die_match(svr, fsl_soc_die);
>   	if (soc_die) {
> @@ -267,7 +262,6 @@ static int __init fsl_guts_init(void)
>   err_nomem:
>   	ret = -ENOMEM;
>   err:
> -	kfree(soc_dev_attr->machine);
>   	kfree(soc_dev_attr->family);
>   	kfree(soc_dev_attr->soc_id);
>   	kfree(soc_dev_attr->revision);
> 


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 4/8] soc: fsl: guts: don't access of_root directly
  2026-01-19 10:40 ` [PATCH 4/8] soc: fsl: guts: don't access of_root directly Bartosz Golaszewski
  2026-01-19 11:05   ` LEROY Christophe
@ 2026-01-19 11:06   ` Christophe Leroy (CS GROUP)
  1 sibling, 0 replies; 27+ messages in thread
From: Christophe Leroy (CS GROUP) @ 2026-01-19 11:06 UTC (permalink / raw)
  To: Bartosz Golaszewski, Rob Herring, Saravana Kannan,
	Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Geert Uytterhoeven, Magnus Damm, Chen-Yu Tsai, Jernej Skrabec,
	Samuel Holland
  Cc: devicetree, linux-kernel, linuxppc-dev, linux-arm-kernel, imx,
	linux-renesas-soc, linux-sunxi



Le 19/01/2026 à 11:40, Bartosz Golaszewski a écrit :
> 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 <bartosz.golaszewski@oss.qualcomm.com>

Reviewed-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>
Acked-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>

> ---
>   drivers/soc/fsl/guts.c | 12 +++---------
>   1 file changed, 3 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/soc/fsl/guts.c b/drivers/soc/fsl/guts.c
> index 6bf3e6a980ffc67c21ed7b62b5b638e37f27454e..88ba32a40f6a27f8ffd13624e940aa0edf48586f 100644
> --- a/drivers/soc/fsl/guts.c
> +++ b/drivers/soc/fsl/guts.c
> @@ -186,7 +186,6 @@ static int __init fsl_guts_init(void)
>   	const struct fsl_soc_data *soc_data;
>   	const struct of_device_id *match;
>   	struct ccsr_guts __iomem *regs;
> -	const char *machine = NULL;
>   	struct device_node *np;
>   	bool little_endian;
>   	u64 soc_uid = 0;
> @@ -217,13 +216,9 @@ static int __init fsl_guts_init(void)
>   	if (!soc_dev_attr)
>   		return -ENOMEM;
>   
> -	if (of_property_read_string(of_root, "model", &machine))
> -		of_property_read_string_index(of_root, "compatible", 0, &machine);
> -	if (machine) {
> -		soc_dev_attr->machine = kstrdup(machine, GFP_KERNEL);
> -		if (!soc_dev_attr->machine)
> -			goto err_nomem;
> -	}
> +	ret = soc_device_get_machine(soc_dev_attr);
> +	if (ret)
> +		of_machine_get_compatible(&soc_dev_attr->machine);
>   
>   	soc_die = fsl_soc_die_match(svr, fsl_soc_die);
>   	if (soc_die) {
> @@ -267,7 +262,6 @@ static int __init fsl_guts_init(void)
>   err_nomem:
>   	ret = -ENOMEM;
>   err:
> -	kfree(soc_dev_attr->machine);
>   	kfree(soc_dev_attr->family);
>   	kfree(soc_dev_attr->soc_id);
>   	kfree(soc_dev_attr->revision);
> 


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 1/8] of: provide of_machine_get_compatible()
  2026-01-19 10:40 ` [PATCH 1/8] of: provide of_machine_get_compatible() Bartosz Golaszewski
@ 2026-01-19 11:06   ` Christophe Leroy (CS GROUP)
  2026-01-19 11:26   ` Danilo Krummrich
  2026-01-19 19:17   ` Geert Uytterhoeven
  2 siblings, 0 replies; 27+ messages in thread
From: Christophe Leroy (CS GROUP) @ 2026-01-19 11:06 UTC (permalink / raw)
  To: Bartosz Golaszewski, Rob Herring, Saravana Kannan,
	Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Geert Uytterhoeven, Magnus Damm, Chen-Yu Tsai, Jernej Skrabec,
	Samuel Holland
  Cc: devicetree, linux-kernel, linuxppc-dev, linux-arm-kernel, imx,
	linux-renesas-soc, linux-sunxi



Le 19/01/2026 à 11:40, Bartosz Golaszewski a écrit :
> Provide a helper function allowing users to read the compatible string
> of the machine, hiding the access to the root node.
> 
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>

Reviewed-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>

> ---
>   drivers/of/base.c  | 13 +++++++++++++
>   include/linux/of.h |  2 ++
>   2 files changed, 15 insertions(+)
> 
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index 0b65039ece53aa90f30da2420a893a02ab4c6dd8..a7e27d5355929abd6d156b80c52f8f8b08fe6da1 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -434,6 +434,19 @@ bool of_machine_compatible_match(const char *const *compats)
>   }
>   EXPORT_SYMBOL(of_machine_compatible_match);
>   
> +/**
> + * of_machine_get_compatible - Get the compatible string of this machine
> + * @compatible: address at which the compatible string will be stored
> + *
> + * Returns:
> + * 0 on success, negative error number on failure.
> + */
> +int of_machine_get_compatible(const char **compatible)
> +{
> +	return of_property_read_string(of_root, "compatible", compatible);
> +}
> +EXPORT_SYMBOL_GPL(of_machine_get_compatible);
> +
>   /**
>    * of_machine_device_match - Test root of device tree against a of_device_id array
>    * @matches:	NULL terminated array of of_device_id match structures to search in
> diff --git a/include/linux/of.h b/include/linux/of.h
> index 9bbdcf25a2b448ba4ec5ddee8b35a105ca4aab8b..75423fb556ee4c108ce25144a0bdc252a89f7d1d 100644
> --- a/include/linux/of.h
> +++ b/include/linux/of.h
> @@ -426,6 +426,8 @@ static inline bool of_machine_is_compatible(const char *compat)
>   	return of_machine_compatible_match(compats);
>   }
>   
> +int of_machine_get_compatible(const char **compatible);
> +
>   extern int of_add_property(struct device_node *np, struct property *prop);
>   extern int of_remove_property(struct device_node *np, struct property *prop);
>   extern int of_update_property(struct device_node *np, struct property *newprop);
> 


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 2/8] base: soc: order includes alphabetically
  2026-01-19 10:40 ` [PATCH 2/8] base: soc: order includes alphabetically Bartosz Golaszewski
@ 2026-01-19 11:07   ` Christophe Leroy (CS GROUP)
  0 siblings, 0 replies; 27+ messages in thread
From: Christophe Leroy (CS GROUP) @ 2026-01-19 11:07 UTC (permalink / raw)
  To: Bartosz Golaszewski, Rob Herring, Saravana Kannan,
	Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Geert Uytterhoeven, Magnus Damm, Chen-Yu Tsai, Jernej Skrabec,
	Samuel Holland
  Cc: devicetree, linux-kernel, linuxppc-dev, linux-arm-kernel, imx,
	linux-renesas-soc, linux-sunxi



Le 19/01/2026 à 11:40, Bartosz Golaszewski a écrit :
> For easier readability and maintenance, order the included headers
> alphabetically.
> 
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>

Reviewed-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>

> ---
>   drivers/base/soc.c | 10 +++++-----
>   1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/base/soc.c b/drivers/base/soc.c
> index 282c38aece0de88049dc1e6e9bea00df52bed1ea..6f42632d2b0fcc8a729484e6ad270f9bcabe4a0b 100644
> --- a/drivers/base/soc.c
> +++ b/drivers/base/soc.c
> @@ -5,16 +5,16 @@
>    * Author: Lee Jones <lee.jones@linaro.org> for ST-Ericsson.
>    */
>   
> -#include <linux/sysfs.h>
> +#include <linux/err.h>
> +#include <linux/glob.h>
> +#include <linux/idr.h>
>   #include <linux/init.h>
>   #include <linux/of.h>
> -#include <linux/stat.h>
>   #include <linux/slab.h>
> -#include <linux/idr.h>
>   #include <linux/spinlock.h>
> +#include <linux/stat.h>
> +#include <linux/sysfs.h>
>   #include <linux/sys_soc.h>
> -#include <linux/err.h>
> -#include <linux/glob.h>
>   
>   static DEFINE_IDA(soc_ida);
>   
> 


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 3/8] base: soc: export soc_device_get_machine()
  2026-01-19 10:40 ` [PATCH 3/8] base: soc: export soc_device_get_machine() Bartosz Golaszewski
@ 2026-01-19 11:08   ` Christophe Leroy (CS GROUP)
  2026-01-19 11:36   ` Danilo Krummrich
  2026-01-19 19:23   ` Geert Uytterhoeven
  2 siblings, 0 replies; 27+ messages in thread
From: Christophe Leroy (CS GROUP) @ 2026-01-19 11:08 UTC (permalink / raw)
  To: Bartosz Golaszewski, Rob Herring, Saravana Kannan,
	Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Geert Uytterhoeven, Magnus Damm, Chen-Yu Tsai, Jernej Skrabec,
	Samuel Holland
  Cc: devicetree, linux-kernel, linuxppc-dev, linux-arm-kernel, imx,
	linux-renesas-soc, linux-sunxi



Le 19/01/2026 à 11:40, Bartosz Golaszewski a écrit :
> 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 <bartosz.golaszewski@oss.qualcomm.com>

Reviewed-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>

> ---
>   drivers/base/soc.c      | 16 +++++++++-------
>   include/linux/sys_soc.h | 10 ++++++++++
>   2 files changed, 19 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/base/soc.c b/drivers/base/soc.c
> index 6f42632d2b0fcc8a729484e6ad270f9bcabe4a0b..bec8771d40f0590d4d7c3985c08fedfd4043a394 100644
> --- 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);
>   }
> +EXPORT_SYMBOL_GPL(soc_device_get_machine);
>   
>   static struct soc_device_attribute *early_soc_dev_attr;
>   
> diff --git a/include/linux/sys_soc.h b/include/linux/sys_soc.h
> index d9b3cf0f410c8cfb509a4c1a4d6c83fde6fe33c6..2d2dbc18462a39ddee95e38826a769fab089026f 100644
> --- a/include/linux/sys_soc.h
> +++ b/include/linux/sys_soc.h
> @@ -37,6 +37,16 @@ void soc_device_unregister(struct soc_device *soc_dev);
>    */
>   struct device *soc_device_to_device(struct soc_device *soc);
>   
> +/**
> + * soc_device_get_machine - retrieve the machine model and store it in
> + *                          the soc_device_attribute structure
> + * @soc_dev_attr: SoC attribute structure to store the model in
> + *
> + * Returns:
> + * 0 on success, negative error number on failure.
> + */
> +int soc_device_get_machine(struct soc_device_attribute *soc_dev_attr);
> +
>   #ifdef CONFIG_SOC_BUS
>   const struct soc_device_attribute *soc_device_match(
>   	const struct soc_device_attribute *matches);
> 


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 1/8] of: provide of_machine_get_compatible()
  2026-01-19 10:40 ` [PATCH 1/8] of: provide of_machine_get_compatible() Bartosz Golaszewski
  2026-01-19 11:06   ` Christophe Leroy (CS GROUP)
@ 2026-01-19 11:26   ` Danilo Krummrich
  2026-01-19 13:00     ` Bartosz Golaszewski
  2026-01-19 19:17   ` Geert Uytterhoeven
  2 siblings, 1 reply; 27+ messages in thread
From: Danilo Krummrich @ 2026-01-19 11:26 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Rob Herring, Saravana Kannan, Greg Kroah-Hartman,
	Rafael J. Wysocki, Christophe Leroy (CS GROUP), Shawn Guo,
	Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Geert Uytterhoeven, Magnus Damm, Chen-Yu Tsai, Jernej Skrabec,
	Samuel Holland, devicetree, linux-kernel, linuxppc-dev,
	linux-arm-kernel, imx, linux-renesas-soc, linux-sunxi

On Mon Jan 19, 2026 at 11:40 AM CET, Bartosz Golaszewski wrote:
> +/**
> + * of_machine_get_compatible - Get the compatible string of this machine
> + * @compatible: address at which the compatible string will be stored
> + *
> + * Returns:
> + * 0 on success, negative error number on failure.
> + */
> +int of_machine_get_compatible(const char **compatible)

I think the name of this function is not ideal. 'get' usually indicates that a
reference count will be taken, but this is not the case here.

I'm also not sure about the machine prefix. If we really want this helper I'd
suggest something along the lines of e.g. of_root_read_compatible().

> +{
> +	return of_property_read_string(of_root, "compatible", compatible);
> +}
> +EXPORT_SYMBOL_GPL(of_machine_get_compatible);

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 3/8] base: soc: export soc_device_get_machine()
  2026-01-19 10:40 ` [PATCH 3/8] base: soc: export soc_device_get_machine() Bartosz Golaszewski
  2026-01-19 11:08   ` Christophe Leroy (CS GROUP)
@ 2026-01-19 11:36   ` Danilo Krummrich
  2026-01-19 18:41     ` Danilo Krummrich
  2026-01-19 19:23   ` Geert Uytterhoeven
  2 siblings, 1 reply; 27+ messages in thread
From: Danilo Krummrich @ 2026-01-19 11:36 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Rob Herring, Saravana Kannan, Greg Kroah-Hartman,
	Rafael J. Wysocki, Christophe Leroy (CS GROUP), Shawn Guo,
	Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Geert Uytterhoeven, Magnus Damm, Chen-Yu Tsai, Jernej Skrabec,
	Samuel Holland, devicetree, linux-kernel, linuxppc-dev,
	linux-arm-kernel, imx, linux-renesas-soc, linux-sunxi

On Mon Jan 19, 2026 at 11:40 AM CET, Bartosz Golaszewski wrote:
> -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;

This should never fail at this point, no? Also, can't we just use of_root?

>  
> -	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);
>  }
> +EXPORT_SYMBOL_GPL(soc_device_get_machine);

If we want to export this, we shouldn't reuse the existing name, which is
misleading.

soc_device_get_machine() reads as if we return a reference count of something.
Additionally, it operates on struct soc_device_attribute instead of struct
soc_device, where the name suggests the latter.

Instead this should be soc_device_attribute_read_machine() or if we want a
shorter name, just soc_attr_read_machine().

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 1/8] of: provide of_machine_get_compatible()
  2026-01-19 11:26   ` Danilo Krummrich
@ 2026-01-19 13:00     ` Bartosz Golaszewski
  2026-01-19 13:20       ` Danilo Krummrich
  0 siblings, 1 reply; 27+ messages in thread
From: Bartosz Golaszewski @ 2026-01-19 13:00 UTC (permalink / raw)
  To: Danilo Krummrich
  Cc: Bartosz Golaszewski, Rob Herring, Saravana Kannan,
	Greg Kroah-Hartman, Rafael J. Wysocki,
	Christophe Leroy (CS GROUP), Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Geert Uytterhoeven,
	Magnus Damm, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland,
	devicetree, linux-kernel, linuxppc-dev, linux-arm-kernel, imx,
	linux-renesas-soc, linux-sunxi

On Mon, Jan 19, 2026 at 12:26 PM Danilo Krummrich <dakr@kernel.org> wrote:
>
> On Mon Jan 19, 2026 at 11:40 AM CET, Bartosz Golaszewski wrote:
> > +/**
> > + * of_machine_get_compatible - Get the compatible string of this machine
> > + * @compatible: address at which the compatible string will be stored
> > + *
> > + * Returns:
> > + * 0 on success, negative error number on failure.
> > + */
> > +int of_machine_get_compatible(const char **compatible)
>
> I think the name of this function is not ideal. 'get' usually indicates that a
> reference count will be taken, but this is not the case here.
>
> I'm also not sure about the machine prefix. If we really want this helper I'd
> suggest something along the lines of e.g. of_root_read_compatible().
>

Makes sense for the "read" part but I'm not sure about the "root" bit.
We already have a whole set of "of_machine_" interfaces, like
of_machine_is_compatible().

How about of_machine_read_compatible()?

Bartosz

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 1/8] of: provide of_machine_get_compatible()
  2026-01-19 13:00     ` Bartosz Golaszewski
@ 2026-01-19 13:20       ` Danilo Krummrich
  0 siblings, 0 replies; 27+ messages in thread
From: Danilo Krummrich @ 2026-01-19 13:20 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Bartosz Golaszewski, Rob Herring, Saravana Kannan,
	Greg Kroah-Hartman, Rafael J. Wysocki,
	Christophe Leroy (CS GROUP), Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Geert Uytterhoeven,
	Magnus Damm, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland,
	devicetree, linux-kernel, linuxppc-dev, linux-arm-kernel, imx,
	linux-renesas-soc, linux-sunxi

On Mon Jan 19, 2026 at 2:00 PM CET, Bartosz Golaszewski wrote:
> How about of_machine_read_compatible()?

SGTM.

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 8/8] soc: sunxi: mbus: don't access of_root directly
  2026-01-19 10:40 ` [PATCH 8/8] soc: sunxi: mbus: " Bartosz Golaszewski
@ 2026-01-19 15:36   ` Jernej Škrabec
  2026-01-20  7:55   ` Chen-Yu Tsai
  1 sibling, 0 replies; 27+ messages in thread
From: Jernej Škrabec @ 2026-01-19 15:36 UTC (permalink / raw)
  To: Rob Herring, Saravana Kannan, Greg Kroah-Hartman,
	Rafael J. Wysocki, Danilo Krummrich, Christophe Leroy (CS GROUP),
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Geert Uytterhoeven, Magnus Damm, Chen-Yu Tsai, Samuel Holland,
	Bartosz Golaszewski
  Cc: devicetree, linux-kernel, linuxppc-dev, linux-arm-kernel, imx,
	linux-renesas-soc, linux-sunxi, Bartosz Golaszewski

Dne ponedeljek, 19. januar 2026 ob 11:40:19 Srednjeevropski standardni čas je Bartosz Golaszewski napisal(a):
> 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 <bartosz.golaszewski@oss.qualcomm.com>

Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com>

Best regards,
Jernej



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 3/8] base: soc: export soc_device_get_machine()
  2026-01-19 11:36   ` Danilo Krummrich
@ 2026-01-19 18:41     ` Danilo Krummrich
  0 siblings, 0 replies; 27+ messages in thread
From: Danilo Krummrich @ 2026-01-19 18:41 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Rob Herring, Saravana Kannan, Greg Kroah-Hartman,
	Rafael J. Wysocki, Christophe Leroy (CS GROUP), Shawn Guo,
	Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Geert Uytterhoeven, Magnus Damm, Chen-Yu Tsai, Jernej Skrabec,
	Samuel Holland, devicetree, linux-kernel, linuxppc-dev,
	linux-arm-kernel, imx, linux-renesas-soc, linux-sunxi

On Mon Jan 19, 2026 at 12:36 PM CET, Danilo Krummrich wrote:
> On Mon Jan 19, 2026 at 11:40 AM CET, Bartosz Golaszewski wrote:
>> -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;
>
> This should never fail at this point, no? Also, can't we just use of_root?

Regarding of_root, please disregard my earlier comment. I mistakenly assumed
that it would also be guarded by CONFIG_OF.

But I still think we do not need the NULL check.

>> -	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);
>>  }
>> +EXPORT_SYMBOL_GPL(soc_device_get_machine);
>
> If we want to export this, we shouldn't reuse the existing name, which is
> misleading.
>
> soc_device_get_machine() reads as if we return a reference count of something.
> Additionally, it operates on struct soc_device_attribute instead of struct
> soc_device, where the name suggests the latter.
>
> Instead this should be soc_device_attribute_read_machine() or if we want a
> shorter name, just soc_attr_read_machine().

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 1/8] of: provide of_machine_get_compatible()
  2026-01-19 10:40 ` [PATCH 1/8] of: provide of_machine_get_compatible() Bartosz Golaszewski
  2026-01-19 11:06   ` Christophe Leroy (CS GROUP)
  2026-01-19 11:26   ` Danilo Krummrich
@ 2026-01-19 19:17   ` Geert Uytterhoeven
  2 siblings, 0 replies; 27+ messages in thread
From: Geert Uytterhoeven @ 2026-01-19 19:17 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Rob Herring, Saravana Kannan, Greg Kroah-Hartman,
	Rafael J. Wysocki, Danilo Krummrich, Christophe Leroy (CS GROUP),
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Magnus Damm, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland,
	devicetree, linux-kernel, linuxppc-dev, linux-arm-kernel, imx,
	linux-renesas-soc, linux-sunxi

Hi Bartosz,

On Mon, 19 Jan 2026 at 11:40, Bartosz Golaszewski
<bartosz.golaszewski@oss.qualcomm.com> wrote:
> Provide a helper function allowing users to read the compatible string
> of the machine, hiding the access to the root node.
>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>

Thanks for your patch!

> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -434,6 +434,19 @@ bool of_machine_compatible_match(const char *const *compats)
>  }
>  EXPORT_SYMBOL(of_machine_compatible_match);
>
> +/**
> + * of_machine_get_compatible - Get the compatible string of this machine

... the first compatible string...

Do you see a need for adding an index parameter?

> + * @compatible: address at which the compatible string will be stored
> + *
> + * Returns:
> + * 0 on success, negative error number on failure.
> + */
> +int of_machine_get_compatible(const char **compatible)
> +{
> +       return of_property_read_string(of_root, "compatible", compatible);
> +}
> +EXPORT_SYMBOL_GPL(of_machine_get_compatible);
> +
>  /**
>   * of_machine_device_match - Test root of device tree against a of_device_id array
>   * @matches:   NULL terminated array of of_device_id match structures to search in

> --- a/include/linux/of.h
> +++ b/include/linux/of.h
> @@ -426,6 +426,8 @@ static inline bool of_machine_is_compatible(const char *compat)
>         return of_machine_compatible_match(compats);
>  }
>
> +int of_machine_get_compatible(const char **compatible);
> +
>  extern int of_add_property(struct device_node *np, struct property *prop);
>  extern int of_remove_property(struct device_node *np, struct property *prop);
>  extern int of_update_property(struct device_node *np, struct property *newprop);
>

Do you need a dummy for the !CONFIG_OF case?
This is only used by drivers/soc/fsl/guts.c, and FSL_GUTS is selected
by MMC_SDHCI_OF_ESDHC, which is OF-only, but can be enabled
when PPC || COMPILE_TEST.

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

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 3/8] base: soc: export soc_device_get_machine()
  2026-01-19 10:40 ` [PATCH 3/8] base: soc: export soc_device_get_machine() Bartosz Golaszewski
  2026-01-19 11:08   ` Christophe Leroy (CS GROUP)
  2026-01-19 11:36   ` Danilo Krummrich
@ 2026-01-19 19:23   ` Geert Uytterhoeven
  2 siblings, 0 replies; 27+ messages in thread
From: Geert Uytterhoeven @ 2026-01-19 19:23 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Rob Herring, Saravana Kannan, Greg Kroah-Hartman,
	Rafael J. Wysocki, Danilo Krummrich, Christophe Leroy (CS GROUP),
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Geert Uytterhoeven, Magnus Damm, Chen-Yu Tsai, Jernej Skrabec,
	Samuel Holland, devicetree, linux-kernel, linuxppc-dev,
	linux-arm-kernel, imx, linux-renesas-soc, linux-sunxi

Hi Bartosz,

On Mon, 19 Jan 2026 at 11:40, Bartosz Golaszewski
<bartosz.golaszewski@oss.qualcomm.com> 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 <bartosz.golaszewski@oss.qualcomm.com>

Thanks for your patch!

> --- 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

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 7/8] soc: renesas: don't access of_root directly
  2026-01-19 10:40 ` [PATCH 7/8] soc: renesas: " Bartosz Golaszewski
@ 2026-01-19 19:25   ` Geert Uytterhoeven
  2026-02-23 13:45     ` Bartosz Golaszewski
  0 siblings, 1 reply; 27+ messages in thread
From: Geert Uytterhoeven @ 2026-01-19 19:25 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Rob Herring, Saravana Kannan, Greg Kroah-Hartman,
	Rafael J. Wysocki, Danilo Krummrich, Christophe Leroy (CS GROUP),
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Geert Uytterhoeven, Magnus Damm, Chen-Yu Tsai, Jernej Skrabec,
	Samuel Holland, devicetree, linux-kernel, linuxppc-dev,
	linux-arm-kernel, imx, linux-renesas-soc, linux-sunxi

Hi Bartosz,

On Mon, 19 Jan 2026 at 11:40, Bartosz Golaszewski
<bartosz.golaszewski@oss.qualcomm.com> wrote:
> 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 <bartosz.golaszewski@oss.qualcomm.com>

Thanks for your patch!

> --- a/drivers/soc/renesas/renesas-soc.c
> +++ b/drivers/soc/renesas/renesas-soc.c
> @@ -6,6 +6,7 @@
>   */
>
>  #include <linux/bitfield.h>
> +#include <linux/cleanup.h>
>  #include <linux/io.h>
>  #include <linux/of.h>
>  #include <linux/of_address.h>
> @@ -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);

I am not so fond of these of_find_node_by_path("/") + something replacements.
What about adding an of_match_root() helper?

However, in the previous patch you used a different strategy:

-       if (!of_match_node(imx8_soc_match, of_root))
+       if (!of_machine_device_match(imx8_soc_match))

>         if (!match)
>                 return -ENODEV;
>
>

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

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 8/8] soc: sunxi: mbus: don't access of_root directly
  2026-01-19 10:40 ` [PATCH 8/8] soc: sunxi: mbus: " Bartosz Golaszewski
  2026-01-19 15:36   ` Jernej Škrabec
@ 2026-01-20  7:55   ` Chen-Yu Tsai
  2026-01-20  8:08     ` Bartosz Golaszewski
  1 sibling, 1 reply; 27+ messages in thread
From: Chen-Yu Tsai @ 2026-01-20  7:55 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Rob Herring, Saravana Kannan, Greg Kroah-Hartman,
	Rafael J. Wysocki, Danilo Krummrich, Christophe Leroy (CS GROUP),
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Geert Uytterhoeven, Magnus Damm, Jernej Skrabec, Samuel Holland,
	devicetree, linux-kernel, linuxppc-dev, linux-arm-kernel, imx,
	linux-renesas-soc, linux-sunxi

On Mon, Jan 19, 2026 at 6:40 PM Bartosz Golaszewski
<bartosz.golaszewski@oss.qualcomm.com> wrote:
>
> 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.

I was somewhat expecting a matching change to the Kconfig to add
COMPILE_TEST to the "depends on" line.

But maybe the case is already hit with ARM=y && USE_OF=n ?

ChenYu

> Suggested-by: Rob Herring <robh@kernel.org>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
> ---
>  drivers/soc/sunxi/sunxi_mbus.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/soc/sunxi/sunxi_mbus.c b/drivers/soc/sunxi/sunxi_mbus.c
> index 1734da357ca21b249740e089698275507ea98a8a..8bc5f62ff258837d3f3b30cb84b60d1872b31c27 100644
> --- a/drivers/soc/sunxi/sunxi_mbus.c
> +++ b/drivers/soc/sunxi/sunxi_mbus.c
> @@ -118,7 +118,7 @@ static const char * const sunxi_mbus_platforms[] __initconst = {
>
>  static int __init sunxi_mbus_init(void)
>  {
> -       if (!of_device_compatible_match(of_root, sunxi_mbus_platforms))
> +       if (!of_machine_compatible_match(sunxi_mbus_platforms))
>                 return 0;
>
>         bus_register_notifier(&platform_bus_type, &sunxi_mbus_nb);
>
> --
> 2.47.3
>

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 8/8] soc: sunxi: mbus: don't access of_root directly
  2026-01-20  7:55   ` Chen-Yu Tsai
@ 2026-01-20  8:08     ` Bartosz Golaszewski
  0 siblings, 0 replies; 27+ messages in thread
From: Bartosz Golaszewski @ 2026-01-20  8:08 UTC (permalink / raw)
  To: wens
  Cc: Bartosz Golaszewski, Rob Herring, Saravana Kannan,
	Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich,
	Christophe Leroy (CS GROUP), Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Geert Uytterhoeven,
	Magnus Damm, Jernej Skrabec, Samuel Holland, devicetree,
	linux-kernel, linuxppc-dev, linux-arm-kernel, imx,
	linux-renesas-soc, linux-sunxi

On Tue, Jan 20, 2026 at 9:05 AM Chen-Yu Tsai <wens@kernel.org> wrote:
>
> On Mon, Jan 19, 2026 at 6:40 PM Bartosz Golaszewski
> <bartosz.golaszewski@oss.qualcomm.com> wrote:
> >
> > 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.
>
> I was somewhat expecting a matching change to the Kconfig to add
> COMPILE_TEST to the "depends on" line.
>
> But maybe the case is already hit with ARM=y && USE_OF=n ?
>

Yeah, that would be the next step but there may be more weird
dependencies hidden in here so let's do it separately after this is
addressed or we'll get stuck looking and buildbot reports.

Bart

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 6/8] soc: imx9: don't access of_root directly
  2026-01-19 10:40 ` [PATCH 6/8] soc: imx9: " Bartosz Golaszewski
@ 2026-01-27  2:39   ` Peng Fan
  0 siblings, 0 replies; 27+ messages in thread
From: Peng Fan @ 2026-01-27  2:39 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Rob Herring, Saravana Kannan, Greg Kroah-Hartman,
	Rafael J. Wysocki, Danilo Krummrich, Christophe Leroy (CS GROUP),
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Geert Uytterhoeven, Magnus Damm, Chen-Yu Tsai, Jernej Skrabec,
	Samuel Holland, devicetree, linux-kernel, linuxppc-dev,
	linux-arm-kernel, imx, linux-renesas-soc, linux-sunxi

On Mon, Jan 19, 2026 at 11:40:17AM +0100, Bartosz Golaszewski wrote:
>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 <bartosz.golaszewski@oss.qualcomm.com>

Reviewed-by: Peng Fan <peng.fan@nxp.com>

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 7/8] soc: renesas: don't access of_root directly
  2026-01-19 19:25   ` Geert Uytterhoeven
@ 2026-02-23 13:45     ` Bartosz Golaszewski
  0 siblings, 0 replies; 27+ messages in thread
From: Bartosz Golaszewski @ 2026-02-23 13:45 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Bartosz Golaszewski, Rob Herring, Saravana Kannan,
	Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich,
	Christophe Leroy (CS GROUP), Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Geert Uytterhoeven,
	Magnus Damm, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland,
	devicetree, linux-kernel, linuxppc-dev, linux-arm-kernel, imx,
	linux-renesas-soc, linux-sunxi

On Mon, Jan 19, 2026 at 8:25 PM Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>
> Hi Bartosz,
>
> On Mon, 19 Jan 2026 at 11:40, Bartosz Golaszewski
> <bartosz.golaszewski@oss.qualcomm.com> wrote:
> > 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 <bartosz.golaszewski@oss.qualcomm.com>
>
> Thanks for your patch!
>
> > --- a/drivers/soc/renesas/renesas-soc.c
> > +++ b/drivers/soc/renesas/renesas-soc.c
> > @@ -6,6 +6,7 @@
> >   */
> >
> >  #include <linux/bitfield.h>
> > +#include <linux/cleanup.h>
> >  #include <linux/io.h>
> >  #include <linux/of.h>
> >  #include <linux/of_address.h>
> > @@ -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);
>
> I am not so fond of these of_find_node_by_path("/") + something replacements.
> What about adding an of_match_root() helper?
>

I removed other instances from this series but not this one. I don't
want to grow this series with even more new helpers. How about
addressing this separately?

> However, in the previous patch you used a different strategy:
>
> -       if (!of_match_node(imx8_soc_match, of_root))
> +       if (!of_machine_device_match(imx8_soc_match))
>

Because here, we really need the match structure later into the function.

Bart

^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2026-02-23 13:46 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-19 10:40 [PATCH 0/8] soc: remove direct accesses to of_root from drivers/soc/ Bartosz Golaszewski
2026-01-19 10:40 ` [PATCH 1/8] of: provide of_machine_get_compatible() Bartosz Golaszewski
2026-01-19 11:06   ` Christophe Leroy (CS GROUP)
2026-01-19 11:26   ` Danilo Krummrich
2026-01-19 13:00     ` Bartosz Golaszewski
2026-01-19 13:20       ` Danilo Krummrich
2026-01-19 19:17   ` Geert Uytterhoeven
2026-01-19 10:40 ` [PATCH 2/8] base: soc: order includes alphabetically Bartosz Golaszewski
2026-01-19 11:07   ` Christophe Leroy (CS GROUP)
2026-01-19 10:40 ` [PATCH 3/8] base: soc: export soc_device_get_machine() Bartosz Golaszewski
2026-01-19 11:08   ` Christophe Leroy (CS GROUP)
2026-01-19 11:36   ` Danilo Krummrich
2026-01-19 18:41     ` Danilo Krummrich
2026-01-19 19:23   ` Geert Uytterhoeven
2026-01-19 10:40 ` [PATCH 4/8] soc: fsl: guts: don't access of_root directly Bartosz Golaszewski
2026-01-19 11:05   ` LEROY Christophe
2026-01-19 11:06   ` Christophe Leroy (CS GROUP)
2026-01-19 10:40 ` [PATCH 5/8] soc: imx8m: " Bartosz Golaszewski
2026-01-19 10:40 ` [PATCH 6/8] soc: imx9: " Bartosz Golaszewski
2026-01-27  2:39   ` Peng Fan
2026-01-19 10:40 ` [PATCH 7/8] soc: renesas: " Bartosz Golaszewski
2026-01-19 19:25   ` Geert Uytterhoeven
2026-02-23 13:45     ` Bartosz Golaszewski
2026-01-19 10:40 ` [PATCH 8/8] soc: sunxi: mbus: " Bartosz Golaszewski
2026-01-19 15:36   ` Jernej Škrabec
2026-01-20  7:55   ` Chen-Yu Tsai
2026-01-20  8:08     ` Bartosz Golaszewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox