drivers/net/usb/pegasus.c
Source file repositories/reference/linux-study-clean/drivers/net/usb/pegasus.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/usb/pegasus.c- Extension
.c- Size
- 34248 bytes
- Lines
- 1376
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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/sched.hlinux/slab.hlinux/init.hlinux/delay.hlinux/netdevice.hlinux/etherdevice.hlinux/ethtool.hlinux/mii.hlinux/usb.hlinux/module.hasm/byteorder.hlinux/uaccess.hpegasus.h
Detected Declarations
enum pegasus_usb_epfunction async_ctrl_callbackfunction get_registersfunction set_registersfunction set_registerfunction update_eth_regs_asyncfunction __mii_opfunction read_mii_wordfunction write_mii_wordfunction mdio_readfunction mdio_writefunction read_eprom_wordfunction enable_eprom_writefunction disable_eprom_writefunction write_eprom_wordfunction get_node_idfunction set_ethernet_addrfunction reset_macfunction enable_net_trafficfunction read_bulk_callbackfunction rx_fixupfunction write_bulk_callbackfunction intr_callbackfunction pegasus_tx_timeoutfunction pegasus_start_xmitfunction disable_net_trafficfunction get_interrupt_intervalfunction set_carrierfunction free_all_urbsfunction unlink_all_urbsfunction alloc_urbsfunction pegasus_openfunction pegasus_closefunction pegasus_get_drvinfofunction pegasus_get_wolfunction pegasus_set_wolfunction pegasus_reset_wolfunction pegasus_get_link_ksettingsfunction pegasus_set_link_ksettingsfunction pegasus_nway_resetfunction pegasus_get_linkfunction pegasus_get_msglevelfunction pegasus_set_msglevelfunction pegasus_siocdevprivatefunction pegasus_set_multicastfunction mii_phy_probefunction setup_pegasus_IIfunction check_carrier
Annotated Snippet
static const struct net_device_ops pegasus_netdev_ops;
/*****/
static void async_ctrl_callback(struct urb *urb)
{
struct usb_ctrlrequest *req = (struct usb_ctrlrequest *)urb->context;
int status = urb->status;
if (status < 0)
dev_dbg(&urb->dev->dev, "%s failed with %d", __func__, status);
kfree(req);
usb_free_urb(urb);
}
static int get_registers(pegasus_t *pegasus, __u16 indx, __u16 size, void *data)
{
return usb_control_msg_recv(pegasus->usb, 0, PEGASUS_REQ_GET_REGS,
PEGASUS_REQT_READ, 0, indx, data, size,
1000, GFP_NOIO);
}
static int set_registers(pegasus_t *pegasus, __u16 indx, __u16 size,
const void *data)
{
int ret;
ret = usb_control_msg_send(pegasus->usb, 0, PEGASUS_REQ_SET_REGS,
PEGASUS_REQT_WRITE, 0, indx, data, size,
1000, GFP_NOIO);
if (ret < 0)
netif_dbg(pegasus, drv, pegasus->net, "%s failed with %d\n", __func__, ret);
return ret;
}
/*
* There is only one way to write to a single ADM8511 register and this is via
* specific control request. 'data' is ignored by the device, but it is here to
* not break the API.
*/
static int set_register(pegasus_t *pegasus, __u16 indx, __u8 data)
{
void *buf = &data;
int ret;
ret = usb_control_msg_send(pegasus->usb, 0, PEGASUS_REQ_SET_REG,
PEGASUS_REQT_WRITE, data, indx, buf, 1,
1000, GFP_NOIO);
if (ret < 0)
netif_dbg(pegasus, drv, pegasus->net, "%s failed with %d\n", __func__, ret);
return ret;
}
static int update_eth_regs_async(pegasus_t *pegasus)
{
int ret = -ENOMEM;
struct urb *async_urb;
struct usb_ctrlrequest *req;
req = kmalloc_obj(struct usb_ctrlrequest, GFP_ATOMIC);
if (req == NULL)
return ret;
async_urb = usb_alloc_urb(0, GFP_ATOMIC);
if (async_urb == NULL) {
kfree(req);
return ret;
}
req->bRequestType = PEGASUS_REQT_WRITE;
req->bRequest = PEGASUS_REQ_SET_REGS;
req->wValue = cpu_to_le16(0);
req->wIndex = cpu_to_le16(EthCtrl0);
req->wLength = cpu_to_le16(3);
usb_fill_control_urb(async_urb, pegasus->usb,
usb_sndctrlpipe(pegasus->usb, 0), (void *)req,
pegasus->eth_regs, 3, async_ctrl_callback, req);
ret = usb_submit_urb(async_urb, GFP_ATOMIC);
if (ret) {
if (ret == -ENODEV)
netif_device_detach(pegasus->net);
netif_err(pegasus, drv, pegasus->net,
"%s returned %d\n", __func__, ret);
usb_free_urb(async_urb);
kfree(req);
}
return ret;
Annotation
- Immediate include surface: `linux/sched.h`, `linux/slab.h`, `linux/init.h`, `linux/delay.h`, `linux/netdevice.h`, `linux/etherdevice.h`, `linux/ethtool.h`, `linux/mii.h`.
- Detected declarations: `enum pegasus_usb_ep`, `function async_ctrl_callback`, `function get_registers`, `function set_registers`, `function set_register`, `function update_eth_regs_async`, `function __mii_op`, `function read_mii_word`, `function write_mii_word`, `function mdio_read`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: pattern 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.