drivers/acpi/glue.c
Source file repositories/reference/linux-study-clean/drivers/acpi/glue.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/acpi/glue.c- Extension
.c- Size
- 9830 bytes
- Lines
- 415
- Domain
- Driver Families
- Bucket
- drivers/acpi
- 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/acpi_iort.hlinux/export.hlinux/init.hlinux/list.hlinux/device.hlinux/slab.hlinux/rwsem.hlinux/acpi.hlinux/dma-mapping.hlinux/pci.hlinux/pci-acpi.hlinux/platform_device.hinternal.h
Detected Declarations
struct find_child_walk_datafunction register_acpi_bus_typefunction unregister_acpi_bus_typefunction match_anyfunction acpi_dev_has_childrenfunction find_child_checksfunction check_one_childfunction acpi_physnode_link_namefunction acpi_bind_onefunction acpi_unbind_onefunction list_for_each_entryfunction acpi_device_notifyfunction acpi_device_notify_removeexport register_acpi_bus_typeexport unregister_acpi_bus_typeexport acpi_find_child_deviceexport acpi_find_child_by_adrexport acpi_bind_oneexport acpi_unbind_one
Annotated Snippet
struct find_child_walk_data {
struct acpi_device *adev;
u64 address;
int score;
bool check_sta;
bool check_children;
};
static int check_one_child(struct acpi_device *adev, void *data)
{
struct find_child_walk_data *wd = data;
int score;
if (!adev->pnp.type.bus_address || acpi_device_adr(adev) != wd->address)
return 0;
if (!wd->adev) {
/*
* This is the first matching object, so save it. If it is not
* necessary to look for any other matching objects, stop the
* search.
*/
wd->adev = adev;
return !(wd->check_sta || wd->check_children);
}
/*
* There is more than one matching device object with the same _ADR
* value. That really is unexpected, so we are kind of beyond the scope
* of the spec here. We have to choose which one to return, though.
*
* First, get the score for the previously found object and terminate
* the walk if it is maximum.
*/
if (!wd->score) {
score = find_child_checks(wd->adev, wd->check_children);
if (score == FIND_CHILD_MAX_SCORE)
return 1;
wd->score = score;
}
/*
* Second, if the object that has just been found has a better score,
* replace the previously found one with it and terminate the walk if
* the new score is maximum.
*/
score = find_child_checks(adev, wd->check_children);
if (score > wd->score) {
wd->adev = adev;
if (score == FIND_CHILD_MAX_SCORE)
return 1;
wd->score = score;
}
/* Continue, because there may be better matches. */
return 0;
}
static struct acpi_device *acpi_find_child(struct acpi_device *parent,
u64 address, bool check_children,
bool check_sta)
{
struct find_child_walk_data wd = {
.address = address,
.check_children = check_children,
.check_sta = check_sta,
.adev = NULL,
.score = 0,
};
if (parent)
acpi_dev_for_each_child(parent, check_one_child, &wd);
return wd.adev;
}
struct acpi_device *acpi_find_child_device(struct acpi_device *parent,
u64 address, bool check_children)
{
return acpi_find_child(parent, address, check_children, true);
}
EXPORT_SYMBOL_GPL(acpi_find_child_device);
struct acpi_device *acpi_find_child_by_adr(struct acpi_device *adev,
acpi_bus_address adr)
{
return acpi_find_child(adev, adr, false, false);
}
EXPORT_SYMBOL_GPL(acpi_find_child_by_adr);
Annotation
- Immediate include surface: `linux/acpi_iort.h`, `linux/export.h`, `linux/init.h`, `linux/list.h`, `linux/device.h`, `linux/slab.h`, `linux/rwsem.h`, `linux/acpi.h`.
- Detected declarations: `struct find_child_walk_data`, `function register_acpi_bus_type`, `function unregister_acpi_bus_type`, `function match_any`, `function acpi_dev_has_children`, `function find_child_checks`, `function check_one_child`, `function acpi_physnode_link_name`, `function acpi_bind_one`, `function acpi_unbind_one`.
- Atlas domain: Driver Families / drivers/acpi.
- 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.