drivers/base/component.c
Source file repositories/reference/linux-study-clean/drivers/base/component.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/base/component.c- Extension
.c- Size
- 23238 bytes
- Lines
- 843
- Domain
- Driver Families
- Bucket
- drivers/base
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/component.hlinux/device.hlinux/list.hlinux/mutex.hlinux/of.hlinux/slab.hlinux/debugfs.h
Detected Declarations
struct componentstruct component_match_arraystruct component_matchstruct aggregate_devicestruct componentfunction component_devices_showfunction component_debug_initfunction component_debugfs_addfunction component_debugfs_delfunction component_debugfs_addfunction list_for_each_entryfunction find_componentsfunction remove_componentfunction try_to_bring_up_aggregate_devicefunction try_to_bring_up_mastersfunction list_for_each_entryfunction take_down_aggregate_devicefunction component_match_add_releasefunction component_release_offunction component_match_addfunction component_match_addfunction devm_component_match_releasefunction component_match_reallocfunction __component_match_addfunction component_addfunction component_add_typedfunction free_aggregate_devicefunction component_match_addfunction component_master_add_with_matchfunction component_master_is_boundfunction component_unbindfunction component_unbind_allfunction component_bindfunction component_bind_allfunction __component_addfunction component_bind_allfunction component_bind_allfunction component_addmodule init component_debug_initexport component_compare_ofexport component_release_ofexport component_compare_devexport component_compare_dev_nameexport component_match_add_releaseexport component_match_add_typedexport component_master_add_with_matchexport component_master_delexport component_master_is_bound
Annotated Snippet
core_initcall(component_debug_init);
static void component_debugfs_add(struct aggregate_device *m)
{
debugfs_create_file(dev_name(m->parent), 0444, component_debugfs_dir, m,
&component_devices_fops);
}
static void component_debugfs_del(struct aggregate_device *m)
{
debugfs_lookup_and_remove(dev_name(m->parent), component_debugfs_dir);
}
#else
static void component_debugfs_add(struct aggregate_device *m)
{ }
static void component_debugfs_del(struct aggregate_device *m)
{ }
#endif
static struct aggregate_device *__aggregate_find(struct device *parent,
const struct component_master_ops *ops)
{
struct aggregate_device *m;
list_for_each_entry(m, &aggregate_devices, node)
if (m->parent == parent && (!ops || m->ops == ops))
return m;
return NULL;
}
static struct component *find_component(struct aggregate_device *adev,
struct component_match_array *mc)
{
struct component *c;
list_for_each_entry(c, &component_list, node) {
if (c->adev && c->adev != adev)
continue;
if (mc->compare && mc->compare(c->dev, mc->data))
return c;
if (mc->compare_typed &&
mc->compare_typed(c->dev, c->subcomponent, mc->data))
return c;
}
return NULL;
}
static int find_components(struct aggregate_device *adev)
{
struct component_match *match = adev->match;
size_t i;
int ret = 0;
/*
* Scan the array of match functions and attach
* any components which are found to this adev.
*/
for (i = 0; i < match->num; i++) {
struct component_match_array *mc = &match->compare[i];
struct component *c;
dev_dbg(adev->parent, "Looking for component %zu\n", i);
if (match->compare[i].component)
continue;
c = find_component(adev, mc);
if (!c) {
ret = -ENXIO;
break;
}
dev_dbg(adev->parent, "found component %s, duplicate %u\n",
dev_name(c->dev), !!c->adev);
/* Attach this component to the adev */
match->compare[i].duplicate = !!c->adev;
match->compare[i].component = c;
c->adev = adev;
}
return ret;
}
Annotation
- Immediate include surface: `linux/component.h`, `linux/device.h`, `linux/list.h`, `linux/mutex.h`, `linux/of.h`, `linux/slab.h`, `linux/debugfs.h`.
- Detected declarations: `struct component`, `struct component_match_array`, `struct component_match`, `struct aggregate_device`, `struct component`, `function component_devices_show`, `function component_debug_init`, `function component_debugfs_add`, `function component_debugfs_del`, `function component_debugfs_add`.
- Atlas domain: Driver Families / drivers/base.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.