drivers/net/usb/hso.c
Source file repositories/reference/linux-study-clean/drivers/net/usb/hso.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/usb/hso.c- Extension
.c- Size
- 83901 bytes
- Lines
- 3271
- 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/sched/signal.hlinux/slab.hlinux/init.hlinux/delay.hlinux/netdevice.hlinux/module.hlinux/ethtool.hlinux/usb.hlinux/tty.hlinux/tty_driver.hlinux/tty_flip.hlinux/kmod.hlinux/rfkill.hlinux/ip.hlinux/uaccess.hlinux/usb/cdc.hnet/arp.hasm/byteorder.hlinux/serial_core.hlinux/serial.h
Detected Declarations
struct hso_shared_intstruct hso_netstruct hso_serial_state_notificationstruct hso_tiocmgetstruct hso_serialstruct hso_deviceenum pkt_parse_stateenum rx_ctrl_statefunction dbg_dumpfunction hsotype_showfunction hso_urb_to_indexfunction hso_mux_to_portfunction hso_port_to_muxfunction obtain_minorfunction release_minorfunction handle_usb_errorfunction hso_net_openfunction hso_net_closefunction write_bulk_callbackfunction hso_net_start_xmitfunction hso_net_tx_timeoutfunction packetizeRxfunction fix_crc_bugfunction read_bulk_callbackfunction hso_init_termiosfunction _hso_serial_set_termiosfunction hso_resubmit_rx_bulk_urbfunction put_rxbuf_data_and_resubmit_bulk_urbfunction put_rxbuf_data_and_resubmit_ctrl_urbfunction hso_std_serial_read_bulk_callbackfunction hso_unthrottle_taskletfunction hso_unthrottlefunction hso_serial_openfunction hso_serial_closefunction hso_serial_writefunction hso_serial_write_roomfunction hso_serial_cleanupfunction hso_serial_set_termiosfunction hso_serial_chars_in_bufferfunction tiocmget_submit_urbfunction tiocmget_intr_callbackfunction le16_to_cpufunction hso_wait_modem_statusfunction interruptsfunction hso_serial_tiocmgetfunction hso_serial_tiocmsetfunction hso_serial_ioctlfunction hso_kick_transmit
Annotated Snippet
static const struct net_device_ops hso_netdev_ops = {
.ndo_open = hso_net_open,
.ndo_stop = hso_net_close,
.ndo_start_xmit = hso_net_start_xmit,
.ndo_tx_timeout = hso_net_tx_timeout,
};
/* initialize the network interface */
static void hso_net_init(struct net_device *net)
{
struct hso_net *hso_net = netdev_priv(net);
hso_dbg(0x1, "sizeof hso_net is %zu\n", sizeof(*hso_net));
/* fill in the other fields */
net->netdev_ops = &hso_netdev_ops;
net->watchdog_timeo = HSO_NET_TX_TIMEOUT;
net->flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST;
net->type = ARPHRD_NONE;
net->mtu = DEFAULT_MTU - 14;
net->tx_queue_len = 10;
net->ethtool_ops = &ops;
/* and initialize the semaphore */
spin_lock_init(&hso_net->net_lock);
}
/* Adds a network device in the network device table */
static int add_net_device(struct hso_device *hso_dev)
{
int i;
for (i = 0; i < HSO_MAX_NET_DEVICES; i++) {
if (network_table[i] == NULL) {
network_table[i] = hso_dev;
break;
}
}
if (i == HSO_MAX_NET_DEVICES)
return -1;
return 0;
}
static int hso_rfkill_set_block(void *data, bool blocked)
{
struct hso_device *hso_dev = data;
int enabled = !blocked;
int rv;
mutex_lock(&hso_dev->mutex);
if (hso_dev->usb_gone)
rv = 0;
else
rv = usb_control_msg(hso_dev->usb, usb_sndctrlpipe(hso_dev->usb, 0),
enabled ? 0x82 : 0x81, 0x40, 0, 0, NULL, 0,
USB_CTRL_SET_TIMEOUT);
mutex_unlock(&hso_dev->mutex);
return rv;
}
static const struct rfkill_ops hso_rfkill_ops = {
.set_block = hso_rfkill_set_block,
};
/* Creates and sets up everything for rfkill */
static void hso_create_rfkill(struct hso_device *hso_dev,
struct usb_interface *interface)
{
struct hso_net *hso_net = dev2net(hso_dev);
struct device *dev = &hso_net->net->dev;
static u32 rfkill_counter;
snprintf(hso_net->name, sizeof(hso_net->name), "hso-%d",
rfkill_counter++);
hso_net->rfkill = rfkill_alloc(hso_net->name,
&interface_to_usbdev(interface)->dev,
RFKILL_TYPE_WWAN,
&hso_rfkill_ops, hso_dev);
if (!hso_net->rfkill)
return;
if (rfkill_register(hso_net->rfkill) < 0) {
rfkill_destroy(hso_net->rfkill);
hso_net->rfkill = NULL;
dev_err(dev, "%s - Failed to register rfkill\n", __func__);
return;
}
}
Annotation
- Immediate include surface: `linux/sched/signal.h`, `linux/slab.h`, `linux/init.h`, `linux/delay.h`, `linux/netdevice.h`, `linux/module.h`, `linux/ethtool.h`, `linux/usb.h`.
- Detected declarations: `struct hso_shared_int`, `struct hso_net`, `struct hso_serial_state_notification`, `struct hso_tiocmget`, `struct hso_serial`, `struct hso_device`, `enum pkt_parse_state`, `enum rx_ctrl_state`, `function dbg_dump`, `function hsotype_show`.
- 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.