drivers/net/wireless/ath/dfs_pri_detector.c
Source file repositories/reference/linux-study-clean/drivers/net/wireless/ath/dfs_pri_detector.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/wireless/ath/dfs_pri_detector.c- Extension
.c- Size
- 10979 bytes
- Lines
- 437
- 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.
- 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/slab.hlinux/spinlock.hath.hdfs_pattern_detector.hdfs_pri_detector.h
Detected Declarations
struct pulse_elemfunction pde_get_multiplefunction pool_register_reffunction pool_deregister_reffunction list_for_each_entry_safefunction list_for_each_entry_safefunction pool_put_pulse_elemfunction pool_put_pseq_elemfunction pulse_queue_dequeuefunction pulse_queue_check_windowfunction pulse_queue_enqueuefunction pseq_handler_create_sequencesfunction list_for_each_entry_continuefunction pseq_handler_add_to_existing_seqsfunction pseq_handler_check_detectionfunction list_for_each_entryfunction pri_detector_resetfunction pri_detector_exit
Annotated Snippet
struct pulse_elem {
struct list_head head;
u64 ts;
};
/*
* pde_get_multiple() - get number of multiples considering a given tolerance
* Return value: factor if abs(val - factor*fraction) <= tolerance, 0 otherwise
*/
static u32 pde_get_multiple(u32 val, u32 fraction, u32 tolerance)
{
u32 remainder;
u32 factor;
u32 delta;
if (fraction == 0)
return 0;
delta = (val < fraction) ? (fraction - val) : (val - fraction);
if (delta <= tolerance)
/* val and fraction are within tolerance */
return 1;
factor = val / fraction;
remainder = val % fraction;
if (remainder > tolerance) {
/* no exact match */
if ((fraction - remainder) <= tolerance)
/* remainder is within tolerance */
factor++;
else
factor = 0;
}
return factor;
}
/*
* DOC: Singleton Pulse and Sequence Pools
*
* Instances of pri_sequence and pulse_elem are kept in singleton pools to
* reduce the number of dynamic allocations. They are shared between all
* instances and grow up to the peak number of simultaneously used objects.
*
* Memory is freed after all references to the pools are released.
*/
static u32 singleton_pool_references;
static LIST_HEAD(pulse_pool);
static LIST_HEAD(pseq_pool);
static DEFINE_SPINLOCK(pool_lock);
static void pool_register_ref(void)
{
spin_lock_bh(&pool_lock);
singleton_pool_references++;
DFS_POOL_STAT_INC(pool_reference);
spin_unlock_bh(&pool_lock);
}
static void pool_deregister_ref(void)
{
spin_lock_bh(&pool_lock);
singleton_pool_references--;
DFS_POOL_STAT_DEC(pool_reference);
if (singleton_pool_references == 0) {
/* free singleton pools with no references left */
struct pri_sequence *ps, *ps0;
struct pulse_elem *p, *p0;
list_for_each_entry_safe(p, p0, &pulse_pool, head) {
list_del(&p->head);
DFS_POOL_STAT_DEC(pulse_allocated);
kfree(p);
}
list_for_each_entry_safe(ps, ps0, &pseq_pool, head) {
list_del(&ps->head);
DFS_POOL_STAT_DEC(pseq_allocated);
kfree(ps);
}
}
spin_unlock_bh(&pool_lock);
}
static void pool_put_pulse_elem(struct pulse_elem *pe)
{
spin_lock_bh(&pool_lock);
list_add(&pe->head, &pulse_pool);
DFS_POOL_STAT_DEC(pulse_used);
spin_unlock_bh(&pool_lock);
}
Annotation
- Immediate include surface: `linux/slab.h`, `linux/spinlock.h`, `ath.h`, `dfs_pattern_detector.h`, `dfs_pri_detector.h`.
- Detected declarations: `struct pulse_elem`, `function pde_get_multiple`, `function pool_register_ref`, `function pool_deregister_ref`, `function list_for_each_entry_safe`, `function list_for_each_entry_safe`, `function pool_put_pulse_elem`, `function pool_put_pseq_elem`, `function pulse_queue_dequeue`, `function pulse_queue_check_window`.
- 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.