drivers/thunderbolt/domain.c
Source file repositories/reference/linux-study-clean/drivers/thunderbolt/domain.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/thunderbolt/domain.c- Extension
.c- Size
- 21358 bytes
- Lines
- 887
- Domain
- Driver Families
- Bucket
- drivers/thunderbolt
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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/device.hlinux/idr.hlinux/module.hlinux/pm_runtime.hlinux/slab.hlinux/random.hcrypto/sha2.hcrypto/utils.htb.h
Detected Declarations
function match_service_idfunction tb_service_matchfunction tb_service_probefunction tb_service_removefunction tb_service_shutdownfunction boot_acl_showfunction boot_acl_storefunction deauthorization_showfunction iommu_dma_protection_showfunction security_showfunction domain_attr_is_visiblefunction tb_domain_releasefunction tb_domain_event_cbfunction tb_domain_allocfunction tb_domain_addfunction tb_domain_removefunction tb_domain_suspend_noirqfunction tb_domain_resume_noirqfunction tb_domain_suspendfunction tb_domain_freeze_noirqfunction tb_domain_thaw_noirqfunction tb_domain_completefunction tb_domain_runtime_suspendfunction tb_domain_runtime_resumefunction tb_domain_disapprove_switchfunction tb_domain_approve_switchfunction tb_domain_approve_switch_keyfunction tb_domain_challenge_switch_keyfunction tb_domain_disconnect_pcie_pathsfunction tb_domain_approve_xdomain_pathsfunction tb_domain_disconnect_xdomain_pathsfunction disconnect_xdomainfunction tb_domain_disconnect_all_pathsfunction tb_domain_initfunction tb_domain_exit
Annotated Snippet
const struct device_driver *drv)
{
const struct tb_service_driver *driver;
const struct tb_service_id *ids;
struct tb_service *svc;
svc = tb_to_service(dev);
if (!svc)
return NULL;
driver = container_of_const(drv, struct tb_service_driver, driver);
if (!driver->id_table)
return NULL;
for (ids = driver->id_table; ids->match_flags != 0; ids++) {
if (match_service_id(ids, svc))
return ids;
}
return NULL;
}
static int tb_service_match(struct device *dev, const struct device_driver *drv)
{
return !!__tb_service_match(dev, drv);
}
static int tb_service_probe(struct device *dev)
{
struct tb_service *svc = tb_to_service(dev);
struct tb_service_driver *driver;
const struct tb_service_id *id;
driver = container_of(dev->driver, struct tb_service_driver, driver);
id = __tb_service_match(dev, &driver->driver);
return driver->probe(svc, id);
}
static void tb_service_remove(struct device *dev)
{
struct tb_service *svc = tb_to_service(dev);
struct tb_service_driver *driver;
driver = container_of(dev->driver, struct tb_service_driver, driver);
if (driver->remove)
driver->remove(svc);
}
static void tb_service_shutdown(struct device *dev)
{
struct tb_service_driver *driver;
struct tb_service *svc;
svc = tb_to_service(dev);
if (!svc || !dev->driver)
return;
driver = container_of(dev->driver, struct tb_service_driver, driver);
if (driver->shutdown)
driver->shutdown(svc);
}
static const char * const tb_security_names[] = {
[TB_SECURITY_NONE] = "none",
[TB_SECURITY_USER] = "user",
[TB_SECURITY_SECURE] = "secure",
[TB_SECURITY_DPONLY] = "dponly",
[TB_SECURITY_USBONLY] = "usbonly",
[TB_SECURITY_NOPCIE] = "nopcie",
};
static ssize_t boot_acl_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct tb *tb = container_of(dev, struct tb, dev);
uuid_t *uuids;
ssize_t ret;
int i;
uuids = kzalloc_objs(uuid_t, tb->nboot_acl);
if (!uuids)
return -ENOMEM;
pm_runtime_get_sync(&tb->dev);
if (mutex_lock_interruptible(&tb->lock)) {
ret = -ERESTARTSYS;
goto out;
}
Annotation
- Immediate include surface: `linux/device.h`, `linux/idr.h`, `linux/module.h`, `linux/pm_runtime.h`, `linux/slab.h`, `linux/random.h`, `crypto/sha2.h`, `crypto/utils.h`.
- Detected declarations: `function match_service_id`, `function tb_service_match`, `function tb_service_probe`, `function tb_service_remove`, `function tb_service_shutdown`, `function boot_acl_show`, `function boot_acl_store`, `function deauthorization_show`, `function iommu_dma_protection_show`, `function security_show`.
- Atlas domain: Driver Families / drivers/thunderbolt.
- Implementation status: pattern 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.