drivers/char/hw_random/arm_smccc_trng.c
Source file repositories/reference/linux-study-clean/drivers/char/hw_random/arm_smccc_trng.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/char/hw_random/arm_smccc_trng.c- Extension
.c- Size
- 2898 bytes
- Lines
- 123
- Domain
- Driver Families
- Bucket
- drivers/char
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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/bits.hlinux/device.hlinux/hw_random.hlinux/module.hlinux/platform_device.hlinux/arm-smccc.h
Detected Declarations
function Copyrightfunction smccc_trng_readfunction smccc_trng_probe
Annotated Snippet
switch ((int)res.a0) {
case SMCCC_RET_SUCCESS:
copied += copy_from_registers(buf + copied, &res,
bits / BITS_PER_BYTE);
tries = 0;
break;
case SMCCC_RET_TRNG_NO_ENTROPY:
if (!wait)
return copied;
tries++;
if (tries >= SMCCC_TRNG_MAX_TRIES)
return copied;
cond_resched();
break;
default:
return -EIO;
}
}
return copied;
}
static int smccc_trng_probe(struct platform_device *pdev)
{
struct hwrng *trng;
trng = devm_kzalloc(&pdev->dev, sizeof(*trng), GFP_KERNEL);
if (!trng)
return -ENOMEM;
trng->name = "smccc_trng";
trng->read = smccc_trng_read;
return devm_hwrng_register(&pdev->dev, trng);
}
static struct platform_driver smccc_trng_driver = {
.driver = {
.name = "smccc_trng",
},
.probe = smccc_trng_probe,
};
module_platform_driver(smccc_trng_driver);
MODULE_ALIAS("platform:smccc_trng");
MODULE_AUTHOR("Andre Przywara");
MODULE_DESCRIPTION("Arm SMCCC TRNG firmware interface support");
MODULE_LICENSE("GPL");
Annotation
- Immediate include surface: `linux/bits.h`, `linux/device.h`, `linux/hw_random.h`, `linux/module.h`, `linux/platform_device.h`, `linux/arm-smccc.h`.
- Detected declarations: `function Copyright`, `function smccc_trng_read`, `function smccc_trng_probe`.
- Atlas domain: Driver Families / drivers/char.
- Implementation status: source 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.