Lines Matching refs:master

30 struct master {  struct
43 struct master *master; argument
54 static struct master *__master_find(struct device *dev, in __master_find()
57 struct master *m; in __master_find()
67 static void component_attach_master(struct master *master, struct component *c) in component_attach_master() argument
69 c->master = master; in component_attach_master()
71 list_add_tail(&c->master_node, &master->components); in component_attach_master()
75 static void component_detach_master(struct master *master, struct component *c) in component_detach_master() argument
79 c->master = NULL; in component_detach_master()
87 int component_master_add_child(struct master *master, in component_master_add_child() argument
94 if (c->master && c->master != master) in component_master_add_child()
98 if (!c->master) in component_master_add_child()
99 component_attach_master(master, c); in component_master_add_child()
109 static int find_components(struct master *master) in find_components() argument
111 struct component_match *match = master->match; in find_components()
120 return master->ops->add_components(master->dev, master); in find_components()
128 ret = component_master_add_child(master, in find_components()
138 static void master_remove_components(struct master *master) in master_remove_components() argument
140 while (!list_empty(&master->components)) { in master_remove_components()
141 struct component *c = list_first_entry(&master->components, in master_remove_components()
144 WARN_ON(c->master != master); in master_remove_components()
146 component_detach_master(master, c); in master_remove_components()
157 static int try_to_bring_up_master(struct master *master, in try_to_bring_up_master() argument
162 if (master->bound) in try_to_bring_up_master()
169 if (find_components(master)) { in try_to_bring_up_master()
175 if (component && component->master != master) { in try_to_bring_up_master()
180 if (!devres_open_group(master->dev, NULL, GFP_KERNEL)) { in try_to_bring_up_master()
186 ret = master->ops->bind(master->dev); in try_to_bring_up_master()
188 devres_release_group(master->dev, NULL); in try_to_bring_up_master()
189 dev_info(master->dev, "master bind failed: %d\n", ret); in try_to_bring_up_master()
193 master->bound = true; in try_to_bring_up_master()
197 master_remove_components(master); in try_to_bring_up_master()
204 struct master *m; in try_to_bring_up_masters()
216 static void take_down_master(struct master *master) in take_down_master() argument
218 if (master->bound) { in take_down_master()
219 master->ops->unbind(master->dev); in take_down_master()
220 devres_release_group(master->dev, NULL); in take_down_master()
221 master->bound = false; in take_down_master()
224 master_remove_components(master); in take_down_master()
290 struct master *master; in component_master_add_with_match() local
303 master = kzalloc(sizeof(*master), GFP_KERNEL); in component_master_add_with_match()
304 if (!master) in component_master_add_with_match()
307 master->dev = dev; in component_master_add_with_match()
308 master->ops = ops; in component_master_add_with_match()
309 master->match = match; in component_master_add_with_match()
310 INIT_LIST_HEAD(&master->components); in component_master_add_with_match()
314 list_add(&master->node, &masters); in component_master_add_with_match()
316 ret = try_to_bring_up_master(master, NULL); in component_master_add_with_match()
320 list_del(&master->node); in component_master_add_with_match()
321 kfree(master); in component_master_add_with_match()
339 struct master *master; in component_master_del() local
342 master = __master_find(dev, ops); in component_master_del()
343 if (master) { in component_master_del()
344 take_down_master(master); in component_master_del()
346 list_del(&master->node); in component_master_del()
347 kfree(master); in component_master_del()
354 struct master *master, void *data) in component_unbind() argument
358 component->ops->unbind(component->dev, master->dev, data); in component_unbind()
367 struct master *master; in component_unbind_all() local
372 master = __master_find(master_dev, NULL); in component_unbind_all()
373 if (!master) in component_unbind_all()
376 list_for_each_entry_reverse(c, &master->components, master_node) in component_unbind_all()
377 component_unbind(c, master, data); in component_unbind_all()
381 static int component_bind(struct component *component, struct master *master, in component_bind() argument
391 if (!devres_open_group(master->dev, NULL, GFP_KERNEL)) in component_bind()
400 devres_release_group(master->dev, NULL); in component_bind()
404 dev_dbg(master->dev, "binding %s (ops %ps)\n", in component_bind()
407 ret = component->ops->bind(component->dev, master->dev, data); in component_bind()
418 devres_remove_group(master->dev, NULL); in component_bind()
420 dev_info(master->dev, "bound %s (ops %ps)\n", in component_bind()
424 devres_release_group(master->dev, NULL); in component_bind()
426 dev_err(master->dev, "failed to bind %s (ops %ps): %d\n", in component_bind()
435 struct master *master; in component_bind_all() local
441 master = __master_find(master_dev, NULL); in component_bind_all()
442 if (!master) in component_bind_all()
445 list_for_each_entry(c, &master->components, master_node) { in component_bind_all()
446 ret = component_bind(c, master, data); in component_bind_all()
452 list_for_each_entry_continue_reverse(c, &master->components, in component_bind_all()
454 component_unbind(c, master, data); in component_bind_all()
502 if (component && component->master) in component_del()
503 take_down_master(component->master); in component_del()