* [PATCH 0/2] base: soc: populate machine name in soc_device_register if empty
@ 2023-03-17 12:35 Heiner Kallweit
2023-03-17 12:36 ` [PATCH 1/2] " Heiner Kallweit
2023-03-17 12:37 ` [PATCH 2/2] soc: amlogic: meson-gx-socinfo: use new soc_device_register functionality to populate machine name Heiner Kallweit
0 siblings, 2 replies; 5+ messages in thread
From: Heiner Kallweit @ 2023-03-17 12:35 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rafael J. Wysocki, Jerome Brunet,
Martin Blumenstingl, Neil Armstrong, Kevin Hilman
Cc: Linux Kernel Mailing List, open list:ARM/Amlogic Meson...,
linux-arm-kernel
Several SoC drivers use the same of-based mechanism to populate the machine
name. Therefore move this to the core and try to populate the machine name
in soc_device_register if it's not set yet.
Make meson-gx-socinfo the first user of this new functionality.
Heiner Kallweit (2):
base: soc: populate machine name in soc_device_register if empty
soc: amlogic: meson-gx-socinfo: use new soc_device_register
functionality to populate machine name
drivers/base/soc.c | 15 +++++++++++++++
drivers/soc/amlogic/meson-gx-socinfo.c | 5 -----
2 files changed, 15 insertions(+), 5 deletions(-)
--
2.39.2
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] base: soc: populate machine name in soc_device_register if empty
2023-03-17 12:35 [PATCH 0/2] base: soc: populate machine name in soc_device_register if empty Heiner Kallweit
@ 2023-03-17 12:36 ` Heiner Kallweit
2023-03-20 15:39 ` Martin Blumenstingl
2023-03-17 12:37 ` [PATCH 2/2] soc: amlogic: meson-gx-socinfo: use new soc_device_register functionality to populate machine name Heiner Kallweit
1 sibling, 1 reply; 5+ messages in thread
From: Heiner Kallweit @ 2023-03-17 12:36 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rafael J. Wysocki, Jerome Brunet,
Martin Blumenstingl, Neil Armstrong, Kevin Hilman
Cc: Linux Kernel Mailing List, open list:ARM/Amlogic Meson...,
linux-arm-kernel
Several SoC drivers use the same of-based mechanism to populate the machine
name. Therefore move this to the core and try to populate the machine name
in soc_device_register if it's not set yet.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/base/soc.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/drivers/base/soc.c b/drivers/base/soc.c
index 0fb1d4ab9..8dec5228f 100644
--- a/drivers/base/soc.c
+++ b/drivers/base/soc.c
@@ -7,6 +7,7 @@
#include <linux/sysfs.h>
#include <linux/init.h>
+#include <linux/of.h>
#include <linux/stat.h>
#include <linux/slab.h>
#include <linux/idr.h>
@@ -110,6 +111,18 @@ static void soc_release(struct device *dev)
kfree(soc_dev);
}
+static void soc_device_get_machine(struct soc_device_attribute *soc_dev_attr)
+{
+ struct device_node *np;
+
+ if (soc_dev_attr->machine)
+ return;
+
+ np = of_find_node_by_path("/");
+ of_property_read_string(np, "model", &soc_dev_attr->machine);
+ of_node_put(np);
+}
+
static struct soc_device_attribute *early_soc_dev_attr;
struct soc_device *soc_device_register(struct soc_device_attribute *soc_dev_attr)
@@ -118,6 +131,8 @@ 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);
+
if (!soc_bus_registered) {
if (early_soc_dev_attr)
return ERR_PTR(-EBUSY);
--
2.39.2
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] soc: amlogic: meson-gx-socinfo: use new soc_device_register functionality to populate machine name
2023-03-17 12:35 [PATCH 0/2] base: soc: populate machine name in soc_device_register if empty Heiner Kallweit
2023-03-17 12:36 ` [PATCH 1/2] " Heiner Kallweit
@ 2023-03-17 12:37 ` Heiner Kallweit
2023-03-20 15:40 ` Martin Blumenstingl
1 sibling, 1 reply; 5+ messages in thread
From: Heiner Kallweit @ 2023-03-17 12:37 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rafael J. Wysocki, Jerome Brunet,
Martin Blumenstingl, Neil Armstrong, Kevin Hilman
Cc: Linux Kernel Mailing List, open list:ARM/Amlogic Meson...,
linux-arm-kernel
A new fallback mechanism has been added to soc_device_register that
populates machine with the DT model information if machine isn't set yet.
This allows to remove this code here.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/soc/amlogic/meson-gx-socinfo.c | 5 -----
1 file changed, 5 deletions(-)
diff --git a/drivers/soc/amlogic/meson-gx-socinfo.c b/drivers/soc/amlogic/meson-gx-socinfo.c
index 165f75484..6abb73034 100644
--- a/drivers/soc/amlogic/meson-gx-socinfo.c
+++ b/drivers/soc/amlogic/meson-gx-socinfo.c
@@ -174,11 +174,6 @@ static int __init meson_gx_socinfo_init(void)
return -ENODEV;
soc_dev_attr->family = "Amlogic Meson";
-
- np = of_find_node_by_path("/");
- of_property_read_string(np, "model", &soc_dev_attr->machine);
- of_node_put(np);
-
soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%x:%x - %x:%x",
socinfo_to_major(socinfo),
socinfo_to_minor(socinfo),
--
2.39.2
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] base: soc: populate machine name in soc_device_register if empty
2023-03-17 12:36 ` [PATCH 1/2] " Heiner Kallweit
@ 2023-03-20 15:39 ` Martin Blumenstingl
0 siblings, 0 replies; 5+ messages in thread
From: Martin Blumenstingl @ 2023-03-20 15:39 UTC (permalink / raw)
To: Heiner Kallweit
Cc: Greg Kroah-Hartman, Rafael J. Wysocki, Jerome Brunet,
Neil Armstrong, Kevin Hilman, Linux Kernel Mailing List,
open list:ARM/Amlogic Meson...,
linux-arm-kernel
On Fri, Mar 17, 2023 at 1:37 PM Heiner Kallweit <hkallweit1@gmail.com> wrote:
[...]
> +static void soc_device_get_machine(struct soc_device_attribute *soc_dev_attr)
> +{
> + struct device_node *np;
> +
> + if (soc_dev_attr->machine)
> + return;
> +
> + np = of_find_node_by_path("/");
> + of_property_read_string(np, "model", &soc_dev_attr->machine);
> + of_node_put(np);
At first I thought there's a problem with non-OF machines here.
But if CONFIG_OF is disabled the code above is a no-op because we're
not checking any error/return codes.
So this gets my:
Acked-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] soc: amlogic: meson-gx-socinfo: use new soc_device_register functionality to populate machine name
2023-03-17 12:37 ` [PATCH 2/2] soc: amlogic: meson-gx-socinfo: use new soc_device_register functionality to populate machine name Heiner Kallweit
@ 2023-03-20 15:40 ` Martin Blumenstingl
0 siblings, 0 replies; 5+ messages in thread
From: Martin Blumenstingl @ 2023-03-20 15:40 UTC (permalink / raw)
To: Heiner Kallweit
Cc: Greg Kroah-Hartman, Rafael J. Wysocki, Jerome Brunet,
Neil Armstrong, Kevin Hilman, Linux Kernel Mailing List,
open list:ARM/Amlogic Meson...,
linux-arm-kernel
On Fri, Mar 17, 2023 at 1:37 PM Heiner Kallweit <hkallweit1@gmail.com> wrote:
>
> A new fallback mechanism has been added to soc_device_register that
> populates machine with the DT model information if machine isn't set yet.
> This allows to remove this code here.
>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Assuming this is only applied after/together with the first patch from
this series:
Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-03-20 15:41 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-17 12:35 [PATCH 0/2] base: soc: populate machine name in soc_device_register if empty Heiner Kallweit
2023-03-17 12:36 ` [PATCH 1/2] " Heiner Kallweit
2023-03-20 15:39 ` Martin Blumenstingl
2023-03-17 12:37 ` [PATCH 2/2] soc: amlogic: meson-gx-socinfo: use new soc_device_register functionality to populate machine name Heiner Kallweit
2023-03-20 15:40 ` Martin Blumenstingl
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).