From: Daniel Mack Date: Fri, 6 Jul 2018 05:35:50 +0000 (+0200) Subject: w1: core: match sub-nodes of bus masters in devicetree X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=fae68031f7fbc8b6db58d87830ba7ed1d696fbb1;p=linux.git w1: core: match sub-nodes of bus masters in devicetree 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 Signed-off-by: Sebastian Reichel --- diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c index caef0e0fd8174..890c038c25f87 100644 --- a/drivers/w1/w1.c +++ b/drivers/w1/w1.c @@ -26,6 +26,7 @@ #include #include #include +#include #include @@ -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, diff --git a/include/linux/w1.h b/include/linux/w1.h index 694101f744c7d..3111585c371f5 100644 --- a/include/linux/w1.h +++ b/include/linux/w1.h @@ -274,6 +274,8 @@ struct w1_family { struct w1_family_ops *fops; + const struct of_device_id *of_match_table; + atomic_t refcnt; };