]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
w1: core: match sub-nodes of bus masters in devicetree
authorDaniel Mack <daniel@zonque.org>
Fri, 6 Jul 2018 05:35:50 +0000 (07:35 +0200)
committerSebastian Reichel <sre@kernel.org>
Wed, 11 Jul 2018 16:09:08 +0000 (18:09 +0200)
Once a new slave device is detected, match it against all sub-nodes of the
master bus controller. If a match is found, set the slave device's of_node
pointer.

Signed-off-by: Daniel Mack <daniel@zonque.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
drivers/w1/w1.c
include/linux/w1.h

index caef0e0fd81740585e62e066f6d84c09f25a267e..890c038c25f8717f38d1c901d4ec9662d13905c5 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/kthread.h>
 #include <linux/freezer.h>
 #include <linux/hwmon.h>
+#include <linux/of.h>
 
 #include <linux/atomic.h>
 
@@ -686,6 +687,8 @@ static int __w1_attach_slave_device(struct w1_slave *sl)
        sl->dev.bus = &w1_bus_type;
        sl->dev.release = &w1_slave_release;
        sl->dev.groups = w1_slave_groups;
+       sl->dev.of_node = of_find_matching_node(sl->master->dev.of_node,
+                                               sl->family->of_match_table);
 
        dev_set_name(&sl->dev, "%02x-%012llx",
                 (unsigned int) sl->reg_num.family,
index 694101f744c7dca5fb5aa97cfa2bd88b002da322..3111585c371f5697c77fc21c77dc7eaa90ee39f3 100644 (file)
@@ -274,6 +274,8 @@ struct w1_family {
 
        struct w1_family_ops    *fops;
 
+       const struct of_device_id *of_match_table;
+
        atomic_t                refcnt;
 };