drivers/net/ieee802154/atusb.c
Source file repositories/reference/linux-study-clean/drivers/net/ieee802154/atusb.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ieee802154/atusb.c- Extension
.c- Size
- 30354 bytes
- Lines
- 1114
- 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.
- 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/kernel.hlinux/slab.hlinux/module.hlinux/jiffies.hlinux/usb.hlinux/skbuff.hnet/cfg802154.hnet/mac802154.hat86rf230.hatusb.h
Detected Declarations
struct atusbstruct atusb_chip_datafunction atusb_write_subregfunction atusb_read_subregfunction atusb_get_and_clear_errorfunction atusb_submit_rx_urbfunction atusb_work_urbsfunction atusb_tx_donefunction atusb_in_goodfunction atusb_infunction atusb_free_urbsfunction atusb_alloc_urbsfunction atusb_xmit_completefunction atusb_xmitfunction atusb_edfunction atusb_set_hw_addr_filtfunction atusb_startfunction atusb_stopfunction atusb_txpowerfunction atusb_set_txpowerfunction hulusb_set_txpowerfunction atusb_set_cca_modefunction hulusb_set_cca_ed_levelfunction atusb_set_cca_ed_levelfunction atusb_channelfunction atusb_set_channelfunction hulusb_set_channelfunction atusb_set_csma_paramsfunction hulusb_set_lbtfunction atusb_set_frame_retriesfunction atusb_set_promiscuous_modefunction atusb_get_and_show_revisionfunction atusb_get_and_show_buildfunction atusb_get_and_conf_chipfunction atusb_set_extended_addrfunction atusb_probefunction atusb_disconnect
Annotated Snippet
struct atusb {
struct ieee802154_hw *hw;
struct usb_device *usb_dev;
struct atusb_chip_data *data;
int shutdown; /* non-zero if shutting down */
int err; /* set by first error */
/* RX variables */
struct delayed_work work; /* memory allocations */
struct usb_anchor idle_urbs; /* URBs waiting to be submitted */
struct usb_anchor rx_urbs; /* URBs waiting for reception */
/* TX variables */
struct usb_ctrlrequest tx_dr;
struct urb *tx_urb;
struct sk_buff *tx_skb;
u8 tx_ack_seq; /* current TX ACK sequence number */
/* Firmware variable */
unsigned char fw_ver_maj; /* Firmware major version number */
unsigned char fw_ver_min; /* Firmware minor version number */
unsigned char fw_hw_type; /* Firmware hardware type */
};
struct atusb_chip_data {
u16 t_channel_switch;
int rssi_base_val;
int (*set_channel)(struct ieee802154_hw*, u8, u8);
int (*set_txpower)(struct ieee802154_hw*, s32);
};
static int atusb_write_subreg(struct atusb *atusb, u8 reg, u8 mask,
u8 shift, u8 value)
{
struct usb_device *usb_dev = atusb->usb_dev;
u8 orig, tmp;
int ret = 0;
dev_dbg(&usb_dev->dev, "%s: 0x%02x <- 0x%02x\n", __func__, reg, value);
ret = usb_control_msg_recv(usb_dev, 0, ATUSB_REG_READ, ATUSB_REQ_FROM_DEV,
0, reg, &orig, 1, 1000, GFP_KERNEL);
if (ret < 0)
return ret;
/* Write the value only into that part of the register which is allowed
* by the mask. All other bits stay as before.
*/
tmp = orig & ~mask;
tmp |= (value << shift) & mask;
if (tmp != orig)
ret = usb_control_msg_send(usb_dev, 0, ATUSB_REG_WRITE, ATUSB_REQ_TO_DEV,
tmp, reg, NULL, 0, 1000, GFP_KERNEL);
return ret;
}
static int atusb_read_subreg(struct atusb *lp,
unsigned int addr, unsigned int mask,
unsigned int shift)
{
int reg, ret;
ret = usb_control_msg_recv(lp->usb_dev, 0, ATUSB_REG_READ, ATUSB_REQ_FROM_DEV,
0, addr, ®, 1, 1000, GFP_KERNEL);
if (ret < 0)
return ret;
reg = (reg & mask) >> shift;
return reg;
}
static int atusb_get_and_clear_error(struct atusb *atusb)
{
int err = atusb->err;
atusb->err = 0;
return err;
}
/* ----- skb allocation ---------------------------------------------------- */
#define MAX_PSDU 127
#define MAX_RX_XFER (1 + MAX_PSDU + 2 + 1) /* PHR+PSDU+CRC+LQI */
#define SKB_ATUSB(skb) (*(struct atusb **)(skb)->cb)
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/slab.h`, `linux/module.h`, `linux/jiffies.h`, `linux/usb.h`, `linux/skbuff.h`, `net/cfg802154.h`, `net/mac802154.h`.
- Detected declarations: `struct atusb`, `struct atusb_chip_data`, `function atusb_write_subreg`, `function atusb_read_subreg`, `function atusb_get_and_clear_error`, `function atusb_submit_rx_urb`, `function atusb_work_urbs`, `function atusb_tx_done`, `function atusb_in_good`, `function atusb_in`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
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.