Lines Matching full:master
7 * subsystem, and only handles one master device, but this doesn't have to be
61 struct master { struct
73 struct master *master; argument
91 struct master *m = s->private; in component_devices_show()
96 seq_printf(s, "%-40s %20s\n", "master name", "status"); in component_devices_show()
126 static void component_master_debugfs_add(struct master *m) in component_master_debugfs_add()
133 static void component_master_debugfs_del(struct master *m) in component_master_debugfs_del()
141 static void component_master_debugfs_add(struct master *m) in component_master_debugfs_add()
144 static void component_master_debugfs_del(struct master *m) in component_master_debugfs_del()
149 static struct master *__master_find(struct device *dev, in __master_find()
152 struct master *m; in __master_find()
161 static struct component *find_component(struct master *master, in find_component() argument
167 if (c->master && c->master != master) in find_component()
181 static int find_components(struct master *master) in find_components() argument
183 struct component_match *match = master->match; in find_components()
189 * any components which are found to this master. in find_components()
195 dev_dbg(master->dev, "Looking for component %zu\n", i); in find_components()
200 c = find_component(master, mc); in find_components()
206 dev_dbg(master->dev, "found component %s, duplicate %u\n", dev_name(c->dev), !!c->master); in find_components()
208 /* Attach this component to the master */ in find_components()
209 match->compare[i].duplicate = !!c->master; in find_components()
211 c->master = master; in find_components()
216 /* Detach component from associated master */
217 static void remove_component(struct master *master, struct component *c) in remove_component() argument
221 /* Detach the component from this master. */ in remove_component()
222 for (i = 0; i < master->match->num; i++) in remove_component()
223 if (master->match->compare[i].component == c) in remove_component()
224 master->match->compare[i].component = NULL; in remove_component()
228 * Try to bring up a master. If component is NULL, we're interested in
229 * this master, otherwise it's a component which must be present to try
230 * and bring up the master.
234 static int try_to_bring_up_master(struct master *master, in try_to_bring_up_master() argument
239 dev_dbg(master->dev, "trying to bring up master\n"); in try_to_bring_up_master()
241 if (find_components(master)) { in try_to_bring_up_master()
242 dev_dbg(master->dev, "master has incomplete components\n"); in try_to_bring_up_master()
246 if (component && component->master != master) { in try_to_bring_up_master()
247 dev_dbg(master->dev, "master is not for this component (%s)\n", in try_to_bring_up_master()
252 if (!devres_open_group(master->dev, NULL, GFP_KERNEL)) in try_to_bring_up_master()
256 ret = master->ops->bind(master->dev); in try_to_bring_up_master()
258 devres_release_group(master->dev, NULL); in try_to_bring_up_master()
260 dev_info(master->dev, "master bind failed: %d\n", ret); in try_to_bring_up_master()
264 master->bound = true; in try_to_bring_up_master()
270 struct master *m; in try_to_bring_up_masters()
284 static void take_down_master(struct master *master) in take_down_master() argument
286 if (master->bound) { in take_down_master()
287 master->ops->unbind(master->dev); in take_down_master()
288 devres_release_group(master->dev, NULL); in take_down_master()
289 master->bound = false; in take_down_master()
293 static void component_match_release(struct device *master, in component_match_release() argument
302 mc->release(master, mc->data); in component_match_release()
336 static void __component_match_add(struct device *master, in __component_match_add() argument
356 devres_add(master, match); in __component_match_add()
365 ret = component_match_realloc(master, match, new_size); in __component_match_add()
382 * @master: device with the aggregate driver
388 * Adds a new component match to the list stored in @matchptr, which the @master
400 void component_match_add_release(struct device *master, in component_match_add_release() argument
405 __component_match_add(master, matchptr, release, compare, NULL, in component_match_add_release()
412 * @master: device with the aggregate driver
417 * Adds a new component match to the list stored in @matchptr, which the @master
427 void component_match_add_typed(struct device *master, in component_match_add_typed() argument
431 __component_match_add(master, matchptr, NULL, NULL, compare_typed, in component_match_add_typed()
436 static void free_master(struct master *master) in free_master() argument
438 struct component_match *match = master->match; in free_master()
441 component_master_debugfs_del(master); in free_master()
442 list_del(&master->node); in free_master()
448 c->master = NULL; in free_master()
452 kfree(master); in free_master()
471 struct master *master; in component_master_add_with_match() local
479 master = kzalloc(sizeof(*master), GFP_KERNEL); in component_master_add_with_match()
480 if (!master) in component_master_add_with_match()
483 master->dev = dev; in component_master_add_with_match()
484 master->ops = ops; in component_master_add_with_match()
485 master->match = match; in component_master_add_with_match()
487 component_master_debugfs_add(master); in component_master_add_with_match()
490 list_add(&master->node, &masters); in component_master_add_with_match()
492 ret = try_to_bring_up_master(master, NULL); in component_master_add_with_match()
495 free_master(master); in component_master_add_with_match()
515 struct master *master; in component_master_del() local
518 master = __master_find(dev, ops); in component_master_del()
519 if (master) { in component_master_del()
520 take_down_master(master); in component_master_del()
521 free_master(master); in component_master_del()
528 struct master *master, void *data) in component_unbind() argument
533 component->ops->unbind(component->dev, master->dev, data); in component_unbind()
551 struct master *master; in component_unbind_all() local
557 master = __master_find(master_dev, NULL); in component_unbind_all()
558 if (!master) in component_unbind_all()
562 for (i = master->match->num; i--; ) in component_unbind_all()
563 if (!master->match->compare[i].duplicate) { in component_unbind_all()
564 c = master->match->compare[i].component; in component_unbind_all()
565 component_unbind(c, master, data); in component_unbind_all()
570 static int component_bind(struct component *component, struct master *master, in component_bind() argument
580 if (!devres_open_group(master->dev, NULL, GFP_KERNEL)) in component_bind()
589 devres_release_group(master->dev, NULL); in component_bind()
593 dev_dbg(master->dev, "binding %s (ops %ps)\n", in component_bind()
596 ret = component->ops->bind(component->dev, master->dev, data); in component_bind()
607 devres_remove_group(master->dev, NULL); in component_bind()
609 dev_info(master->dev, "bound %s (ops %ps)\n", in component_bind()
613 devres_release_group(master->dev, NULL); in component_bind()
616 dev_err(master->dev, "failed to bind %s (ops %ps): %d\n", in component_bind()
634 struct master *master; in component_bind_all() local
641 master = __master_find(master_dev, NULL); in component_bind_all()
642 if (!master) in component_bind_all()
646 for (i = 0; i < master->match->num; i++) in component_bind_all()
647 if (!master->match->compare[i].duplicate) { in component_bind_all()
648 c = master->match->compare[i].component; in component_bind_all()
649 ret = component_bind(c, master, data); in component_bind_all()
656 if (!master->match->compare[i - 1].duplicate) { in component_bind_all()
657 c = master->match->compare[i - 1].component; in component_bind_all()
658 component_unbind(c, master, data); in component_bind_all()
687 if (component->master) in __component_add()
688 remove_component(component->master, component); in __component_add()
769 if (component && component->master) { in component_del()
770 take_down_master(component->master); in component_del()
771 remove_component(component->master, component); in component_del()