drivers/iommu/iommu-sysfs.c
Source file repositories/reference/linux-study-clean/drivers/iommu/iommu-sysfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iommu/iommu-sysfs.c- Extension
.c- Size
- 2975 bytes
- Lines
- 128
- Domain
- Driver Families
- Bucket
- drivers/iommu
- 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.
- 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/iommu.hlinux/init.hlinux/slab.h
Detected Declarations
function release_devicefunction iommu_dev_initfunction iommu_device_sysfs_addfunction iommu_device_sysfs_removefunction iommu_device_linkfunction iommu_device_unlinkexport iommu_device_sysfs_addexport iommu_device_sysfs_remove
Annotated Snippet
ret = device_add(iommu->dev);
if (ret)
goto error;
dev_set_drvdata(iommu->dev, iommu);
return 0;
error:
put_device(iommu->dev);
return ret;
}
EXPORT_SYMBOL_GPL(iommu_device_sysfs_add);
void iommu_device_sysfs_remove(struct iommu_device *iommu)
{
dev_set_drvdata(iommu->dev, NULL);
device_unregister(iommu->dev);
iommu->dev = NULL;
}
EXPORT_SYMBOL_GPL(iommu_device_sysfs_remove);
/*
* IOMMU drivers can indicate a device is managed by a given IOMMU using
* this interface. A link to the device will be created in the "devices"
* directory of the IOMMU device in sysfs and an "iommu" link will be
* created under the linked device, pointing back at the IOMMU device.
*/
int iommu_device_link(struct iommu_device *iommu, struct device *link)
{
int ret;
ret = sysfs_add_link_to_group(&iommu->dev->kobj, "devices",
&link->kobj, dev_name(link));
if (ret)
return ret;
ret = sysfs_create_link_nowarn(&link->kobj, &iommu->dev->kobj, "iommu");
if (ret)
sysfs_remove_link_from_group(&iommu->dev->kobj, "devices",
dev_name(link));
return ret;
}
void iommu_device_unlink(struct iommu_device *iommu, struct device *link)
{
sysfs_remove_link(&link->kobj, "iommu");
sysfs_remove_link_from_group(&iommu->dev->kobj, "devices", dev_name(link));
}
Annotation
- Immediate include surface: `linux/device.h`, `linux/iommu.h`, `linux/init.h`, `linux/slab.h`.
- Detected declarations: `function release_device`, `function iommu_dev_init`, `function iommu_device_sysfs_add`, `function iommu_device_sysfs_remove`, `function iommu_device_link`, `function iommu_device_unlink`, `export iommu_device_sysfs_add`, `export iommu_device_sysfs_remove`.
- Atlas domain: Driver Families / drivers/iommu.
- Implementation status: integration implementation candidate.
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.