drivers/net/wireless/ath/ath9k/rng.c
Source file repositories/reference/linux-study-clean/drivers/net/wireless/ath/ath9k/rng.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/wireless/ath/ath9k/rng.c- Extension
.c- Size
- 3174 bytes
- Lines
- 123
- Domain
- Driver Families
- Bucket
- drivers/net
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/hw_random.hlinux/kthread.hath9k.hhw.har9003_phy.h
Detected Declarations
function Copyrightfunction ath9k_rng_delay_getfunction ath9k_rng_readfunction ath9k_rng_startfunction ath9k_rng_stop
Annotated Snippet
if ((max & 3UL) && ath9k_rng_data_read(sc, &word, 1)) {
memcpy(buf + bytes_read, &word, max & 3UL);
bytes_read += max & 3UL;
memzero_explicit(&word, sizeof(word));
}
if (!wait || !max || likely(bytes_read) || fail_stats > 110)
break;
if (hwrng_msleep(rng, ath9k_rng_delay_get(++fail_stats)))
break;
}
if (wait && !bytes_read && max)
bytes_read = -EIO;
return bytes_read;
}
void ath9k_rng_start(struct ath_softc *sc)
{
static atomic_t serial = ATOMIC_INIT(0);
struct ath_hw *ah = sc->sc_ah;
if (sc->rng_ops.read)
return;
if (!AR_SREV_9300_20_OR_LATER(ah))
return;
snprintf(sc->rng_name, sizeof(sc->rng_name), "ath9k_%u",
(atomic_inc_return(&serial) - 1) & U16_MAX);
sc->rng_ops.name = sc->rng_name;
sc->rng_ops.read = ath9k_rng_read;
sc->rng_ops.quality = 320;
if (devm_hwrng_register(sc->dev, &sc->rng_ops))
sc->rng_ops.read = NULL;
}
void ath9k_rng_stop(struct ath_softc *sc)
{
if (sc->rng_ops.read) {
devm_hwrng_unregister(sc->dev, &sc->rng_ops);
sc->rng_ops.read = NULL;
}
}
Annotation
- Immediate include surface: `linux/hw_random.h`, `linux/kthread.h`, `ath9k.h`, `hw.h`, `ar9003_phy.h`.
- Detected declarations: `function Copyright`, `function ath9k_rng_delay_get`, `function ath9k_rng_read`, `function ath9k_rng_start`, `function ath9k_rng_stop`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source 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.