drivers/net/wireless/broadcom/b43/ppr.c
Source file repositories/reference/linux-study-clean/drivers/net/wireless/broadcom/b43/ppr.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/wireless/broadcom/b43/ppr.c- Extension
.c- Size
- 4950 bytes
- Lines
- 191
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
ppr.hb43.h
Detected Declarations
function b43_ppr_clearfunction b43_ppr_addfunction ppr_for_each_entryfunction b43_ppr_apply_maxfunction ppr_for_each_entryfunction b43_ppr_apply_minfunction ppr_for_each_entryfunction b43_ppr_get_maxfunction ppr_for_each_entryfunction b43_ppr_load_max_from_sprom
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Broadcom B43 wireless driver
* PPR (Power Per Rate) management
*
* Copyright (c) 2014 Rafał Miłecki <zajec5@gmail.com>
*/
#include "ppr.h"
#include "b43.h"
#define ppr_for_each_entry(ppr, i, entry) \
for (i = 0, entry = &(ppr)->__all_rates[i]; \
i < B43_PPR_RATES_NUM; \
i++, entry++)
void b43_ppr_clear(struct b43_wldev *dev, struct b43_ppr *ppr)
{
memset(ppr, 0, sizeof(*ppr));
/* Compile-time PPR check */
BUILD_BUG_ON(sizeof(struct b43_ppr) != B43_PPR_RATES_NUM * sizeof(u8));
}
void b43_ppr_add(struct b43_wldev *dev, struct b43_ppr *ppr, int diff)
{
int i;
u8 *rate;
ppr_for_each_entry(ppr, i, rate) {
*rate = clamp_val(*rate + diff, 0, 127);
}
}
void b43_ppr_apply_max(struct b43_wldev *dev, struct b43_ppr *ppr, u8 max)
{
int i;
u8 *rate;
ppr_for_each_entry(ppr, i, rate) {
*rate = min(*rate, max);
}
}
void b43_ppr_apply_min(struct b43_wldev *dev, struct b43_ppr *ppr, u8 min)
{
int i;
u8 *rate;
ppr_for_each_entry(ppr, i, rate) {
*rate = max(*rate, min);
}
}
u8 b43_ppr_get_max(struct b43_wldev *dev, struct b43_ppr *ppr)
{
u8 res = 0;
int i;
u8 *rate;
ppr_for_each_entry(ppr, i, rate) {
res = max(*rate, res);
}
return res;
}
bool b43_ppr_load_max_from_sprom(struct b43_wldev *dev, struct b43_ppr *ppr,
enum b43_band band)
{
struct b43_ppr_rates *rates = &ppr->rates;
struct ssb_sprom *sprom = dev->dev->bus_sprom;
struct b43_phy *phy = &dev->phy;
u8 maxpwr, off;
u32 sprom_ofdm_po;
u16 *sprom_mcs_po;
u8 extra_cdd_po, extra_stbc_po;
int i;
switch (band) {
case B43_BAND_2G:
maxpwr = min(sprom->core_pwr_info[0].maxpwr_2g,
sprom->core_pwr_info[1].maxpwr_2g);
sprom_ofdm_po = sprom->ofdm2gpo;
sprom_mcs_po = sprom->mcs2gpo;
extra_cdd_po = (sprom->cddpo >> 0) & 0xf;
extra_stbc_po = (sprom->stbcpo >> 0) & 0xf;
break;
case B43_BAND_5G_LO:
maxpwr = min(sprom->core_pwr_info[0].maxpwr_5gl,
Annotation
- Immediate include surface: `ppr.h`, `b43.h`.
- Detected declarations: `function b43_ppr_clear`, `function b43_ppr_add`, `function ppr_for_each_entry`, `function b43_ppr_apply_max`, `function ppr_for_each_entry`, `function b43_ppr_apply_min`, `function ppr_for_each_entry`, `function b43_ppr_get_max`, `function ppr_for_each_entry`, `function b43_ppr_load_max_from_sprom`.
- Atlas domain: Driver Families / drivers/net.
- 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.