Lines Matching refs:master
60 struct master { struct
71 struct master *master; member
89 struct master *m = s->private; in component_devices_show()
124 static void component_master_debugfs_add(struct master *m) in component_master_debugfs_add()
130 static void component_master_debugfs_del(struct master *m) in component_master_debugfs_del()
137 static void component_master_debugfs_add(struct master *m) in component_master_debugfs_add()
140 static void component_master_debugfs_del(struct master *m) in component_master_debugfs_del()
145 static struct master *__master_find(struct device *parent, in __master_find()
148 struct master *m; in __master_find()
157 static struct component *find_component(struct master *master, in find_component() argument
163 if (c->master && c->master != master) in find_component()
177 static int find_components(struct master *master) in find_components() argument
179 struct component_match *match = master->match; in find_components()
191 dev_dbg(master->parent, "Looking for component %zu\n", i); in find_components()
196 c = find_component(master, mc); in find_components()
202 dev_dbg(master->parent, "found component %s, duplicate %u\n", dev_name(c->dev), !!c->master); in find_components()
205 match->compare[i].duplicate = !!c->master; in find_components()
207 c->master = master; in find_components()
213 static void remove_component(struct master *master, struct component *c) in remove_component() argument
218 for (i = 0; i < master->match->num; i++) in remove_component()
219 if (master->match->compare[i].component == c) in remove_component()
220 master->match->compare[i].component = NULL; in remove_component()
230 static int try_to_bring_up_master(struct master *master, in try_to_bring_up_master() argument
235 dev_dbg(master->parent, "trying to bring up master\n"); in try_to_bring_up_master()
237 if (find_components(master)) { in try_to_bring_up_master()
238 dev_dbg(master->parent, "master has incomplete components\n"); in try_to_bring_up_master()
242 if (component && component->master != master) { in try_to_bring_up_master()
243 dev_dbg(master->parent, "master is not for this component (%s)\n", in try_to_bring_up_master()
248 if (!devres_open_group(master->parent, master, GFP_KERNEL)) in try_to_bring_up_master()
252 ret = master->ops->bind(master->parent); in try_to_bring_up_master()
254 devres_release_group(master->parent, NULL); in try_to_bring_up_master()
256 dev_info(master->parent, "master bind failed: %d\n", ret); in try_to_bring_up_master()
260 devres_close_group(master->parent, NULL); in try_to_bring_up_master()
261 master->bound = true; in try_to_bring_up_master()
267 struct master *m; in try_to_bring_up_masters()
281 static void take_down_master(struct master *master) in take_down_master() argument
283 if (master->bound) { in take_down_master()
284 master->ops->unbind(master->parent); in take_down_master()
285 devres_release_group(master->parent, master); in take_down_master()
286 master->bound = false; in take_down_master()
327 static void __component_match_add(struct device *master, in __component_match_add() argument
347 devres_add(master, match); in __component_match_add()
391 void component_match_add_release(struct device *master, in component_match_add_release() argument
396 __component_match_add(master, matchptr, release, compare, NULL, in component_match_add_release()
418 void component_match_add_typed(struct device *master, in component_match_add_typed() argument
422 __component_match_add(master, matchptr, NULL, NULL, compare_typed, in component_match_add_typed()
427 static void free_master(struct master *master) in free_master() argument
429 struct component_match *match = master->match; in free_master()
432 component_master_debugfs_del(master); in free_master()
433 list_del(&master->node); in free_master()
439 c->master = NULL; in free_master()
443 kfree(master); in free_master()
462 struct master *master; in component_master_add_with_match() local
470 master = kzalloc(sizeof(*master), GFP_KERNEL); in component_master_add_with_match()
471 if (!master) in component_master_add_with_match()
474 master->parent = parent; in component_master_add_with_match()
475 master->ops = ops; in component_master_add_with_match()
476 master->match = match; in component_master_add_with_match()
478 component_master_debugfs_add(master); in component_master_add_with_match()
481 list_add(&master->node, &masters); in component_master_add_with_match()
483 ret = try_to_bring_up_master(master, NULL); in component_master_add_with_match()
486 free_master(master); in component_master_add_with_match()
506 struct master *master; in component_master_del() local
509 master = __master_find(parent, ops); in component_master_del()
510 if (master) { in component_master_del()
511 take_down_master(master); in component_master_del()
512 free_master(master); in component_master_del()
519 struct master *master, void *data) in component_unbind() argument
524 component->ops->unbind(component->dev, master->parent, data); in component_unbind()
542 struct master *master; in component_unbind_all() local
548 master = __master_find(parent, NULL); in component_unbind_all()
549 if (!master) in component_unbind_all()
553 for (i = master->match->num; i--; ) in component_unbind_all()
554 if (!master->match->compare[i].duplicate) { in component_unbind_all()
555 c = master->match->compare[i].component; in component_unbind_all()
556 component_unbind(c, master, data); in component_unbind_all()
561 static int component_bind(struct component *component, struct master *master, in component_bind() argument
571 if (!devres_open_group(master->parent, NULL, GFP_KERNEL)) in component_bind()
580 devres_release_group(master->parent, NULL); in component_bind()
584 dev_dbg(master->parent, "binding %s (ops %ps)\n", in component_bind()
587 ret = component->ops->bind(component->dev, master->parent, data); in component_bind()
598 devres_remove_group(master->parent, NULL); in component_bind()
600 dev_info(master->parent, "bound %s (ops %ps)\n", in component_bind()
604 devres_release_group(master->parent, NULL); in component_bind()
607 dev_err(master->parent, "failed to bind %s (ops %ps): %d\n", in component_bind()
625 struct master *master; in component_bind_all() local
632 master = __master_find(parent, NULL); in component_bind_all()
633 if (!master) in component_bind_all()
637 for (i = 0; i < master->match->num; i++) in component_bind_all()
638 if (!master->match->compare[i].duplicate) { in component_bind_all()
639 c = master->match->compare[i].component; in component_bind_all()
640 ret = component_bind(c, master, data); in component_bind_all()
647 if (!master->match->compare[i - 1].duplicate) { in component_bind_all()
648 c = master->match->compare[i - 1].component; in component_bind_all()
649 component_unbind(c, master, data); in component_bind_all()
678 if (component->master) in __component_add()
679 remove_component(component->master, component); in __component_add()
760 if (component && component->master) { in component_del()
761 take_down_master(component->master); in component_del()
762 remove_component(component->master, component); in component_del()