drivers/net/wireless/marvell/mwifiex/usb.c
Source file repositories/reference/linux-study-clean/drivers/net/wireless/marvell/mwifiex/usb.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/wireless/marvell/mwifiex/usb.c- Extension
.c- Size
- 44563 bytes
- Lines
- 1610
- 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
main.husb.h
Detected Declarations
function mwifiex_usb_recvfunction mwifiex_usb_rx_completefunction mwifiex_usb_tx_completefunction mwifiex_usb_submit_rx_urbfunction mwifiex_usb_freefunction mwifiex_usb_probefunction mwifiex_usb_suspendfunction mwifiex_usb_resumefunction mwifiex_usb_disconnectfunction mwifiex_usb_coredumpfunction mwifiex_write_data_syncfunction mwifiex_read_data_syncfunction mwifiex_usb_port_resyncfunction mwifiex_usb_is_port_readyfunction mwifiex_usb_data_sentfunction mwifiex_usb_construct_send_urbfunction mwifiex_usb_prepare_tx_aggr_skbfunction mwifiex_usb_aggr_tx_datafunction mwifiex_usb_tx_aggr_tmofunction mwifiex_usb_host_to_cardfunction mwifiex_usb_tx_initfunction mwifiex_usb_rx_initfunction mwifiex_register_devfunction mwifiex_usb_cleanup_tx_aggrfunction mwifiex_unregister_devfunction mwifiex_prog_fw_w_helperfunction mwifiex_usb_dnld_fwfunction mwifiex_submit_rx_urbfunction mwifiex_usb_cmd_event_completefunction mwifiex_pm_wakeup_cardfunction mwifiex_usb_submit_rem_rx_urbsfunction mwifiex_pm_wakeup_card_complete
Annotated Snippet
switch (recv_type) {
case MWIFIEX_USB_TYPE_CMD:
if (skb->len > MWIFIEX_SIZE_OF_CMD_BUFFER) {
mwifiex_dbg(adapter, ERROR,
"CMD: skb->len too large\n");
ret = -1;
goto exit_restore_skb;
} else if (!adapter->curr_cmd) {
mwifiex_dbg(adapter, WARN, "CMD: no curr_cmd\n");
if (adapter->ps_state == PS_STATE_SLEEP_CFM) {
mwifiex_process_sleep_confirm_resp(
adapter, skb->data,
skb->len);
ret = 0;
goto exit_restore_skb;
}
ret = -1;
goto exit_restore_skb;
}
adapter->curr_cmd->resp_skb = skb;
adapter->cmd_resp_received = true;
break;
case MWIFIEX_USB_TYPE_EVENT:
if (skb->len < sizeof(u32)) {
mwifiex_dbg(adapter, ERROR,
"EVENT: skb->len too small\n");
ret = -1;
goto exit_restore_skb;
}
skb_copy_from_linear_data(skb, &tmp, sizeof(u32));
adapter->event_cause = le32_to_cpu(tmp);
mwifiex_dbg(adapter, EVENT,
"event_cause %#x\n", adapter->event_cause);
if (skb->len > MAX_EVENT_SIZE) {
mwifiex_dbg(adapter, ERROR,
"EVENT: event body too large\n");
ret = -1;
goto exit_restore_skb;
}
memcpy(adapter->event_body, skb->data +
MWIFIEX_EVENT_HEADER_LEN, skb->len);
adapter->event_received = true;
adapter->event_skb = skb;
break;
default:
mwifiex_dbg(adapter, ERROR,
"unknown recv_type %#x\n", recv_type);
ret = -1;
goto exit_restore_skb;
}
break;
case MWIFIEX_USB_EP_DATA:
mwifiex_dbg(adapter, DATA, "%s: EP_DATA\n", __func__);
if (skb->len > MWIFIEX_RX_DATA_BUF_SIZE) {
mwifiex_dbg(adapter, ERROR,
"DATA: skb->len too large\n");
return -1;
}
skb_queue_tail(&adapter->rx_data_q, skb);
adapter->data_received = true;
atomic_inc(&adapter->rx_pending);
break;
default:
mwifiex_dbg(adapter, ERROR,
"%s: unknown endport %#x\n", __func__, ep);
return -1;
}
return -EINPROGRESS;
exit_restore_skb:
/* The buffer will be reused for further cmds/events */
skb_push(skb, INTF_HEADER_LEN);
return ret;
}
static void mwifiex_usb_rx_complete(struct urb *urb)
{
struct urb_context *context = (struct urb_context *)urb->context;
struct mwifiex_adapter *adapter = context->adapter;
struct sk_buff *skb = context->skb;
struct usb_card_rec *card;
int recv_length = urb->actual_length;
int size, status;
Annotation
- Immediate include surface: `main.h`, `usb.h`.
- Detected declarations: `function mwifiex_usb_recv`, `function mwifiex_usb_rx_complete`, `function mwifiex_usb_tx_complete`, `function mwifiex_usb_submit_rx_urb`, `function mwifiex_usb_free`, `function mwifiex_usb_probe`, `function mwifiex_usb_suspend`, `function mwifiex_usb_resume`, `function mwifiex_usb_disconnect`, `function mwifiex_usb_coredump`.
- 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.