drivers/net/wireless/ralink/rt2x00/rt2500usb.c
Source file repositories/reference/linux-study-clean/drivers/net/wireless/ralink/rt2x00/rt2500usb.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/wireless/ralink/rt2x00/rt2500usb.c- Extension
.c- Size
- 61980 bytes
- Lines
- 1985
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/delay.hlinux/etherdevice.hlinux/kernel.hlinux/module.hlinux/slab.hlinux/usb.hrt2x00.hrt2x00usb.hrt2500usb.h
Detected Declarations
function rt2500usb_register_readfunction rt2500usb_register_read_lockfunction rt2500usb_register_writefunction rt2500usb_register_write_lockfunction rt2500usb_register_multiwritefunction rt2500usb_regbusy_readfunction rt2500usb_bbp_writefunction rt2500usb_bbp_readfunction rt2500usb_rf_writefunction _rt2500usb_register_readfunction _rt2500usb_register_writefunction rt2500usb_rfkill_pollfunction rt2500usb_brightness_setfunction rt2500usb_blink_setfunction rt2500usb_init_ledfunction rt2500usb_config_keyfunction rt2500usb_config_filterfunction rt2500usb_config_intffunction rt2500usb_config_erpfunction rt2500usb_config_antfunction rt2500usb_config_channelfunction rt2500usb_config_txpowerfunction rt2500usb_config_psfunction rt2500usb_configfunction rt2500usb_link_statsfunction rt2500usb_reset_tunerfunction rt2500usb_start_queuefunction rt2500usb_stop_queuefunction rt2500usb_init_registersfunction rt2500usb_wait_bbp_readyfunction rt2500usb_init_bbpfunction rt2500usb_enable_radiofunction rt2500usb_disable_radiofunction rt2500usb_set_statefunction rt2500usb_set_device_statefunction rt2500usb_write_tx_descfunction rt2500usb_write_beaconfunction rt2500usb_get_tx_data_lenfunction rt2500usb_fill_rxdonefunction rt2500usb_beacondonefunction rt2500usb_validate_eepromfunction rt2500usb_init_eepromfunction rt2500usb_probe_hw_modefunction rt2500usb_probe_hwfunction rt2500usb_queue_initfunction rt2500usb_probe
Annotated Snippet
if (eeprom != 0xffff && eeprom != 0x0000) {
reg_id = rt2x00_get_field16(eeprom, EEPROM_BBP_REG_ID);
value = rt2x00_get_field16(eeprom, EEPROM_BBP_VALUE);
rt2500usb_bbp_write(rt2x00dev, reg_id, value);
}
}
return 0;
}
/*
* Device state switch handlers.
*/
static int rt2500usb_enable_radio(struct rt2x00_dev *rt2x00dev)
{
/*
* Initialize all registers.
*/
if (unlikely(rt2500usb_init_registers(rt2x00dev) ||
rt2500usb_init_bbp(rt2x00dev)))
return -EIO;
return 0;
}
static void rt2500usb_disable_radio(struct rt2x00_dev *rt2x00dev)
{
rt2500usb_register_write(rt2x00dev, MAC_CSR13, 0x2121);
rt2500usb_register_write(rt2x00dev, MAC_CSR14, 0x2121);
/*
* Disable synchronisation.
*/
rt2500usb_register_write(rt2x00dev, TXRX_CSR19, 0);
rt2x00usb_disable_radio(rt2x00dev);
}
static int rt2500usb_set_state(struct rt2x00_dev *rt2x00dev,
enum dev_state state)
{
u16 reg;
u16 reg2;
unsigned int i;
bool put_to_sleep;
u8 bbp_state;
u8 rf_state;
put_to_sleep = (state != STATE_AWAKE);
reg = 0;
rt2x00_set_field16(®, MAC_CSR17_BBP_DESIRE_STATE, state);
rt2x00_set_field16(®, MAC_CSR17_RF_DESIRE_STATE, state);
rt2x00_set_field16(®, MAC_CSR17_PUT_TO_SLEEP, put_to_sleep);
rt2500usb_register_write(rt2x00dev, MAC_CSR17, reg);
rt2x00_set_field16(®, MAC_CSR17_SET_STATE, 1);
rt2500usb_register_write(rt2x00dev, MAC_CSR17, reg);
/*
* Device is not guaranteed to be in the requested state yet.
* We must wait until the register indicates that the
* device has entered the correct state.
*/
for (i = 0; i < REGISTER_USB_BUSY_COUNT; i++) {
reg2 = rt2500usb_register_read(rt2x00dev, MAC_CSR17);
bbp_state = rt2x00_get_field16(reg2, MAC_CSR17_BBP_CURR_STATE);
rf_state = rt2x00_get_field16(reg2, MAC_CSR17_RF_CURR_STATE);
if (bbp_state == state && rf_state == state)
return 0;
rt2500usb_register_write(rt2x00dev, MAC_CSR17, reg);
msleep(30);
}
return -EBUSY;
}
static int rt2500usb_set_device_state(struct rt2x00_dev *rt2x00dev,
enum dev_state state)
{
int retval = 0;
switch (state) {
case STATE_RADIO_ON:
retval = rt2500usb_enable_radio(rt2x00dev);
break;
case STATE_RADIO_OFF:
rt2500usb_disable_radio(rt2x00dev);
break;
case STATE_RADIO_IRQ_ON:
case STATE_RADIO_IRQ_OFF:
Annotation
- Immediate include surface: `linux/delay.h`, `linux/etherdevice.h`, `linux/kernel.h`, `linux/module.h`, `linux/slab.h`, `linux/usb.h`, `rt2x00.h`, `rt2x00usb.h`.
- Detected declarations: `function rt2500usb_register_read`, `function rt2500usb_register_read_lock`, `function rt2500usb_register_write`, `function rt2500usb_register_write_lock`, `function rt2500usb_register_multiwrite`, `function rt2500usb_regbusy_read`, `function rt2500usb_bbp_write`, `function rt2500usb_bbp_read`, `function rt2500usb_rf_write`, `function _rt2500usb_register_read`.
- 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.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.