drivers/net/usb/ch9200.c
Source file repositories/reference/linux-study-clean/drivers/net/usb/ch9200.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/usb/ch9200.c- Extension
.c- Size
- 9800 bytes
- Lines
- 430
- 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/module.hlinux/sched.hlinux/stddef.hlinux/init.hlinux/netdevice.hlinux/etherdevice.hlinux/ethtool.hlinux/mii.hlinux/usb.hlinux/crc32.hlinux/usb/usbnet.hlinux/slab.h
Detected Declarations
function control_readfunction control_writefunction ch9200_mdio_readfunction ch9200_mdio_writefunction ch9200_link_resetfunction ch9200_statusfunction ch9200_rx_fixupfunction get_mac_addressfunction ch9200_bind
Annotated Snippet
if (!buf) {
err = -ENOMEM;
goto err_out;
}
}
err = usb_control_msg(dev->udev,
usb_sndctrlpipe(dev->udev, 0),
request, request_type, value, index, buf, size,
timeout);
if (err >= 0 && err < size)
err = -EINVAL;
kfree(buf);
return 0;
err_out:
return err;
}
static int ch9200_mdio_read(struct net_device *netdev, int phy_id, int loc)
{
struct usbnet *dev = netdev_priv(netdev);
unsigned char buff[2];
int ret;
netdev_dbg(netdev, "%s phy_id:%02x loc:%02x\n",
__func__, phy_id, loc);
if (phy_id != 0)
return -ENODEV;
ret = control_read(dev, REQUEST_READ, 0, loc * 2, buff, 0x02,
CONTROL_TIMEOUT_MS);
if (ret < 0)
return ret;
return (buff[0] | buff[1] << 8);
}
static void ch9200_mdio_write(struct net_device *netdev,
int phy_id, int loc, int val)
{
struct usbnet *dev = netdev_priv(netdev);
unsigned char buff[2];
netdev_dbg(netdev, "%s() phy_id=%02x loc:%02x\n",
__func__, phy_id, loc);
if (phy_id != 0)
return;
buff[0] = (unsigned char)val;
buff[1] = (unsigned char)(val >> 8);
control_write(dev, REQUEST_WRITE, 0, loc * 2, buff, 0x02,
CONTROL_TIMEOUT_MS);
}
static int ch9200_link_reset(struct usbnet *dev)
{
struct ethtool_cmd ecmd;
mii_check_media(&dev->mii, 1, 1);
mii_ethtool_gset(&dev->mii, &ecmd);
netdev_dbg(dev->net, "%s() speed:%d duplex:%d\n",
__func__, ecmd.speed, ecmd.duplex);
return 0;
}
static void ch9200_status(struct usbnet *dev, struct urb *urb)
{
int link;
unsigned char *buf;
if (urb->actual_length < 16)
return;
buf = urb->transfer_buffer;
link = !!(buf[0] & 0x01);
if (link) {
netif_carrier_on(dev->net);
usbnet_defer_kevent(dev, EVENT_LINK_RESET);
} else {
netif_carrier_off(dev->net);
}
}
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/sched.h`, `linux/stddef.h`, `linux/init.h`, `linux/netdevice.h`, `linux/etherdevice.h`, `linux/ethtool.h`.
- Detected declarations: `function control_read`, `function control_write`, `function ch9200_mdio_read`, `function ch9200_mdio_write`, `function ch9200_link_reset`, `function ch9200_status`, `function ch9200_rx_fixup`, `function get_mac_address`, `function ch9200_bind`.
- 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.