drivers/tty/serial/jsm/jsm_tty.c

Source file repositories/reference/linux-study-clean/drivers/tty/serial/jsm/jsm_tty.c

File Facts

System
Linux kernel
Corpus path
drivers/tty/serial/jsm/jsm_tty.c
Extension
.c
Size
20212 bytes
Lines
830
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.

Dependency Surface

Detected Declarations

Annotated Snippet

if (!channel->ch_rqueue) {
			jsm_dbg(INIT, &channel->ch_bd->pci_dev,
				"unable to allocate read queue buf\n");
			return -ENOMEM;
		}
	}
	if (!channel->ch_equeue) {
		channel->ch_equeue = kzalloc(EQUEUESIZE, GFP_KERNEL);
		if (!channel->ch_equeue) {
			jsm_dbg(INIT, &channel->ch_bd->pci_dev,
				"unable to allocate error queue buf\n");
			return -ENOMEM;
		}
	}

	channel->ch_flags &= ~(CH_OPENING);
	/*
	 * Initialize if neither terminal is open.
	 */
	jsm_dbg(OPEN, &channel->ch_bd->pci_dev,
		"jsm_open: initializing channel in open...\n");

	/*
	 * Flush input queues.
	 */
	channel->ch_r_head = channel->ch_r_tail = 0;
	channel->ch_e_head = channel->ch_e_tail = 0;

	brd->bd_ops->flush_uart_write(channel);
	brd->bd_ops->flush_uart_read(channel);

	channel->ch_flags = 0;
	channel->ch_cached_lsr = 0;
	channel->ch_stops_sent = 0;

	uart_port_lock_irqsave(port, &lock_flags);
	termios = &port->state->port.tty->termios;
	channel->ch_c_cflag	= termios->c_cflag;
	channel->ch_c_iflag	= termios->c_iflag;
	channel->ch_c_oflag	= termios->c_oflag;
	channel->ch_c_lflag	= termios->c_lflag;
	channel->ch_startc	= termios->c_cc[VSTART];
	channel->ch_stopc	= termios->c_cc[VSTOP];

	/* Tell UART to init itself */
	brd->bd_ops->uart_init(channel);

	/*
	 * Run param in case we changed anything
	 */
	brd->bd_ops->param(channel);

	jsm_carrier(channel);

	channel->ch_open_count++;
	uart_port_unlock_irqrestore(port, lock_flags);

	jsm_dbg(OPEN, &channel->ch_bd->pci_dev, "finish\n");
	return 0;
}

static void jsm_tty_close(struct uart_port *port)
{
	struct jsm_board *bd;
	struct jsm_channel *channel =
		container_of(port, struct jsm_channel, uart_port);

	jsm_dbg(CLOSE, &channel->ch_bd->pci_dev, "start\n");

	bd = channel->ch_bd;

	channel->ch_flags &= ~(CH_STOPI);

	channel->ch_open_count--;

	/*
	 * If we have HUPCL set, lower DTR and RTS
	 */
	if (channel->ch_c_cflag & HUPCL) {
		jsm_dbg(CLOSE, &channel->ch_bd->pci_dev,
			"Close. HUPCL set, dropping DTR/RTS\n");

		/* Drop RTS/DTR */
		channel->ch_mostat &= ~(UART_MCR_DTR | UART_MCR_RTS);
		bd->bd_ops->assert_modem_signals(channel);
	}

	/* Turn off UART interrupts for this port */
	channel->ch_bd->bd_ops->uart_off(channel);

Annotation

Implementation Notes