drivers/tty/ipwireless/tty.c
Source file repositories/reference/linux-study-clean/drivers/tty/ipwireless/tty.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/tty/ipwireless/tty.c- Extension
.c- Size
- 14073 bytes
- Lines
- 628
- Domain
- Driver Families
- Bucket
- drivers/tty
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/kernel.hlinux/module.hlinux/mutex.hlinux/ppp_defs.hlinux/if.hlinux/ppp-ioctl.hlinux/sched.hlinux/serial.hlinux/slab.hlinux/tty.hlinux/tty_driver.hlinux/tty_flip.hlinux/uaccess.htty.hnetwork.hhardware.hmain.h
Detected Declarations
struct ipw_ttyfunction ipw_openfunction do_ipw_closefunction ipw_hangupfunction ipw_closefunction ipwireless_tty_receivedfunction ipw_write_packet_sent_callbackfunction ipw_writefunction ipw_write_roomfunction ipwireless_get_serial_infofunction ipwireless_set_serial_infofunction ipw_chars_in_bufferfunction get_control_linesfunction set_control_linesfunction ipw_tiocmgetfunction ipw_tiocmsetfunction ipw_ioctlfunction add_ttyfunction ipwireless_network_freefunction ipwireless_tty_initfunction ipwireless_tty_releasefunction ipwireless_tty_is_modemfunction ipwireless_tty_notify_control_line_change
Annotated Snippet
struct ipw_tty {
struct tty_port port;
int index;
struct ipw_hardware *hardware;
unsigned int channel_idx;
unsigned int secondary_channel_idx;
int tty_type;
struct ipw_network *network;
unsigned int control_lines;
struct mutex ipw_tty_mutex;
int tx_bytes_queued;
};
static struct ipw_tty *ttys[IPWIRELESS_PCMCIA_MINORS];
static struct tty_driver *ipw_tty_driver;
static char *tty_type_name(int tty_type)
{
static char *channel_names[] = {
"modem",
"monitor",
"RAS-raw"
};
return channel_names[tty_type];
}
static struct ipw_tty *get_tty(int index)
{
/*
* The 'ras_raw' channel is only available when 'loopback' mode
* is enabled.
* Number of minor starts with 16 (_RANGE * _RAS_RAW).
*/
if (!ipwireless_loopback && index >=
IPWIRELESS_PCMCIA_MINOR_RANGE * TTYTYPE_RAS_RAW)
return NULL;
return ttys[index];
}
static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
{
struct ipw_tty *tty = get_tty(linux_tty->index);
if (!tty)
return -ENODEV;
mutex_lock(&tty->ipw_tty_mutex);
if (tty->port.count == 0)
tty->tx_bytes_queued = 0;
tty->port.count++;
tty->port.tty = linux_tty;
linux_tty->driver_data = tty;
if (tty->tty_type == TTYTYPE_MODEM)
ipwireless_ppp_open(tty->network);
mutex_unlock(&tty->ipw_tty_mutex);
return 0;
}
static void do_ipw_close(struct ipw_tty *tty)
{
tty->port.count--;
if (tty->port.count == 0) {
struct tty_struct *linux_tty = tty->port.tty;
if (linux_tty != NULL) {
tty->port.tty = NULL;
linux_tty->driver_data = NULL;
if (tty->tty_type == TTYTYPE_MODEM)
ipwireless_ppp_close(tty->network);
}
}
}
static void ipw_hangup(struct tty_struct *linux_tty)
{
struct ipw_tty *tty = linux_tty->driver_data;
if (!tty)
return;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/mutex.h`, `linux/ppp_defs.h`, `linux/if.h`, `linux/ppp-ioctl.h`, `linux/sched.h`, `linux/serial.h`.
- Detected declarations: `struct ipw_tty`, `function ipw_open`, `function do_ipw_close`, `function ipw_hangup`, `function ipw_close`, `function ipwireless_tty_received`, `function ipw_write_packet_sent_callback`, `function ipw_write`, `function ipw_write_room`, `function ipwireless_get_serial_info`.
- Atlas domain: Driver Families / drivers/tty.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.