[PATCH 7/7] grlib: Simplify apbuart_inbyte_nonblocking()

Sebastian Huber sebastian.huber at embedded-brains.de
Thu Jun 10 13:24:06 UTC 2021


---
 bsps/shared/grlib/uart/apbuart_polled.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/bsps/shared/grlib/uart/apbuart_polled.c b/bsps/shared/grlib/uart/apbuart_polled.c
index 587dacc731..49e137af85 100644
--- a/bsps/shared/grlib/uart/apbuart_polled.c
+++ b/bsps/shared/grlib/uart/apbuart_polled.c
@@ -35,11 +35,11 @@ void apbuart_outbyte_polled(struct apbuart_regs *regs, char ch)
 int apbuart_inbyte_nonblocking(struct apbuart_regs *regs)
 {
   /* Clear errors */
-  if (regs->status & APBUART_STATUS_ERR)
-    regs->status = ~APBUART_STATUS_ERR;
+  regs->status = ~APBUART_STATUS_ERR;
 
-  if ((regs->status & APBUART_STATUS_DR) == 0)
+  if ((regs->status & APBUART_STATUS_DR) == 0) {
     return -1;
-  else
-    return (int) regs->data;
+  }
+
+  return (uint8_t) regs->data;
 }
-- 
2.26.2



More information about the devel mailing list