drivers/net/wireless/mediatek/mt76/util.h
Source file repositories/reference/linux-study-clean/drivers/net/wireless/mediatek/mt76/util.h
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/wireless/mediatek/mt76/util.h- Extension
.h- Size
- 2130 bytes
- Lines
- 116
- 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
linux/skbuff.hlinux/bitops.hlinux/bitfield.hnet/mac80211.h
Detected Declarations
struct mt76_workerfunction mt76_wcid_mask_setfunction mt76_wcid_mask_clearfunction mt76_skb_set_moredatafunction mt76_worker_setupfunction mt76_worker_schedulefunction mt76_worker_disablefunction mt76_worker_enablefunction mt76_worker_teardown
Annotated Snippet
#ifndef __MT76_UTIL_H
#define __MT76_UTIL_H
#include <linux/skbuff.h>
#include <linux/bitops.h>
#include <linux/bitfield.h>
#include <net/mac80211.h>
struct mt76_worker
{
struct task_struct *task;
void (*fn)(struct mt76_worker *);
unsigned long state;
};
enum {
MT76_WORKER_SCHEDULED,
MT76_WORKER_RUNNING,
};
#define MT76_INCR(_var, _size) \
(_var = (((_var) + 1) % (_size)))
int mt76_wcid_alloc(u32 *mask, int size);
static inline void
mt76_wcid_mask_set(u32 *mask, int idx)
{
mask[idx / 32] |= BIT(idx % 32);
}
static inline void
mt76_wcid_mask_clear(u32 *mask, int idx)
{
mask[idx / 32] &= ~BIT(idx % 32);
}
static inline void
mt76_skb_set_moredata(struct sk_buff *skb, bool enable)
{
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
if (enable)
hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_MOREDATA);
else
hdr->frame_control &= ~cpu_to_le16(IEEE80211_FCTL_MOREDATA);
}
int __mt76_worker_fn(void *ptr);
static inline int
mt76_worker_setup(struct ieee80211_hw *hw, struct mt76_worker *w,
void (*fn)(struct mt76_worker *),
const char *name)
{
const char *dev_name = wiphy_name(hw->wiphy);
int ret;
if (fn)
w->fn = fn;
w->task = kthread_run(__mt76_worker_fn, w,
"mt76-%s %s", name, dev_name);
if (IS_ERR(w->task)) {
ret = PTR_ERR(w->task);
w->task = NULL;
return ret;
}
return 0;
}
static inline void mt76_worker_schedule(struct mt76_worker *w)
{
if (!w->task)
return;
if (!test_and_set_bit(MT76_WORKER_SCHEDULED, &w->state) &&
!test_bit(MT76_WORKER_RUNNING, &w->state))
wake_up_process(w->task);
}
static inline void mt76_worker_disable(struct mt76_worker *w)
{
if (!w->task)
return;
kthread_park(w->task);
WRITE_ONCE(w->state, 0);
}
Annotation
- Immediate include surface: `linux/skbuff.h`, `linux/bitops.h`, `linux/bitfield.h`, `net/mac80211.h`.
- Detected declarations: `struct mt76_worker`, `function mt76_wcid_mask_set`, `function mt76_wcid_mask_clear`, `function mt76_skb_set_moredata`, `function mt76_worker_setup`, `function mt76_worker_schedule`, `function mt76_worker_disable`, `function mt76_worker_enable`, `function mt76_worker_teardown`.
- 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.