diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2013-02-01 22:51:34 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2013-02-01 22:51:34 +0000 |
commit | 7e161b4a2da17da233a1869ce6f44582ae7692e4 (patch) | |
tree | 5b3beb0256277784ab9da08bb37d18499418a08c /nuttx/drivers/serial/serial.c | |
parent | 9ffc9286e7c5a851b775551b488b98c85b4d4827 (diff) | |
download | px4-nuttx-7e161b4a2da17da233a1869ce6f44582ae7692e4.tar.gz px4-nuttx-7e161b4a2da17da233a1869ce6f44582ae7692e4.tar.bz2 px4-nuttx-7e161b4a2da17da233a1869ce6f44582ae7692e4.zip |
Last minute 6.25 changenuttx-6.25
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5595 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/drivers/serial/serial.c')
-rw-r--r-- | nuttx/drivers/serial/serial.c | 51 |
1 files changed, 33 insertions, 18 deletions
diff --git a/nuttx/drivers/serial/serial.c b/nuttx/drivers/serial/serial.c index 9c6acf2ee..cc1c697c0 100644 --- a/nuttx/drivers/serial/serial.c +++ b/nuttx/drivers/serial/serial.c @@ -292,15 +292,6 @@ static ssize_t uart_write(FAR struct file *filep, FAR const char *buffer, size_t ssize_t nread = buflen; int ret; -#ifdef CONFIG_SERIAL_REMOVABLE - /* If the removable device is no longer connected, refuse to write to the device */ - - if (dev->disconnected) - { - return -ENOTCONN; - } -#endif - /* We may receive console writes through this path from interrupt handlers and * from debug output in the IDLE task! In these cases, we will need to do things * a little differently. @@ -308,6 +299,17 @@ static ssize_t uart_write(FAR struct file *filep, FAR const char *buffer, size_t if (up_interrupt_context() || getpid() == 0) { +#ifdef CONFIG_SERIAL_REMOVABLE + /* If the removable device is no longer connected, refuse to write to + * the device. + */ + + if (dev->disconnected) + { + return -ENOTCONN; + } +#endif + /* up_putc() will be used to generate the output in a busy-wait loop. * up_putc() is only available for the console device. */ @@ -338,6 +340,18 @@ static ssize_t uart_write(FAR struct file *filep, FAR const char *buffer, size_t return ret; } +#ifdef CONFIG_SERIAL_REMOVABLE + /* If the removable device is no longer connected, refuse to write to the + * device. + */ + + if (dev->disconnected) + { + uart_givesem(&dev->xmit.sem); + return -ENOTCONN; + } +#endif + /* Loop while we still have data to copy to the transmit buffer. * we add data to the head of the buffer; uart_xmitchars takes the * data from the end of the buffer. @@ -417,15 +431,6 @@ static ssize_t uart_read(FAR struct file *filep, FAR char *buffer, size_t buflen int16_t tail; int ret; -#ifdef CONFIG_SERIAL_REMOVABLE - /* If the removable device is no longer connected, refuse to read from the device */ - - if (dev->disconnected) - { - return -ENOTCONN; - } -#endif - /* Only one user can access dev->recv.tail at a time */ ret = uart_takesem(&dev->recv.sem, true); @@ -439,6 +444,16 @@ static ssize_t uart_read(FAR struct file *filep, FAR char *buffer, size_t buflen return ret; } +#ifdef CONFIG_SERIAL_REMOVABLE + /* If the removable device is no longer connected, refuse to read from the device */ + + if (dev->disconnected) + { + uart_givesem(&dev->recv.sem); + return -ENOTCONN; + } +#endif + /* Loop while we still have data to copy to the receive buffer. * we add data to the head of the buffer; uart_xmitchars takes the * data from the end of the buffer. |