serial: ns16550: Fix poll in

poll_in was dropping all data and return just the last character.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
Flavio Ceolin 2020-06-16 14:40:27 -07:00 committed by Carles Cufí
commit 459dde17e5

View file

@ -511,21 +511,12 @@ static int uart_ns16550_poll_in(struct device *dev, unsigned char *c)
int ret = -1; int ret = -1;
k_spinlock_key_t key = k_spin_lock(&DEV_DATA(dev)->lock); k_spinlock_key_t key = k_spin_lock(&DEV_DATA(dev)->lock);
while (1) {
if ((INBYTE(LSR(dev)) & LSR_RXRDY) != 0) { if ((INBYTE(LSR(dev)) & LSR_RXRDY) != 0) {
/* got a character */ /* got a character */
*c = INBYTE(RDR(dev)); *c = INBYTE(RDR(dev));
ret = 0; ret = 0;
} }
if ((INBYTE(LSR(dev)) & LSR_RXRDY) != 0) {
continue;
}
break;
}
k_spin_unlock(&DEV_DATA(dev)->lock, key); k_spin_unlock(&DEV_DATA(dev)->lock, key);
return ret; return ret;