drivers/net/wireless/ti/wlcore/cmd.c
Source file repositories/reference/linux-study-clean/drivers/net/wireless/ti/wlcore/cmd.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/wireless/ti/wlcore/cmd.c- Extension
.c- Size
- 48974 bytes
- Lines
- 2077
- 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/module.hlinux/platform_device.hlinux/pm_runtime.hlinux/spi/spi.hlinux/etherdevice.hlinux/ieee80211.hlinux/slab.hwlcore.hdebug.hio.hacx.hwl12xx_80211.hcmd.hevent.htx.hhw_ops.h
Detected Declarations
function Copyrightfunction wlcore_cmd_send_failsafefunction wl1271_cmd_sendfunction occursfunction wl12xx_cmd_role_enablefunction wl12xx_cmd_role_disablefunction wlcore_get_new_session_idfunction wl12xx_allocate_linkfunction wl12xx_free_linkfunction wlcore_get_native_channel_typefunction wl12xx_cmd_role_start_devfunction wl12xx_cmd_role_stop_devfunction wl12xx_cmd_role_start_stafunction wl12xx_cmd_role_stop_stafunction wl12xx_cmd_role_start_apfunction wl12xx_cmd_role_stop_apfunction wl12xx_cmd_role_start_ibssfunction wl1271_cmd_testfunction wl1271_cmd_interrogatefunction wlcore_cmd_configure_failsafefunction wl1271_cmd_configurefunction wl1271_cmd_data_pathfunction wl1271_cmd_ps_modefunction wl1271_cmd_template_setfunction wl12xx_cmd_build_null_datafunction wl12xx_cmd_build_klv_null_datafunction wl1271_cmd_build_ps_pollfunction wl12xx_cmd_build_probe_reqfunction wl1271_cmd_build_arp_rspfunction wl1271_build_qos_null_datafunction wl12xx_cmd_set_default_wep_keyfunction wl1271_cmd_set_sta_keyfunction wl1271_cmd_set_ap_keyfunction wl12xx_cmd_set_peer_statefunction wl12xx_cmd_add_peerfunction wl12xx_cmd_remove_peerfunction wlcore_get_reg_conf_ch_idxfunction wlcore_set_pending_regdomain_chfunction wlcore_cmd_regdomain_config_lockedfunction wl12xx_cmd_config_fwlogfunction wl12xx_cmd_stop_fwlogfunction wl12xx_cmd_rocfunction wl12xx_cmd_crocfunction wl12xx_rocfunction wl12xx_crocfunction wl12xx_cmd_stop_channel_switchfunction wl12xx_start_devfunction wl12xx_stop_dev
Annotated Snippet
if (time_after(jiffies, timeout)) {
wl1271_error("command complete timeout");
return -ETIMEDOUT;
}
poll_count++;
if (poll_count < WL1271_CMD_FAST_POLL_COUNT)
udelay(10);
else
msleep(1);
ret = wlcore_read_reg(wl, REG_INTERRUPT_NO_CLEAR, &intr);
if (ret < 0)
return ret;
}
/* read back the status code of the command */
if (res_len == 0)
res_len = sizeof(struct wl1271_cmd_header);
ret = wlcore_read(wl, wl->cmd_box_addr, cmd, res_len, false);
if (ret < 0)
return ret;
status = le16_to_cpu(cmd->status);
ret = wlcore_write_reg(wl, REG_INTERRUPT_ACK,
WL1271_ACX_INTR_CMD_COMPLETE);
if (ret < 0)
return ret;
return status;
}
/*
* send command to fw and return cmd status on success
* valid_rets contains a bitmap of allowed error codes
*/
static int wlcore_cmd_send_failsafe(struct wl1271 *wl, u16 id, void *buf,
size_t len, size_t res_len,
unsigned long valid_rets)
{
int ret = __wlcore_cmd_send(wl, id, buf, len, res_len);
if (ret < 0)
goto fail;
/* success is always a valid status */
valid_rets |= BIT(CMD_STATUS_SUCCESS);
if (ret >= MAX_COMMAND_STATUS ||
!test_bit(ret, &valid_rets)) {
wl1271_error("command execute failure %d", ret);
ret = -EIO;
goto fail;
}
return ret;
fail:
wl12xx_queue_recovery_work(wl);
return ret;
}
/*
* wrapper for wlcore_cmd_send that accept only CMD_STATUS_SUCCESS
* return 0 on success.
*/
int wl1271_cmd_send(struct wl1271 *wl, u16 id, void *buf, size_t len,
size_t res_len)
{
int ret = wlcore_cmd_send_failsafe(wl, id, buf, len, res_len, 0);
if (ret < 0)
return ret;
return 0;
}
EXPORT_SYMBOL_GPL(wl1271_cmd_send);
/*
* Poll the mailbox event field until any of the bits in the mask is set or a
* timeout occurs (WL1271_EVENT_TIMEOUT in msecs)
*/
int wlcore_cmd_wait_for_event_or_timeout(struct wl1271 *wl,
u32 mask, bool *timeout)
{
u32 *events_vector;
u32 event;
unsigned long timeout_time;
u16 poll_count = 0;
int ret = 0;
Annotation
- Immediate include surface: `linux/module.h`, `linux/platform_device.h`, `linux/pm_runtime.h`, `linux/spi/spi.h`, `linux/etherdevice.h`, `linux/ieee80211.h`, `linux/slab.h`, `wlcore.h`.
- Detected declarations: `function Copyright`, `function wlcore_cmd_send_failsafe`, `function wl1271_cmd_send`, `function occurs`, `function wl12xx_cmd_role_enable`, `function wl12xx_cmd_role_disable`, `function wlcore_get_new_session_id`, `function wl12xx_allocate_link`, `function wl12xx_free_link`, `function wlcore_get_native_channel_type`.
- 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.