Skip to content

Commit

Permalink
serial: export the key functions for an 8250 IRQ handler
Browse files Browse the repository at this point in the history
For drivers that need to construct their own IRQ handler, the
three components are seen in the current handle_port -- i.e.
Rx, Tx and modem_status.

Make these exported symbols so that "almost" 8250 UARTs can
construct their own IRQ handler with these shared components,
while working around their own unique errata issues.

The function names are given a serial8250 prefix, since they
are now entering the global namespace.

Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Acked-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Paul Gortmaker authored and Greg Kroah-Hartman committed Dec 10, 2011
1 parent 0690f41 commit 3986fb2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
29 changes: 15 additions & 14 deletions drivers/tty/serial/8250.c
Original file line number Diff line number Diff line change
Expand Up @@ -1300,8 +1300,6 @@ static void serial8250_stop_tx(struct uart_port *port)
}
}

static void transmit_chars(struct uart_8250_port *up);

static void serial8250_start_tx(struct uart_port *port)
{
struct uart_8250_port *up =
Expand All @@ -1318,7 +1316,7 @@ static void serial8250_start_tx(struct uart_port *port)
if ((up->port.type == PORT_RM9000) ?
(lsr & UART_LSR_THRE) :
(lsr & UART_LSR_TEMT))
transmit_chars(up);
serial8250_tx_chars(up);
}
}

Expand Down Expand Up @@ -1376,12 +1374,12 @@ static void clear_rx_fifo(struct uart_8250_port *up)
}

/*
* receive_chars: processes according to the passed in LSR
* serial8250_rx_chars: processes according to the passed in LSR
* value, and returns the remaining LSR bits not handled
* by this Rx routine.
*/
static unsigned char
receive_chars(struct uart_8250_port *up, unsigned char lsr)
unsigned char
serial8250_rx_chars(struct uart_8250_port *up, unsigned char lsr)
{
struct tty_struct *tty = up->port.state->port.tty;
unsigned char ch;
Expand Down Expand Up @@ -1462,8 +1460,9 @@ receive_chars(struct uart_8250_port *up, unsigned char lsr)
spin_lock(&up->port.lock);
return lsr;
}
EXPORT_SYMBOL_GPL(serial8250_rx_chars);

static void transmit_chars(struct uart_8250_port *up)
void serial8250_tx_chars(struct uart_8250_port *up)
{
struct circ_buf *xmit = &up->port.state->xmit;
int count;
Expand Down Expand Up @@ -1500,8 +1499,9 @@ static void transmit_chars(struct uart_8250_port *up)
if (uart_circ_empty(xmit))
__stop_tx(up);
}
EXPORT_SYMBOL_GPL(serial8250_tx_chars);

static unsigned int check_modem_status(struct uart_8250_port *up)
unsigned int serial8250_modem_status(struct uart_8250_port *up)
{
unsigned int status = serial_in(up, UART_MSR);

Expand All @@ -1523,6 +1523,7 @@ static unsigned int check_modem_status(struct uart_8250_port *up)

return status;
}
EXPORT_SYMBOL_GPL(serial8250_modem_status);

/*
* This handles the interrupt from one port.
Expand All @@ -1539,10 +1540,10 @@ static void serial8250_handle_port(struct uart_8250_port *up)
DEBUG_INTR("status = %x...", status);

if (status & (UART_LSR_DR | UART_LSR_BI))
status = receive_chars(up, status);
check_modem_status(up);
status = serial8250_rx_chars(up, status);
serial8250_modem_status(up);
if (status & UART_LSR_THRE)
transmit_chars(up);
serial8250_tx_chars(up);

spin_unlock_irqrestore(&up->port.lock, flags);
}
Expand Down Expand Up @@ -1782,7 +1783,7 @@ static void serial8250_backup_timeout(unsigned long data)
}

if (!(iir & UART_IIR_NO_INT))
transmit_chars(up);
serial8250_tx_chars(up);

if (is_real_interrupt(up->port.irq))
serial_out(up, UART_IER, ier);
Expand Down Expand Up @@ -1816,7 +1817,7 @@ static unsigned int serial8250_get_mctrl(struct uart_port *port)
unsigned int status;
unsigned int ret;

status = check_modem_status(up);
status = serial8250_modem_status(up);

ret = 0;
if (status & UART_MSR_DCD)
Expand Down Expand Up @@ -2863,7 +2864,7 @@ serial8250_console_write(struct console *co, const char *s, unsigned int count)
* while processing with interrupts off.
*/
if (up->msr_saved_flags)
check_modem_status(up);
serial8250_modem_status(up);

if (locked)
spin_unlock(&up->port.lock);
Expand Down
4 changes: 4 additions & 0 deletions include/linux/serial_8250.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ enum {
* dependent on the 8250 driver.
*/
struct uart_port;
struct uart_8250_port;

int serial8250_register_port(struct uart_port *);
void serial8250_unregister_port(int line);
Expand All @@ -82,6 +83,9 @@ extern void serial8250_do_set_termios(struct uart_port *port,
extern void serial8250_do_pm(struct uart_port *port, unsigned int state,
unsigned int oldstate);
int serial8250_handle_irq(struct uart_port *port, unsigned int iir);
unsigned char serial8250_rx_chars(struct uart_8250_port *up, unsigned char lsr);
void serial8250_tx_chars(struct uart_8250_port *up);
unsigned int serial8250_modem_status(struct uart_8250_port *up);

extern void serial8250_set_isa_configurator(void (*v)
(int port, struct uart_port *up,
Expand Down

0 comments on commit 3986fb2

Please sign in to comment.