drivers/tty/serial/jsm/jsm_neo.c
Source file repositories/reference/linux-study-clean/drivers/tty/serial/jsm/jsm_neo.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/tty/serial/jsm/jsm_neo.c- Extension
.c- Size
- 34852 bytes
- Lines
- 1336
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/delay.hlinux/serial_reg.hlinux/tty.hlinux/pci.hasm/io.hjsm.h
Detected Declarations
function neo_pci_posting_flushfunction neo_set_cts_flow_controlfunction neo_set_rts_flow_controlfunction neo_set_ixon_flow_controlfunction neo_set_ixoff_flow_controlfunction neo_set_no_input_flow_controlfunction neo_set_no_output_flow_controlfunction neo_set_new_start_stop_charsfunction neo_copy_data_from_uart_to_queuefunction neo_copy_data_from_queue_to_uartfunction neo_parse_modemfunction neo_assert_modem_signalsfunction neo_flush_uart_writefunction neo_flush_uart_readfunction neo_clear_breakfunction neo_parse_isrfunction neo_parse_lsrfunction neo_paramfunction jsm_neo_intrfunction neo_disable_receiverfunction neo_enable_receiverfunction neo_send_start_characterfunction neo_send_stop_characterfunction neo_uart_initfunction neo_uart_offfunction neo_send_break
Annotated Snippet
if (!(linestatus & UART_LSR_DR)) {
ch->ch_cached_lsr = linestatus;
break;
}
/* No need to store this bit */
linestatus &= ~UART_LSR_DR;
/*
* Since we are grabbing the linestatus register, which
* will reset some bits after our read, we need to ensure
* we don't miss our TX FIFO emptys.
*/
if (linestatus & (UART_LSR_THRE | UART_17158_TX_AND_FIFO_CLR)) {
linestatus &= ~(UART_LSR_THRE | UART_17158_TX_AND_FIFO_CLR);
ch->ch_flags |= (CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM);
}
/*
* Discard character if we are ignoring the error mask.
*/
if (linestatus & error_mask) {
u8 discard;
linestatus = 0;
memcpy_fromio(&discard, &ch->ch_neo_uart->txrxburst, 1);
continue;
}
/*
* If our queue is full, we have no choice but to drop some data.
* The assumption is that HWFLOW or SWFLOW should have stopped
* things way way before we got to this point.
*
* I decided that I wanted to ditch the oldest data first,
* I hope thats okay with everyone? Yes? Good.
*/
while (qleft < 1) {
jsm_dbg(READ, &ch->ch_bd->pci_dev,
"Queue full, dropping DATA:%x LSR:%x\n",
ch->ch_rqueue[tail], ch->ch_equeue[tail]);
ch->ch_r_tail = tail = (tail + 1) & RQUEUEMASK;
ch->ch_err_overrun++;
qleft++;
}
memcpy_fromio(ch->ch_rqueue + head, &ch->ch_neo_uart->txrxburst, 1);
ch->ch_equeue[head] = (u8) linestatus;
jsm_dbg(READ, &ch->ch_bd->pci_dev, "DATA/LSR pair: %x %x\n",
ch->ch_rqueue[head], ch->ch_equeue[head]);
/* Ditch any remaining linestatus value. */
linestatus = 0;
/* Add to and flip head if needed */
head = (head + 1) & RQUEUEMASK;
qleft--;
ch->ch_rxcount++;
}
/*
* Write new final heads to channel structure.
*/
ch->ch_r_head = head & RQUEUEMASK;
ch->ch_e_head = head & EQUEUEMASK;
jsm_input(ch);
}
static void neo_copy_data_from_queue_to_uart(struct jsm_channel *ch)
{
struct tty_port *tport;
unsigned char *tail;
unsigned char c;
int n;
int s;
int qlen;
u32 len_written = 0;
if (!ch)
return;
tport = &ch->uart_port.state->port;
/* No data to write to the UART */
if (kfifo_is_empty(&tport->xmit_fifo))
return;
/* If port is "stopped", don't send any data to the UART */
Annotation
- Immediate include surface: `linux/delay.h`, `linux/serial_reg.h`, `linux/tty.h`, `linux/pci.h`, `asm/io.h`, `jsm.h`.
- Detected declarations: `function neo_pci_posting_flush`, `function neo_set_cts_flow_control`, `function neo_set_rts_flow_control`, `function neo_set_ixon_flow_control`, `function neo_set_ixoff_flow_control`, `function neo_set_no_input_flow_control`, `function neo_set_no_output_flow_control`, `function neo_set_new_start_stop_chars`, `function neo_copy_data_from_uart_to_queue`, `function neo_copy_data_from_queue_to_uart`.
- Atlas domain: Driver Families / drivers/tty.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.