Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

base: soc: populate machine name in soc_device_register if empty

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>
Acked-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Link: https://lore.kernel.org/r/6dbdf458-9f46-613e-de58-b4a56a6cdd9f@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Heiner Kallweit and committed by
Greg Kroah-Hartman
3f84aa5e 7b884b7f

+15
+15
drivers/base/soc.c
··· 7 7 8 8 #include <linux/sysfs.h> 9 9 #include <linux/init.h> 10 + #include <linux/of.h> 10 11 #include <linux/stat.h> 11 12 #include <linux/slab.h> 12 13 #include <linux/idr.h> ··· 111 110 kfree(soc_dev); 112 111 } 113 112 113 + static void soc_device_get_machine(struct soc_device_attribute *soc_dev_attr) 114 + { 115 + struct device_node *np; 116 + 117 + if (soc_dev_attr->machine) 118 + return; 119 + 120 + np = of_find_node_by_path("/"); 121 + of_property_read_string(np, "model", &soc_dev_attr->machine); 122 + of_node_put(np); 123 + } 124 + 114 125 static struct soc_device_attribute *early_soc_dev_attr; 115 126 116 127 struct soc_device *soc_device_register(struct soc_device_attribute *soc_dev_attr) ··· 130 117 struct soc_device *soc_dev; 131 118 const struct attribute_group **soc_attr_groups; 132 119 int ret; 120 + 121 + soc_device_get_machine(soc_dev_attr); 133 122 134 123 if (!soc_bus_registered) { 135 124 if (early_soc_dev_attr)