[PATCH 1/2] cpu: allow matching cpu_subsys devices against OF nodes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Currently cpu_sybsys devices support only ACPI style matching.
Pass DT node pointer to cpu_device_create to support OF style matching
for cpu_subsys devices.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@xxxxxxxxxx>
---
 drivers/base/cacheinfo.c |  6 ++++--
 drivers/base/cpu.c       | 15 ++++++++++++---
 include/linux/cpu.h      |  3 ++-
 3 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c
index f1e79263fe61..a72c69e70fa3 100644
--- a/drivers/base/cacheinfo.c
+++ b/drivers/base/cacheinfo.c
@@ -845,7 +845,7 @@ static int cpu_cache_sysfs_init(unsigned int cpu)
 	if (per_cpu_cacheinfo(cpu) == NULL)
 		return -ENOENT;
 
-	per_cpu_cache_dev(cpu) = cpu_device_create(dev, NULL, NULL, "cache");
+	per_cpu_cache_dev(cpu) = cpu_device_create(dev, NULL, NULL, NULL, "cache");
 	if (IS_ERR(per_cpu_cache_dev(cpu)))
 		return PTR_ERR(per_cpu_cache_dev(cpu));
 
@@ -882,7 +882,9 @@ static int cache_add_dev(unsigned int cpu)
 		if (this_leaf->type == CACHE_TYPE_NOCACHE)
 			break;
 		cache_groups = cache_get_attribute_groups(this_leaf);
-		ci_dev = cpu_device_create(parent, this_leaf, cache_groups,
+		ci_dev = cpu_device_create(parent, this_leaf,
+					   NULL,
+					   cache_groups,
 					   "index%1u", i);
 		if (IS_ERR(ci_dev)) {
 			rc = PTR_ERR(ci_dev);
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 47de0f140ba6..d7db38fbfc17 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -16,6 +16,7 @@
 #include <linux/percpu.h>
 #include <linux/acpi.h>
 #include <linux/of.h>
+#include <linux/of_device.h>
 #include <linux/cpufeature.h>
 #include <linux/tick.h>
 #include <linux/pm_qos.h>
@@ -28,7 +29,11 @@ static DEFINE_PER_CPU(struct device *, cpu_sys_devices);
 
 static int cpu_subsys_match(struct device *dev, struct device_driver *drv)
 {
-	/* ACPI style match is the only one that may succeed. */
+	/* Attempt an OF style match first */
+	if (of_driver_match_device(dev, drv))
+		return 1;
+
+	/* Then try ACPI style match */
 	if (acpi_driver_match_device(dev, drv))
 		return 1;
 
@@ -428,12 +433,14 @@ EXPORT_SYMBOL_GPL(get_cpu_device);
 
 static void device_create_release(struct device *dev)
 {
+	of_node_put(dev->of_node);
 	kfree(dev);
 }
 
-__printf(4, 0)
+__printf(5, 0)
 static struct device *
 __cpu_device_create(struct device *parent, void *drvdata,
+		    struct device_node *np,
 		    const struct attribute_group **groups,
 		    const char *fmt, va_list args)
 {
@@ -447,6 +454,7 @@ __cpu_device_create(struct device *parent, void *drvdata,
 	device_initialize(dev);
 	dev->parent = parent;
 	dev->groups = groups;
+	dev->of_node = of_node_get(np);
 	dev->release = device_create_release;
 	device_set_pm_not_required(dev);
 	dev_set_drvdata(dev, drvdata);
@@ -467,6 +475,7 @@ __cpu_device_create(struct device *parent, void *drvdata,
 }
 
 struct device *cpu_device_create(struct device *parent, void *drvdata,
+				 struct device_node *np,
 				 const struct attribute_group **groups,
 				 const char *fmt, ...)
 {
@@ -474,7 +483,7 @@ struct device *cpu_device_create(struct device *parent, void *drvdata,
 	struct device *dev;
 
 	va_start(vargs, fmt);
-	dev = __cpu_device_create(parent, drvdata, groups, fmt, vargs);
+	dev = __cpu_device_create(parent, drvdata, np, groups, fmt, vargs);
 	va_end(vargs);
 	return dev;
 }
diff --git a/include/linux/cpu.h b/include/linux/cpu.h
index dcb89c987164..6ae291080e4a 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -76,8 +76,9 @@ extern ssize_t cpu_show_spec_rstack_overflow(struct device *dev,
 extern ssize_t cpu_show_gds(struct device *dev,
 			    struct device_attribute *attr, char *buf);
 
-extern __printf(4, 5)
+extern __printf(5, 6)
 struct device *cpu_device_create(struct device *parent, void *drvdata,
+				 struct device_node *np,
 				 const struct attribute_group **groups,
 				 const char *fmt, ...);
 extern bool arch_cpu_is_hotpluggable(int cpu);

-- 
2.39.2





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [Linux for Sparc]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux