Lines Matching full:master
7 * subsystem, and only handles one master device, but this doesn't have to be
61 struct master { struct
72 struct master *master; argument
90 struct master *m = s->private; in component_devices_show()
95 seq_printf(s, "%-40s %20s\n", "master name", "status"); in component_devices_show()
125 static void component_master_debugfs_add(struct master *m) in component_master_debugfs_add()
131 static void component_master_debugfs_del(struct master *m) in component_master_debugfs_del()
138 static void component_master_debugfs_add(struct master *m) in component_master_debugfs_add()
141 static void component_master_debugfs_del(struct master *m) in component_master_debugfs_del()
146 static struct master *__master_find(struct device *parent, in __master_find()
149 struct master *m; in __master_find()
158 static struct component *find_component(struct master *master, in find_component() argument
164 if (c->master && c->master != master) in find_component()
178 static int find_components(struct master *master) in find_components() argument
180 struct component_match *match = master->match; in find_components()
186 * any components which are found to this master. in find_components()
192 dev_dbg(master->parent, "Looking for component %zu\n", i); in find_components()
197 c = find_component(master, mc); in find_components()
203 dev_dbg(master->parent, "found component %s, duplicate %u\n", dev_name(c->dev), !!c->master); in find_components()
205 /* Attach this component to the master */ in find_components()
206 match->compare[i].duplicate = !!c->master; in find_components()
208 c->master = master; in find_components()
213 /* Detach component from associated master */
214 static void remove_component(struct master *master, struct component *c) in remove_component() argument
218 /* Detach the component from this master. */ in remove_component()
219 for (i = 0; i < master->match->num; i++) in remove_component()
220 if (master->match->compare[i].component == c) in remove_component()
221 master->match->compare[i].component = NULL; in remove_component()
225 * Try to bring up a master. If component is NULL, we're interested in
226 * this master, otherwise it's a component which must be present to try
227 * and bring up the master.
231 static int try_to_bring_up_master(struct master *master, in try_to_bring_up_master() argument
236 dev_dbg(master->parent, "trying to bring up master\n"); in try_to_bring_up_master()
238 if (find_components(master)) { in try_to_bring_up_master()
239 dev_dbg(master->parent, "master has incomplete components\n"); in try_to_bring_up_master()
243 if (component && component->master != master) { in try_to_bring_up_master()
244 dev_dbg(master->parent, "master is not for this component (%s)\n", in try_to_bring_up_master()
249 if (!devres_open_group(master->parent, NULL, GFP_KERNEL)) in try_to_bring_up_master()
253 ret = master->ops->bind(master->parent); in try_to_bring_up_master()
255 devres_release_group(master->parent, NULL); in try_to_bring_up_master()
257 dev_info(master->parent, "master bind failed: %d\n", ret); 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, NULL); 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()
373 * @master: device with the aggregate driver
379 * Adds a new component match to the list stored in @matchptr, which the @master
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()
403 * @master: device with the aggregate driver
408 * Adds a new component match to the list stored in @matchptr, which the @master
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()