]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
base: soc: rename and export soc_device_get_machine()
authorBartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Mon, 23 Feb 2026 13:37:19 +0000 (14:37 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 12 Mar 2026 15:18:49 +0000 (16:18 +0100)
Some SoC drivers reimplement the functionality of
soc_device_get_machine(). Make this function accessible through the
sys_soc.h header and rename it to a more descriptive name.

Reviewed-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
Link: https://patch.msgid.link/20260223-soc-of-root-v2-4-b45da45903c8@oss.qualcomm.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/base/soc.c
include/linux/sys_soc.h

index 48e2f0dbd330b8d402135ffa7308f454eb4ab7a5..65ce72d49230360c22a812cb9286e7fb4de0baf2 100644 (file)
@@ -111,17 +111,14 @@ 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_attr_read_machine(struct soc_device_attribute *soc_dev_attr)
 {
-       struct device_node *np;
-
        if (soc_dev_attr->machine)
-               return;
+               return -EBUSY;
 
-       np = of_find_node_by_path("/");
-       of_property_read_string(np, "model", &soc_dev_attr->machine);
-       of_node_put(np);
+       return of_machine_read_model(&soc_dev_attr->machine);
 }
+EXPORT_SYMBOL_GPL(soc_attr_read_machine);
 
 static struct soc_device_attribute *early_soc_dev_attr;
 
@@ -131,7 +128,7 @@ struct soc_device *soc_device_register(struct soc_device_attribute *soc_dev_attr
        const struct attribute_group **soc_attr_groups;
        int ret;
 
-       soc_device_get_machine(soc_dev_attr);
+       soc_attr_read_machine(soc_dev_attr);
 
        if (!soc_bus_registered) {
                if (early_soc_dev_attr)
index d9b3cf0f410c8cfb509a4c1a4d6c83fde6fe33c6..f19f5cec18e28461fef57f22702d2c44a41e4193 100644 (file)
@@ -37,6 +37,16 @@ void soc_device_unregister(struct soc_device *soc_dev);
  */
 struct device *soc_device_to_device(struct soc_device *soc);
 
+/**
+ * soc_attr_read_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_attr_read_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);