[rtems commit] libchip: Use Termios API change for NS16550

Sebastian Huber sebh at rtems.org
Wed Jun 12 14:08:10 UTC 2013


Module:    rtems
Branch:    master
Commit:    15f3a91858fc54e3c006fb07a0b87b9610a01f28
Changeset: http://git.rtems.org/rtems/commit/?id=15f3a91858fc54e3c006fb07a0b87b9610a01f28

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Mon Jun 10 14:11:07 2013 +0200

libchip: Use Termios API change for NS16550

This avoids a race condition on SMP configurations.

---

 c/src/libchip/serial/ns16550.c |   22 +++++++++-------------
 1 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/c/src/libchip/serial/ns16550.c b/c/src/libchip/serial/ns16550.c
index 5ef0f97..bf5b1b1 100644
--- a/c/src/libchip/serial/ns16550.c
+++ b/c/src/libchip/serial/ns16550.c
@@ -550,19 +550,12 @@ NS16550_STATIC void ns16550_process( int minor)
     /* Check if we can dequeue transmitted characters */
     if (ctx->transmitFifoChars > 0
         && (get( port, NS16550_LINE_STATUS) & SP_LSR_THOLD) != 0) {
-      unsigned chars = ctx->transmitFifoChars;
-
-      /*
-       * We finished the transmission, so clear the number of characters in the
-       * transmit FIFO.
-       */
-      ctx->transmitFifoChars = 0;
 
       /* Dequeue transmitted characters */
-      if (rtems_termios_dequeue_characters( d->termios_data, chars) == 0) {
-        /* Nothing to do */
-        ns16550_enable_interrupts( c, NS16550_ENABLE_ALL_INTR_EXCEPT_TX);
-      }
+      rtems_termios_dequeue_characters(
+        d->termios_data,
+        ctx->transmitFifoChars
+      );
     }
   } while ((get( port, NS16550_INTERRUPT_ID) & SP_IID_0) == 0);
 }
@@ -595,9 +588,12 @@ ssize_t ns16550_write_support_int(
     set( port, NS16550_TRANSMIT_BUFFER, buf [i]);
   }
 
-  if (len > 0) {
-    ctx->transmitFifoChars = out;
+  ctx->transmitFifoChars = out;
+
+  if (out > 0) {
     ns16550_enable_interrupts( c, NS16550_ENABLE_ALL_INTR);
+  } else {
+    ns16550_enable_interrupts( c, NS16550_ENABLE_ALL_INTR_EXCEPT_TX);
   }
 
   return 0;




More information about the vc mailing list