drivers/net/usb/rtl8150.c
Source file repositories/reference/linux-study-clean/drivers/net/usb/rtl8150.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/usb/rtl8150.c- Extension
.c- Size
- 23614 bytes
- Lines
- 995
- 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.
- 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/signal.hlinux/slab.hlinux/module.hlinux/netdevice.hlinux/etherdevice.hlinux/mii.hlinux/ethtool.hlinux/usb.hlinux/uaccess.h
Detected Declarations
struct rtl8150struct async_reqenum rtl8150_usb_epfunction get_registersfunction set_registersfunction async_set_reg_cbfunction async_set_registersfunction read_mii_wordfunction write_mii_wordfunction set_ethernet_addrfunction rtl8150_set_mac_addressfunction rtl8150_resetfunction alloc_all_urbsfunction free_all_urbsfunction unlink_all_urbsfunction read_bulk_callbackfunction write_bulk_callbackfunction intr_callbackfunction rtl8150_suspendfunction rtl8150_resumefunction fill_skb_poolfunction free_skb_poolfunction rx_fixupfunction enable_net_trafficfunction disable_net_trafficfunction rtl8150_tx_timeoutfunction rtl8150_set_multicastfunction rtl8150_start_xmitfunction set_carrierfunction rtl8150_openfunction rtl8150_closefunction rtl8150_get_drvinfofunction rtl8150_get_link_ksettingsfunction rtl8150_siocdevprivatefunction rtl8150_probefunction rtl8150_disconnect
Annotated Snippet
static const struct net_device_ops rtl8150_netdev_ops = {
.ndo_open = rtl8150_open,
.ndo_stop = rtl8150_close,
.ndo_siocdevprivate = rtl8150_siocdevprivate,
.ndo_start_xmit = rtl8150_start_xmit,
.ndo_tx_timeout = rtl8150_tx_timeout,
.ndo_set_rx_mode = rtl8150_set_multicast,
.ndo_set_mac_address = rtl8150_set_mac_address,
.ndo_validate_addr = eth_validate_addr,
};
static int rtl8150_probe(struct usb_interface *intf,
const struct usb_device_id *id)
{
struct usb_device *udev = interface_to_usbdev(intf);
rtl8150_t *dev;
struct net_device *netdev;
static const u8 bulk_ep_addr[] = {
RTL8150_USB_EP_BULK_IN | USB_DIR_IN,
RTL8150_USB_EP_BULK_OUT | USB_DIR_OUT,
0};
static const u8 int_ep_addr[] = {
RTL8150_USB_EP_INT_IN | USB_DIR_IN,
0};
netdev = alloc_etherdev(sizeof(rtl8150_t));
if (!netdev)
return -ENOMEM;
dev = netdev_priv(netdev);
dev->intr_buff = kmalloc(INTBUFSIZE, GFP_KERNEL);
if (!dev->intr_buff) {
free_netdev(netdev);
return -ENOMEM;
}
/* Verify that all required endpoints are present */
if (!usb_check_bulk_endpoints(intf, bulk_ep_addr) ||
!usb_check_int_endpoints(intf, int_ep_addr)) {
dev_err(&intf->dev, "couldn't find required endpoints\n");
goto out;
}
tasklet_setup(&dev->tl, rx_fixup);
spin_lock_init(&dev->rx_pool_lock);
dev->udev = udev;
dev->netdev = netdev;
netdev->netdev_ops = &rtl8150_netdev_ops;
netdev->watchdog_timeo = RTL8150_TX_TIMEOUT;
netdev->ethtool_ops = &ops;
dev->intr_interval = 100; /* 100ms */
if (!alloc_all_urbs(dev)) {
dev_err(&intf->dev, "out of memory\n");
goto out;
}
if (!rtl8150_reset(dev)) {
dev_err(&intf->dev, "couldn't reset the device\n");
goto out1;
}
fill_skb_pool(dev);
set_ethernet_addr(dev);
usb_set_intfdata(intf, dev);
SET_NETDEV_DEV(netdev, &intf->dev);
if (register_netdev(netdev) != 0) {
dev_err(&intf->dev, "couldn't register the device\n");
goto out2;
}
dev_info(&intf->dev, "%s: rtl8150 is detected\n", netdev->name);
return 0;
out2:
usb_set_intfdata(intf, NULL);
free_skb_pool(dev);
out1:
free_all_urbs(dev);
out:
kfree(dev->intr_buff);
free_netdev(netdev);
return -EIO;
}
static void rtl8150_disconnect(struct usb_interface *intf)
{
Annotation
- Immediate include surface: `linux/signal.h`, `linux/slab.h`, `linux/module.h`, `linux/netdevice.h`, `linux/etherdevice.h`, `linux/mii.h`, `linux/ethtool.h`, `linux/usb.h`.
- Detected declarations: `struct rtl8150`, `struct async_req`, `enum rtl8150_usb_ep`, `function get_registers`, `function set_registers`, `function async_set_reg_cb`, `function async_set_registers`, `function read_mii_word`, `function write_mii_word`, `function set_ethernet_addr`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: pattern 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.