drivers/char/hw_random/omap3-rom-rng.c
Source file repositories/reference/linux-study-clean/drivers/char/hw_random/omap3-rom-rng.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/char/hw_random/omap3-rom-rng.c- Extension
.c- Size
- 4143 bytes
- Lines
- 182
- 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/module.hlinux/init.hlinux/random.hlinux/hw_random.hlinux/workqueue.hlinux/clk.hlinux/err.hlinux/io.hlinux/of.hlinux/platform_device.hlinux/pm_runtime.h
Detected Declarations
struct omap_rom_rngfunction omap3_rom_rng_readfunction omap_rom_rng_runtime_suspendfunction omap_rom_rng_runtime_resumefunction omap_rom_rng_finishfunction omap3_rom_rng_probe
Annotated Snippet
struct omap_rom_rng {
struct clk *clk;
struct device *dev;
struct hwrng ops;
u32 (*rom_rng_call)(u32 ptr, u32 count, u32 flag);
};
static int omap3_rom_rng_read(struct hwrng *rng, void *data, size_t max, bool w)
{
struct omap_rom_rng *ddata;
u32 ptr;
int r;
ddata = (struct omap_rom_rng *)rng->priv;
r = pm_runtime_get_sync(ddata->dev);
if (r < 0) {
pm_runtime_put_noidle(ddata->dev);
return r;
}
ptr = virt_to_phys(data);
r = ddata->rom_rng_call(ptr, 4, RNG_GEN_HW);
if (r != 0)
r = -EINVAL;
else
r = 4;
pm_runtime_put_autosuspend(ddata->dev);
return r;
}
static int __maybe_unused omap_rom_rng_runtime_suspend(struct device *dev)
{
struct omap_rom_rng *ddata;
int r;
ddata = dev_get_drvdata(dev);
r = ddata->rom_rng_call(0, 0, RNG_RESET);
if (r != 0)
dev_err(dev, "reset failed: %d\n", r);
clk_disable_unprepare(ddata->clk);
return 0;
}
static int __maybe_unused omap_rom_rng_runtime_resume(struct device *dev)
{
struct omap_rom_rng *ddata;
int r;
ddata = dev_get_drvdata(dev);
r = clk_prepare_enable(ddata->clk);
if (r < 0)
return r;
r = ddata->rom_rng_call(0, 0, RNG_GEN_PRNG_HW_INIT);
if (r != 0) {
clk_disable_unprepare(ddata->clk);
dev_err(dev, "HW init failed: %d\n", r);
return -EIO;
}
return 0;
}
static void omap_rom_rng_finish(void *data)
{
struct omap_rom_rng *ddata = data;
pm_runtime_dont_use_autosuspend(ddata->dev);
pm_runtime_disable(ddata->dev);
}
static int omap3_rom_rng_probe(struct platform_device *pdev)
{
struct omap_rom_rng *ddata;
int ret = 0;
ddata = devm_kzalloc(&pdev->dev, sizeof(*ddata), GFP_KERNEL);
if (!ddata)
return -ENOMEM;
ddata->dev = &pdev->dev;
Annotation
- Immediate include surface: `linux/module.h`, `linux/init.h`, `linux/random.h`, `linux/hw_random.h`, `linux/workqueue.h`, `linux/clk.h`, `linux/err.h`, `linux/io.h`.
- Detected declarations: `struct omap_rom_rng`, `function omap3_rom_rng_read`, `function omap_rom_rng_runtime_suspend`, `function omap_rom_rng_runtime_resume`, `function omap_rom_rng_finish`, `function omap3_rom_rng_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.