drivers/net/wireless/realtek/rtw89/usb.c
Source file repositories/reference/linux-study-clean/drivers/net/wireless/realtek/rtw89/usb.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/wireless/realtek/rtw89/usb.c- Extension
.c- Size
- 33068 bytes
- Lines
- 1325
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/usb.hdebug.hmac.hreg.htxrx.husb.h
Detected Declarations
function __rtw89_usb_vendorreqfunction rtw89_usb_vendorreqfunction rtw89_usb_read_cmacfunction rtw89_usb_ops_read8function rtw89_usb_ops_read16function rtw89_usb_ops_read32function rtw89_usb_ops_write8function rtw89_usb_ops_write16function rtw89_usb_ops_write32function rtw89_usb_write32_quietfunction rtw89_usb_ops_check_and_reclaim_tx_resourcefunction rtw89_usb_write_port_completefunction rtw89_usb_write_portfunction rtw89_usb_tx_free_skbfunction rtw89_usb_ops_tx_kick_offfunction rtw89_usb_tx_write_fwcmdfunction rtw89_usb_ops_tx_writefunction rtw89_usb_rx_handlerfunction rtw89_usb_rx_resubmitfunction rtw89_usb_rx_resubmit_workfunction rtw89_usb_read_port_completefunction rtw89_usb_cancel_rx_bufsfunction rtw89_usb_cancel_tx_bufsfunction rtw89_usb_free_rx_bufsfunction rtw89_usb_alloc_rx_bufsfunction rtw89_usb_init_rxfunction rtw89_usb_deinit_rxfunction rtw89_usb_start_rxfunction rtw89_usb_init_txfunction rtw89_usb_deinit_txfunction rtw89_usb_ops_resetfunction rtw89_usb_ops_startfunction rtw89_usb_ops_stopfunction rtw89_usb_ops_mac_pre_initfunction rtw89_usb_ops_mac_pre_deinitfunction rtw89_usb_rx_agg_cfg_v1function rtw89_usb_rx_agg_cfg_v2function rtw89_usb_rx_agg_cfg_v3function rtw89_usb_rx_agg_cfgfunction rtw89_usb_ops_mac_post_initfunction rtw89_usb_ops_recalc_int_mitfunction rtw89_usb_ops_dump_err_statusfunction rtw89_usb_parsefunction rtw89_usb_intf_initfunction rtw89_usb_intf_deinitfunction rtw89_usb_switch_mode_axfunction rtw89_usb_switch_mode_befunction rtw89_usb_switch_mode
Annotated Snippet
if (reqtype == RTW89_USB_VENQT_READ) {
pipe = usb_rcvctrlpipe(udev, 0);
} else { /* RTW89_USB_VENQT_WRITE */
pipe = usb_sndctrlpipe(udev, 0);
memcpy(rtwusb->vendor_req_buf, data, len);
}
ret = usb_control_msg(udev, pipe, RTW89_USB_VENQT, reqtype,
value, index, rtwusb->vendor_req_buf,
len, 500);
if (ret == len) { /* Success */
atomic_set(&rtwusb->continual_io_error, 0);
if (reqtype == RTW89_USB_VENQT_READ)
memcpy(data, rtwusb->vendor_req_buf, len);
break;
}
if (ret == -ESHUTDOWN || ret == -ENODEV)
set_bit(RTW89_FLAG_UNPLUGGED, rtwdev->flags);
else if (ret < 0 && warn)
rtw89_warn(rtwdev,
"usb %s%u 0x%x fail ret=%d value=0x%x attempt=%d\n",
str_read_write(reqtype == RTW89_USB_VENQT_READ),
len * 8, addr, ret,
le32_to_cpup(rtwusb->vendor_req_buf),
attempt);
else if (ret > 0 && reqtype == RTW89_USB_VENQT_READ)
memcpy(data, rtwusb->vendor_req_buf, len);
if (atomic_inc_return(&rtwusb->continual_io_error) > 4) {
set_bit(RTW89_FLAG_UNPLUGGED, rtwdev->flags);
break;
}
}
}
static void rtw89_usb_vendorreq(struct rtw89_dev *rtwdev, u32 addr,
void *data, u16 len, u8 reqtype)
{
__rtw89_usb_vendorreq(rtwdev, addr, data, len, reqtype, true);
}
static u32 rtw89_usb_read_cmac(struct rtw89_dev *rtwdev, u32 addr)
{
u32 addr32, val32, shift;
__le32 data = 0;
int count;
addr32 = addr & ~0x3;
shift = (addr & 0x3) * 8;
for (count = 0; ; count++) {
rtw89_usb_vendorreq(rtwdev, addr32, &data, 4,
RTW89_USB_VENQT_READ);
val32 = le32_to_cpu(data);
if (val32 != RTW89_R32_DEAD)
break;
if (count >= MAC_REG_POOL_COUNT) {
rtw89_warn(rtwdev, "%s: addr %#x = %#x\n",
__func__, addr32, val32);
val32 = RTW89_R32_DEAD;
break;
}
rtw89_write32(rtwdev, R_AX_CK_EN, B_AX_CMAC_ALLCKEN);
}
return val32 >> shift;
}
static u8 rtw89_usb_ops_read8(struct rtw89_dev *rtwdev, u32 addr)
{
u8 data = 0;
if (ACCESS_CMAC(addr))
return rtw89_usb_read_cmac(rtwdev, addr);
rtw89_usb_vendorreq(rtwdev, addr, &data, 1, RTW89_USB_VENQT_READ);
return data;
}
static u16 rtw89_usb_ops_read16(struct rtw89_dev *rtwdev, u32 addr)
{
Annotation
- Immediate include surface: `linux/usb.h`, `debug.h`, `mac.h`, `reg.h`, `txrx.h`, `usb.h`.
- Detected declarations: `function __rtw89_usb_vendorreq`, `function rtw89_usb_vendorreq`, `function rtw89_usb_read_cmac`, `function rtw89_usb_ops_read8`, `function rtw89_usb_ops_read16`, `function rtw89_usb_ops_read32`, `function rtw89_usb_ops_write8`, `function rtw89_usb_ops_write16`, `function rtw89_usb_ops_write32`, `function rtw89_usb_write32_quiet`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: integration 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.