ibchip/ns16550: Minor optimisation.

This commit is contained in:
Chris Johns
2016-04-20 17:12:07 +10:00
parent 03ad2a5a92
commit 8ce75671eb

View File

@@ -1,6 +1,6 @@
/** /**
* @file * @file
* *
* This file contains the TTY driver for the National Semiconductor NS16550. * This file contains the TTY driver for the National Semiconductor NS16550.
* *
* This part is widely cloned and second sourced. It is found in a number * This part is widely cloned and second sourced. It is found in a number
@@ -234,7 +234,7 @@ void ns16550_init(int minor)
Console_Port_Data[minor].pDeviceContext=(void *)pns16550Context; Console_Port_Data[minor].pDeviceContext=(void *)pns16550Context;
pns16550Context->ucModemCtrl=SP_MODEM_IRQ; pns16550Context->ucModemCtrl=SP_MODEM_IRQ;
pNS16550 = c->ulCtrlPort1; pNS16550 = c->ulCtrlPort1;
setReg = c->setRegister; setReg = c->setRegister;
getReg = c->getRegister; getReg = c->getRegister;
@@ -389,7 +389,7 @@ void ns16550_outch_polled(console_tbl *c, char out)
void ns16550_write_polled(int minor, char out) void ns16550_write_polled(int minor, char out)
{ {
console_tbl *c = Console_Port_Tbl [minor]; console_tbl *c = Console_Port_Tbl [minor];
ns16550_outch_polled( c, out ); ns16550_outch_polled( c, out );
} }
@@ -616,27 +616,28 @@ NS16550_STATIC void ns16550_process( int minor)
NS16550Context *ctx = d->pDeviceContext; NS16550Context *ctx = d->pDeviceContext;
uint32_t port = c->ulCtrlPort1; uint32_t port = c->ulCtrlPort1;
getRegister_f get = c->getRegister; getRegister_f get = c->getRegister;
int i = 0; int i;
char buf [SP_FIFO_SIZE]; char buf [SP_FIFO_SIZE];
/* Iterate until no more interrupts are pending */ /* Iterate until no more interrupts are pending */
do { do {
/* Fetch received characters */ /* Fetch received characters */
for (i = 0; i < SP_FIFO_SIZE; ++i) { i = 0;
if ((get( port, NS16550_LINE_STATUS) & SP_LSR_RDY) != 0) { while ((get(port, NS16550_LINE_STATUS) & SP_LSR_RDY) != 0) {
buf [i] = (char) get(port, NS16550_RECEIVE_BUFFER); buf[i++] = (char) get(port, NS16550_RECEIVE_BUFFER);
} else { if (i == SP_FIFO_SIZE) {
break; /* Enqueue fetched characters */
rtems_termios_enqueue_raw_characters( d->termios_data, buf, i);
i = 0;
} }
} }
/* Enqueue fetched characters */ if (i > 0)
rtems_termios_enqueue_raw_characters( d->termios_data, buf, i); rtems_termios_enqueue_raw_characters( d->termios_data, buf, i);
/* Check if we can dequeue transmitted characters */ /* Check if we can dequeue transmitted characters */
if (ctx->transmitFifoChars > 0 if (ctx->transmitFifoChars > 0
&& (get( port, NS16550_LINE_STATUS) & SP_LSR_THOLD) != 0) { && (get( port, NS16550_LINE_STATUS) & SP_LSR_THOLD) != 0) {
/* Dequeue transmitted characters */ /* Dequeue transmitted characters */
rtems_termios_dequeue_characters( rtems_termios_dequeue_characters(
d->termios_data, d->termios_data,
@@ -869,6 +870,6 @@ int ns16550_inch_polled(
int ns16550_inbyte_nonblocking_polled(int minor) int ns16550_inbyte_nonblocking_polled(int minor)
{ {
console_tbl *c = Console_Port_Tbl [minor]; console_tbl *c = Console_Port_Tbl [minor];
return ns16550_inch_polled( c ); return ns16550_inch_polled( c );
} }