@@ -673,9 +673,9 @@ static int __w1_attach_slave_device(struct w1_slave *sl)
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,
- (unsigned long long) sl->reg_num.id);
+ dev_set_name(&sl->dev, "%s-%02x-%012llx", sl->master->name,
+ (unsigned int)sl->reg_num.family,
+ (unsigned long long)sl->reg_num.id);
snprintf(&sl->name[0], sizeof(sl->name),
"%02x-%012llx",
(unsigned int) sl->reg_num.family,
@@ -242,3 +242,30 @@ void w1_remove_master_device(struct w1_bus_master *bm)
__w1_remove_master_device(found);
}
EXPORT_SYMBOL(w1_remove_master_device);
+
+/**
+ * w1_find_master_device() - find a master device
+ * @bm: master bus device to search
+ */
+struct w1_master *w1_find_master_device(struct w1_bus_master *bm)
+{
+ struct w1_master *dev, *found = NULL;
+
+ list_for_each_entry(dev, &w1_masters, w1_master_entry) {
+ if (!dev->initialized)
+ continue;
+
+ if (dev->bus_master->data == bm->data) {
+ found = dev;
+ break;
+ }
+ }
+
+ if (!found) {
+ pr_err("device doesn't exist.\n");
+ return ERR_PTR(-ENODEV);
+ }
+
+ return found;
+}
+EXPORT_SYMBOL(w1_find_master_device);
@@ -242,6 +242,7 @@ struct w1_master {
int w1_add_master_device(struct w1_bus_master *master);
void w1_remove_master_device(struct w1_bus_master *master);
+struct w1_master *w1_find_master_device(struct w1_bus_master *master);
/**
* struct w1_family_ops - operations for a family type