drivers/serial: simplify signaling method
authorEunBong Song <eunb.song@samsung.com>
Tue, 11 Apr 2017 23:32:52 +0000 (08:32 +0900)
committerHeesub Shin <heesub.shin@samsung.com>
Tue, 18 Apr 2017 03:02:15 +0000 (12:02 +0900)
Commit ca9015e7 set xmitsem as a signaling semaphore. So we do not need
to use sem_wait_for_isr and sem_post_from_isr for xmitsem.

Change-Id: I4d895429f5f55014be463721bf642d513593d3ae
Signed-off-by: EunBong Song <eunb.song@samsung.com>
os/drivers/serial/serial.c

index 7b2565c..9a18581 100644 (file)
@@ -152,34 +152,6 @@ static int uart_takesem(FAR sem_t *sem, bool errout)
        return OK;
 }
 
-/*
- *   This function attempts to lock the semaphore referenced by 'sem'
- *   which will be posted from interrupt handler.
- *   Because this function should have nothing to do with the priority
- *   inheritance, call sem_wait_for_isr() instead of sem_wait().
- */
-static int uart_takesem_wo_prio_inherit(FAR sem_t *sem, bool errout)
-{
-       /* Loop, ignoring interrupts, until we have successfully acquired the semaphore */
-
-       while (sem_wait_for_isr(sem) != OK) {
-               /* The only case that an error should occur here is if the wait was awakened
-                * by a signal.
-                */
-
-               ASSERT(get_errno() == EINTR);
-
-               /* When the signal is received, should we errout? Or should we just continue
-                * waiting until we have the semaphore?
-                */
-
-               if (errout) {
-                       return -EINTR;
-               }
-       }
-
-       return OK;
-}
 
 /************************************************************************************
  * Name: uart_givesem
@@ -288,7 +260,7 @@ static int uart_putxmitchar(FAR uart_dev_t *dev, int ch, bool oktoblock)
 
                                dev->xmitwaiting = true;
                                uart_enabletxint(dev);
-                               ret = uart_takesem_wo_prio_inherit(&dev->xmitsem, true);
+                               ret = uart_takesem(&dev->xmitsem, true);
                                uart_disabletxint(dev);
                        }
 
@@ -1340,7 +1312,7 @@ void uart_datasent(FAR uart_dev_t *dev)
                /* Yes... wake it up */
 
                dev->xmitwaiting = false;
-               (void)sem_post_from_isr(&dev->xmitsem);
+               (void)sem_post(&dev->xmitsem);
        }
 
        /* Notify all poll/select waiters that they can write to xmit buffer */