Lines Matching +full:sub +full:- +full:components
1 // SPDX-License-Identifier: GPL-2.0
16 * The component helper allows drivers to collect a pile of sub-devices,
18 * already provide functions to get hold of such components, e.g.
20 * subsystem-specific way to find a device is not available: The component
24 * the SoC on various components (scanout engines, blending blocks, transcoders
30 * Components are registered using component_add() and unregistered with
85 struct aggregate_device *m = s->private; in component_devices_show()
86 struct component_match *match = m->match; in component_devices_show()
90 seq_printf(s, "%-40s %20s\n", "aggregate_device name", "status"); in component_devices_show()
91 seq_puts(s, "-------------------------------------------------------------\n"); in component_devices_show()
92 seq_printf(s, "%-40s %20s\n\n", in component_devices_show()
93 dev_name(m->parent), m->bound ? "bound" : "not bound"); in component_devices_show()
95 seq_printf(s, "%-40s %20s\n", "device name", "status"); in component_devices_show()
96 seq_puts(s, "-------------------------------------------------------------\n"); in component_devices_show()
97 for (i = 0; i < match->num; i++) { in component_devices_show()
98 struct component *component = match->compare[i].component; in component_devices_show()
100 seq_printf(s, "%-40s %20s\n", in component_devices_show()
101 component ? dev_name(component->dev) : "(unknown)", in component_devices_show()
102 component ? (component->bound ? "bound" : "not bound") : "not registered"); in component_devices_show()
122 debugfs_create_file(dev_name(m->parent), 0444, component_debugfs_dir, m, in component_debugfs_add()
128 debugfs_lookup_and_remove(dev_name(m->parent), component_debugfs_dir); in component_debugfs_del()
147 if (m->parent == parent && (!ops || m->ops == ops)) in __aggregate_find()
159 if (c->adev && c->adev != adev) in find_component()
162 if (mc->compare && mc->compare(c->dev, mc->data)) in find_component()
165 if (mc->compare_typed && in find_component()
166 mc->compare_typed(c->dev, c->subcomponent, mc->data)) in find_component()
175 struct component_match *match = adev->match; in find_components()
181 * any components which are found to this adev. in find_components()
183 for (i = 0; i < match->num; i++) { in find_components()
184 struct component_match_array *mc = &match->compare[i]; in find_components()
187 dev_dbg(adev->parent, "Looking for component %zu\n", i); in find_components()
189 if (match->compare[i].component) in find_components()
194 ret = -ENXIO; in find_components()
198 dev_dbg(adev->parent, "found component %s, duplicate %u\n", in find_components()
199 dev_name(c->dev), !!c->adev); in find_components()
202 match->compare[i].duplicate = !!c->adev; in find_components()
203 match->compare[i].component = c; in find_components()
204 c->adev = adev; in find_components()
215 for (i = 0; i < adev->match->num; i++) in remove_component()
216 if (adev->match->compare[i].component == c) in remove_component()
217 adev->match->compare[i].component = NULL; in remove_component()
225 * Returns 1 for successful bringup, 0 if not ready, or -ve errno.
232 dev_dbg(adev->parent, "trying to bring up adev\n"); in try_to_bring_up_aggregate_device()
235 dev_dbg(adev->parent, "master has incomplete components\n"); in try_to_bring_up_aggregate_device()
239 if (component && component->adev != adev) { in try_to_bring_up_aggregate_device()
240 dev_dbg(adev->parent, "master is not for this component (%s)\n", in try_to_bring_up_aggregate_device()
241 dev_name(component->dev)); in try_to_bring_up_aggregate_device()
245 if (!devres_open_group(adev->parent, adev, GFP_KERNEL)) in try_to_bring_up_aggregate_device()
246 return -ENOMEM; in try_to_bring_up_aggregate_device()
248 /* Found all components */ in try_to_bring_up_aggregate_device()
249 ret = adev->ops->bind(adev->parent); in try_to_bring_up_aggregate_device()
251 devres_release_group(adev->parent, NULL); in try_to_bring_up_aggregate_device()
252 if (ret != -EPROBE_DEFER) in try_to_bring_up_aggregate_device()
253 dev_info(adev->parent, "adev bind failed: %d\n", ret); in try_to_bring_up_aggregate_device()
257 devres_close_group(adev->parent, NULL); in try_to_bring_up_aggregate_device()
258 adev->bound = true; in try_to_bring_up_aggregate_device()
268 if (!adev->bound) { in try_to_bring_up_masters()
280 if (adev->bound) { in take_down_aggregate_device()
281 adev->ops->unbind(adev->parent); in take_down_aggregate_device()
282 devres_release_group(adev->parent, adev); in take_down_aggregate_device()
283 adev->bound = false; in take_down_aggregate_device()
288 * component_compare_of - A common component compare function for of_node
303 * component_release_of - A common component release function for of_node
316 * component_compare_dev - A common component compare function for dev
330 * component_compare_dev_name - A common component compare function for device name
349 for (i = 0; i < match->num; i++) { in devm_component_match_release()
350 struct component_match_array *mc = &match->compare[i]; in devm_component_match_release()
352 if (mc->release) in devm_component_match_release()
353 mc->release(parent, mc->data); in devm_component_match_release()
356 kfree(match->compare); in devm_component_match_release()
363 if (match->alloc == num) in component_match_realloc()
368 return -ENOMEM; in component_match_realloc()
370 if (match->compare) { in component_match_realloc()
371 memcpy(new, match->compare, sizeof(*new) * in component_match_realloc()
372 min(match->num, num)); in component_match_realloc()
373 kfree(match->compare); in component_match_realloc()
375 match->compare = new; in component_match_realloc()
376 match->alloc = num; in component_match_realloc()
397 *matchptr = ERR_PTR(-ENOMEM); in __component_match_add()
406 if (match->num == match->alloc) { in __component_match_add()
407 size_t new_size = match->alloc + 16; in __component_match_add()
417 match->compare[match->num].compare = compare; in __component_match_add()
418 match->compare[match->num].compare_typed = compare_typed; in __component_match_add()
419 match->compare[match->num].release = release; in __component_match_add()
420 match->compare[match->num].data = compare_data; in __component_match_add()
421 match->compare[match->num].component = NULL; in __component_match_add()
422 match->num++; in __component_match_add()
426 * component_match_add_release - add a component match entry with release callback
430 * @compare: compare function to match against all components
436 * only matches against components added with component_add().
456 * component_match_add_typed - add a component match entry for a typed component
459 * @compare_typed: compare function to match against all typed components
465 * only matches against components added with component_add_typed().
483 struct component_match *match = adev->match; in free_aggregate_device()
487 list_del(&adev->node); in free_aggregate_device()
490 for (i = 0; i < match->num; i++) { in free_aggregate_device()
491 struct component *c = match->compare[i].component; in free_aggregate_device()
493 c->adev = NULL; in free_aggregate_device()
501 * component_master_add_with_match - register an aggregate driver
506 * Registers a new aggregate driver consisting of the components added to @match
507 * by calling one of the component_match_add() functions. Once all components in
520 ret = component_match_realloc(match, match->num); in component_master_add_with_match()
526 return -ENOMEM; in component_master_add_with_match()
528 adev->parent = parent; in component_master_add_with_match()
529 adev->ops = ops; in component_master_add_with_match()
530 adev->match = match; in component_master_add_with_match()
535 list_add(&adev->node, &aggregate_devices); in component_master_add_with_match()
549 * component_master_del - unregister an aggregate driver
575 WARN_ON(!component->bound); in component_unbind()
577 if (component->ops && component->ops->unbind) in component_unbind()
578 component->ops->unbind(component->dev, adev->parent, data); in component_unbind()
579 component->bound = false; in component_unbind()
582 devres_release_group(component->dev, component); in component_unbind()
586 * component_unbind_all - unbind all components of an aggregate driver
588 * @data: opaque pointer, passed to all components
590 * Unbinds all components of the aggregate device by passing @data to their
606 /* Unbind components in reverse order */ in component_unbind_all()
607 for (i = adev->match->num; i--; ) in component_unbind_all()
608 if (!adev->match->compare[i].duplicate) { in component_unbind_all()
609 c = adev->match->compare[i].component; in component_unbind_all()
622 * This allows us to roll-back a failed component without in component_bind()
625 if (!devres_open_group(adev->parent, NULL, GFP_KERNEL)) in component_bind()
626 return -ENOMEM; in component_bind()
630 * to release the resources claimed against the sub-device in component_bind()
633 if (!devres_open_group(component->dev, component, GFP_KERNEL)) { in component_bind()
634 devres_release_group(adev->parent, NULL); in component_bind()
635 return -ENOMEM; in component_bind()
638 dev_dbg(adev->parent, "binding %s (ops %ps)\n", in component_bind()
639 dev_name(component->dev), component->ops); in component_bind()
641 ret = component->ops->bind(component->dev, adev->parent, data); in component_bind()
643 component->bound = true; in component_bind()
651 devres_close_group(component->dev, NULL); in component_bind()
652 devres_remove_group(adev->parent, NULL); in component_bind()
654 dev_info(adev->parent, "bound %s (ops %ps)\n", in component_bind()
655 dev_name(component->dev), component->ops); in component_bind()
657 devres_release_group(component->dev, NULL); in component_bind()
658 devres_release_group(adev->parent, NULL); in component_bind()
660 if (ret != -EPROBE_DEFER) in component_bind()
661 dev_err(adev->parent, "failed to bind %s (ops %ps): %d\n", in component_bind()
662 dev_name(component->dev), component->ops, ret); in component_bind()
669 * component_bind_all - bind all components of an aggregate driver
671 * @data: opaque pointer, passed to all components
673 * Binds all components of the aggregate @dev by passing @data to their
688 return -EINVAL; in component_bind_all()
690 /* Bind components in match order */ in component_bind_all()
691 for (i = 0; i < adev->match->num; i++) in component_bind_all()
692 if (!adev->match->compare[i].duplicate) { in component_bind_all()
693 c = adev->match->compare[i].component; in component_bind_all()
700 for (; i > 0; i--) in component_bind_all()
701 if (!adev->match->compare[i - 1].duplicate) { in component_bind_all()
702 c = adev->match->compare[i - 1].component; in component_bind_all()
719 return -ENOMEM; in __component_add()
721 component->ops = ops; in __component_add()
722 component->dev = dev; in __component_add()
723 component->subcomponent = subcomponent; in __component_add()
728 list_add_tail(&component->node, &component_list); in __component_add()
732 if (component->adev) in __component_add()
733 remove_component(component->adev, component); in __component_add()
734 list_del(&component->node); in __component_add()
744 * component_add_typed - register a component
754 * components registered on the same device @dev. These components are match
766 return -EINVAL; in component_add_typed()
773 * component_add - register a component
785 * components on the same device.
794 * component_del - unregister a component
800 * all its components, to be unbound.
808 if (c->dev == dev && c->ops == ops) { in component_del()
809 list_del(&c->node); in component_del()
814 if (component && component->adev) { in component_del()
815 take_down_aggregate_device(component->adev); in component_del()
816 remove_component(component->adev, component); in component_del()