From: "Christophe Leroy (CS GROUP)" <chleroy@kernel.org>
To: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>,
Rob Herring <robh@kernel.org>,
Saravana Kannan <saravanak@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Danilo Krummrich <dakr@kernel.org>,
Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
Geert Uytterhoeven <geert+renesas@glider.be>,
Magnus Damm <magnus.damm@gmail.com>,
Chen-Yu Tsai <wens@kernel.org>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Samuel Holland <samuel@sholland.org>
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
Subject: Re: [PATCH 3/8] base: soc: export soc_device_get_machine()
Date: Mon, 19 Jan 2026 12:08:05 +0100 [thread overview]
Message-ID: <db748d3f-53c8-43cc-a5bc-94940252ca0c@kernel.org> (raw)
In-Reply-To: <20260119-soc-of-root-v1-3-32a0fa9a78b4@oss.qualcomm.com>
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);
>
next prev parent reply other threads:[~2026-01-19 11:08 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
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) [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=db748d3f-53c8-43cc-a5bc-94940252ca0c@kernel.org \
--to=chleroy@kernel.org \
--cc=bartosz.golaszewski@oss.qualcomm.com \
--cc=dakr@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=festevam@gmail.com \
--cc=geert+renesas@glider.be \
--cc=gregkh@linuxfoundation.org \
--cc=imx@lists.linux.dev \
--cc=jernej.skrabec@gmail.com \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=linux-sunxi@lists.linux.dev \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=magnus.damm@gmail.com \
--cc=rafael@kernel.org \
--cc=robh@kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=samuel@sholland.org \
--cc=saravanak@kernel.org \
--cc=shawnguo@kernel.org \
--cc=wens@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox