diff options
-rw-r--r-- | drivers/base/component.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/base/component.c b/drivers/base/component.c index d0ebd4431736..55813e91bf0d 100644 --- a/drivers/base/component.c +++ b/drivers/base/component.c | |||
@@ -69,6 +69,11 @@ static void component_detach_master(struct master *master, struct component *c) | |||
69 | c->master = NULL; | 69 | c->master = NULL; |
70 | } | 70 | } |
71 | 71 | ||
72 | /* | ||
73 | * Add a component to a master, finding the component via the compare | ||
74 | * function and compare data. This is safe to call for duplicate matches | ||
75 | * and will not result in the same component being added multiple times. | ||
76 | */ | ||
72 | int component_master_add_child(struct master *master, | 77 | int component_master_add_child(struct master *master, |
73 | int (*compare)(struct device *, void *), void *compare_data) | 78 | int (*compare)(struct device *, void *), void *compare_data) |
74 | { | 79 | { |
@@ -76,11 +81,12 @@ int component_master_add_child(struct master *master, | |||
76 | int ret = -ENXIO; | 81 | int ret = -ENXIO; |
77 | 82 | ||
78 | list_for_each_entry(c, &component_list, node) { | 83 | list_for_each_entry(c, &component_list, node) { |
79 | if (c->master) | 84 | if (c->master && c->master != master) |
80 | continue; | 85 | continue; |
81 | 86 | ||
82 | if (compare(c->dev, compare_data)) { | 87 | if (compare(c->dev, compare_data)) { |
83 | component_attach_master(master, c); | 88 | if (!c->master) |
89 | component_attach_master(master, c); | ||
84 | ret = 0; | 90 | ret = 0; |
85 | break; | 91 | break; |
86 | } | 92 | } |