struct arc_serial_plat *plat = dev_get_plat(dev);
struct arc_serial_regs *const regs = plat->reg;
- while (!(readb(®s->status) & UART_TXEMPTY))
- ;
+ if (!(readb(®s->status) & UART_TXEMPTY))
+ return -EAGAIN;
writeb(c, ®s->data);
struct arc_serial_plat *plat = dev_get_plat(dev);
struct arc_serial_regs *const regs = plat->reg;
- while (!arc_serial_tstc(regs))
- ;
+ if (!arc_serial_tstc(regs))
+ return -EAGAIN;
/* Check for overflow errors */
if (readb(®s->status) & UART_OVERFLOW_ERR)
static int _lpuart_serial_getc(struct lpuart_serial_plat *plat)
{
struct lpuart_fsl *base = plat->reg;
- while (!(__raw_readb(&base->us1) & (US1_RDRF | US1_OR)))
- schedule();
+ if (!(__raw_readb(&base->us1) & (US1_RDRF | US1_OR)))
+ return -EAGAIN;
barrier();
return __raw_readb(&base->ud);
}
-static void _lpuart_serial_putc(struct lpuart_serial_plat *plat,
+static int _lpuart_serial_putc(struct lpuart_serial_plat *plat,
const char c)
{
struct lpuart_fsl *base = plat->reg;
- while (!(__raw_readb(&base->us1) & US1_TDRE))
- schedule();
+ if (!(__raw_readb(&base->us1) & US1_TDRE))
+ return -EAGAIN;
__raw_writeb(c, &base->ud);
+ return 0;
}
/* Test whether a character is in the RX buffer */
u32 stat, val;
lpuart_read32(plat->flags, &base->stat, &stat);
- while ((stat & STAT_RDRF) == 0) {
+ if ((stat & STAT_RDRF) == 0) {
lpuart_write32(plat->flags, &base->stat, STAT_FLAGS);
- schedule();
- lpuart_read32(plat->flags, &base->stat, &stat);
+ return -EAGAIN;
}
lpuart_read32(plat->flags, &base->data, &val);
return val & 0x3ff;
}
-static void _lpuart32_serial_putc(struct lpuart_serial_plat *plat,
+static int _lpuart32_serial_putc(struct lpuart_serial_plat *plat,
const char c)
{
struct lpuart_fsl_reg32 *base = plat->reg;
u32 stat;
- while (true) {
- lpuart_read32(plat->flags, &base->stat, &stat);
-
- if ((stat & STAT_TDRE))
- break;
-
- schedule();
- }
+ lpuart_read32(plat->flags, &base->stat, &stat);
+ if (!(stat & STAT_TDRE))
+ return -EAGAIN;
lpuart_write32(plat->flags, &base->data, c);
+ return 0;
}
/* Test whether a character is in the RX buffer */
struct lpuart_serial_plat *plat = dev_get_plat(dev);
if (is_lpuart32(dev))
- _lpuart32_serial_putc(plat, c);
- else
- _lpuart_serial_putc(plat, c);
+ return _lpuart32_serial_putc(plat, c);
- return 0;
+ return _lpuart_serial_putc(plat, c);
}
static int lpuart_serial_pending(struct udevice *dev, bool input)
rtx = (struct serialbuffer __iomem *)&cpmp->cp_dpmem[CPM_SERIAL_BASE];
- /* Wait for last character to go. */
+ if (in_be16(&rtx->txbd.cbd_sc) & BD_SC_READY)
+ return -EAGAIN;
+
out_8(&rtx->txbuf, c);
out_be16(&rtx->txbd.cbd_datlen, 1);
setbits_be16(&rtx->txbd.cbd_sc, BD_SC_READY);
- while (in_be16(&rtx->txbd.cbd_sc) & BD_SC_READY)
- schedule();
-
return 0;
}
rtx = (struct serialbuffer __iomem *)&cpmp->cp_dpmem[CPM_SERIAL_BASE];
- /* Wait for character to show up. */
- while (in_be16(&rtx->rxbd.cbd_sc) & BD_SC_EMPTY)
- schedule();
+ if (in_be16(&rtx->rxbd.cbd_sc) & BD_SC_EMPTY)
+ return -EAGAIN;
/* the characters are read one by one,
* use the rxindex to know the next char to deliver
struct mvebu_plat *plat = dev_get_plat(dev);
void __iomem *base = plat->base;
- while (readl(base + UART_STATUS_REG) & UART_STATUS_TXFIFO_FULL)
- ;
+ if (readl(base + UART_STATUS_REG) & UART_STATUS_TXFIFO_FULL)
+ return -EAGAIN;
writel(ch, base + UART_TX_REG);
struct mvebu_plat *plat = dev_get_plat(dev);
void __iomem *base = plat->base;
- while (!(readl(base + UART_STATUS_REG) & UART_STATUS_RX_RDY))
- ;
+ if (!(readl(base + UART_STATUS_REG) & UART_STATUS_RX_RDY))
+ return -EAGAIN;
return readl(base + UART_RX_REG) & 0xff;
}