drivers/net/wireless/realtek/rtl818x/rtl8187/dev.c
Source file repositories/reference/linux-study-clean/drivers/net/wireless/realtek/rtl818x/rtl8187/dev.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/wireless/realtek/rtl818x/rtl8187/dev.c- Extension
.c- Size
- 50059 bytes
- Lines
- 1698
- 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
linux/usb.hlinux/slab.hlinux/delay.hlinux/etherdevice.hlinux/eeprom_93cx6.hlinux/module.hnet/mac80211.hrtl8187.hrtl8225.hleds.hrfkill.h
Detected Declarations
struct rtl8187_async_write_datafunction rtl8187_iowrite_async_cbfunction rtl8187_iowrite_asyncfunction rtl818x_iowrite32_asyncfunction rtl8187_write_phyfunction rtl8187_tx_cbfunction rtl8187_txfunction rtl8187_rx_cbfunction rtl8187_init_urbsfunction rtl8187b_status_cbfunction skb_queue_reverse_walkfunction rtl8187b_init_status_urbfunction rtl8187_set_anaparamfunction rtl8187_cmd_resetfunction rtl8187_init_hwfunction rtl8187b_init_hwfunction rtl8187_workfunction rtl8187_startfunction rtl8187_stopfunction rtl8187_get_tsffunction rtl8187_beacon_workfunction rtl8187_add_interfacefunction rtl8187_remove_interfacefunction rtl8187_configfunction rtl8187_conf_erpfunction rtl8187_bss_info_changedfunction rtl8187_prepare_multicastfunction rtl8187_configure_filterfunction rtl8187_conf_txfunction rtl8187_eeprom_register_readfunction rtl8187_eeprom_register_writefunction rtl8187_probefunction rtl8187_disconnect
Annotated Snippet
struct rtl8187_async_write_data {
u8 data[4];
struct usb_ctrlrequest dr;
} *buf;
int rc;
buf = kmalloc_obj(*buf, GFP_ATOMIC);
if (!buf)
return;
urb = usb_alloc_urb(0, GFP_ATOMIC);
if (!urb) {
kfree(buf);
return;
}
dr = &buf->dr;
dr->bRequestType = RTL8187_REQT_WRITE;
dr->bRequest = RTL8187_REQ_SET_REG;
dr->wValue = addr;
dr->wIndex = 0;
dr->wLength = cpu_to_le16(len);
memcpy(buf, data, len);
usb_fill_control_urb(urb, priv->udev, usb_sndctrlpipe(priv->udev, 0),
(unsigned char *)dr, buf, len,
rtl8187_iowrite_async_cb, buf);
usb_anchor_urb(urb, &priv->anchored);
rc = usb_submit_urb(urb, GFP_ATOMIC);
if (rc < 0) {
kfree(buf);
usb_unanchor_urb(urb);
}
usb_free_urb(urb);
}
static inline void rtl818x_iowrite32_async(struct rtl8187_priv *priv,
__le32 *addr, u32 val)
{
__le32 buf = cpu_to_le32(val);
rtl8187_iowrite_async(priv, cpu_to_le16((unsigned long)addr),
&buf, sizeof(buf));
}
void rtl8187_write_phy(struct ieee80211_hw *dev, u8 addr, u32 data)
{
struct rtl8187_priv *priv = dev->priv;
data <<= 8;
data |= addr | 0x80;
rtl818x_iowrite8(priv, &priv->map->PHY[3], (data >> 24) & 0xFF);
rtl818x_iowrite8(priv, &priv->map->PHY[2], (data >> 16) & 0xFF);
rtl818x_iowrite8(priv, &priv->map->PHY[1], (data >> 8) & 0xFF);
rtl818x_iowrite8(priv, &priv->map->PHY[0], data & 0xFF);
}
static void rtl8187_tx_cb(struct urb *urb)
{
struct sk_buff *skb = (struct sk_buff *)urb->context;
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
struct ieee80211_hw *hw = info->rate_driver_data[0];
struct rtl8187_priv *priv = hw->priv;
skb_pull(skb, priv->is_rtl8187b ? sizeof(struct rtl8187b_tx_hdr) :
sizeof(struct rtl8187_tx_hdr));
ieee80211_tx_info_clear_status(info);
if (!(urb->status) && !(info->flags & IEEE80211_TX_CTL_NO_ACK)) {
if (priv->is_rtl8187b) {
skb_queue_tail(&priv->b_tx_status.queue, skb);
/* queue is "full", discard last items */
while (skb_queue_len(&priv->b_tx_status.queue) > 5) {
struct sk_buff *old_skb;
dev_dbg(&priv->udev->dev,
"transmit status queue full\n");
old_skb = skb_dequeue(&priv->b_tx_status.queue);
ieee80211_tx_status_irqsafe(hw, old_skb);
}
return;
} else {
info->flags |= IEEE80211_TX_STAT_ACK;
}
}
Annotation
- Immediate include surface: `linux/usb.h`, `linux/slab.h`, `linux/delay.h`, `linux/etherdevice.h`, `linux/eeprom_93cx6.h`, `linux/module.h`, `net/mac80211.h`, `rtl8187.h`.
- Detected declarations: `struct rtl8187_async_write_data`, `function rtl8187_iowrite_async_cb`, `function rtl8187_iowrite_async`, `function rtl818x_iowrite32_async`, `function rtl8187_write_phy`, `function rtl8187_tx_cb`, `function rtl8187_tx`, `function rtl8187_rx_cb`, `function rtl8187_init_urbs`, `function rtl8187b_status_cb`.
- 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.