Lines Matching refs:master
37 struct master { struct
48 struct master *master; argument
59 static struct master *__master_find(struct device *dev, in __master_find()
62 struct master *m; in __master_find()
71 static struct component *find_component(struct master *master, in find_component() argument
77 if (c->master && c->master != master) in find_component()
87 static int find_components(struct master *master) in find_components() argument
89 struct component_match *match = master->match; in find_components()
101 dev_dbg(master->dev, "Looking for component %zu\n", i); in find_components()
106 c = find_component(master, mc->compare, mc->data); in find_components()
112 dev_dbg(master->dev, "found component %s, duplicate %u\n", dev_name(c->dev), !!c->master); in find_components()
115 match->compare[i].duplicate = !!c->master; in find_components()
117 c->master = master; in find_components()
123 static void remove_component(struct master *master, struct component *c) in remove_component() argument
128 for (i = 0; i < master->match->num; i++) in remove_component()
129 if (master->match->compare[i].component == c) in remove_component()
130 master->match->compare[i].component = NULL; in remove_component()
140 static int try_to_bring_up_master(struct master *master, in try_to_bring_up_master() argument
145 dev_dbg(master->dev, "trying to bring up master\n"); in try_to_bring_up_master()
147 if (find_components(master)) { in try_to_bring_up_master()
148 dev_dbg(master->dev, "master has incomplete components\n"); in try_to_bring_up_master()
152 if (component && component->master != master) { in try_to_bring_up_master()
153 dev_dbg(master->dev, "master is not for this component (%s)\n", in try_to_bring_up_master()
158 if (!devres_open_group(master->dev, NULL, GFP_KERNEL)) in try_to_bring_up_master()
162 ret = master->ops->bind(master->dev); in try_to_bring_up_master()
164 devres_release_group(master->dev, NULL); in try_to_bring_up_master()
165 dev_info(master->dev, "master bind failed: %d\n", ret); in try_to_bring_up_master()
169 master->bound = true; in try_to_bring_up_master()
175 struct master *m; in try_to_bring_up_masters()
189 static void take_down_master(struct master *master) in take_down_master() argument
191 if (master->bound) { in take_down_master()
192 master->ops->unbind(master->dev); in take_down_master()
193 devres_release_group(master->dev, NULL); in take_down_master()
194 master->bound = false; in take_down_master()
198 static void component_match_release(struct device *master, in component_match_release() argument
207 mc->release(master, mc->data); in component_match_release()
246 void component_match_add_release(struct device *master, in component_match_add_release() argument
264 devres_add(master, match); in component_match_add_release()
273 ret = component_match_realloc(master, match, new_size); in component_match_add_release()
288 static void free_master(struct master *master) in free_master() argument
290 struct component_match *match = master->match; in free_master()
293 list_del(&master->node); in free_master()
299 c->master = NULL; in free_master()
303 kfree(master); in free_master()
310 struct master *master; in component_master_add_with_match() local
318 master = kzalloc(sizeof(*master), GFP_KERNEL); in component_master_add_with_match()
319 if (!master) in component_master_add_with_match()
322 master->dev = dev; in component_master_add_with_match()
323 master->ops = ops; in component_master_add_with_match()
324 master->match = match; in component_master_add_with_match()
328 list_add(&master->node, &masters); in component_master_add_with_match()
330 ret = try_to_bring_up_master(master, NULL); in component_master_add_with_match()
333 free_master(master); in component_master_add_with_match()
344 struct master *master; in component_master_del() local
347 master = __master_find(dev, ops); in component_master_del()
348 if (master) { in component_master_del()
349 take_down_master(master); in component_master_del()
350 free_master(master); in component_master_del()
357 struct master *master, void *data) in component_unbind() argument
361 component->ops->unbind(component->dev, master->dev, data); in component_unbind()
370 struct master *master; in component_unbind_all() local
376 master = __master_find(master_dev, NULL); in component_unbind_all()
377 if (!master) in component_unbind_all()
381 for (i = master->match->num; i--; ) in component_unbind_all()
382 if (!master->match->compare[i].duplicate) { in component_unbind_all()
383 c = master->match->compare[i].component; in component_unbind_all()
384 component_unbind(c, master, data); in component_unbind_all()
389 static int component_bind(struct component *component, struct master *master, in component_bind() argument
399 if (!devres_open_group(master->dev, NULL, GFP_KERNEL)) in component_bind()
408 devres_release_group(master->dev, NULL); in component_bind()
412 dev_dbg(master->dev, "binding %s (ops %ps)\n", in component_bind()
415 ret = component->ops->bind(component->dev, master->dev, data); in component_bind()
426 devres_remove_group(master->dev, NULL); in component_bind()
428 dev_info(master->dev, "bound %s (ops %ps)\n", in component_bind()
432 devres_release_group(master->dev, NULL); in component_bind()
434 dev_err(master->dev, "failed to bind %s (ops %ps): %d\n", in component_bind()
443 struct master *master; in component_bind_all() local
450 master = __master_find(master_dev, NULL); in component_bind_all()
451 if (!master) in component_bind_all()
455 for (i = 0; i < master->match->num; i++) in component_bind_all()
456 if (!master->match->compare[i].duplicate) { in component_bind_all()
457 c = master->match->compare[i].component; in component_bind_all()
458 ret = component_bind(c, master, data); in component_bind_all()
465 if (!master->match->compare[i - 1].duplicate) { in component_bind_all()
466 c = master->match->compare[i - 1].component; in component_bind_all()
467 component_unbind(c, master, data); in component_bind_all()
494 if (component->master) in component_add()
495 remove_component(component->master, component); in component_add()
518 if (component && component->master) { in component_del()
519 take_down_master(component->master); in component_del()
520 remove_component(component->master, component); in component_del()