mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-25 07:43:33 +08:00
Revise recent changes to serial driver error handling: Errors other than EINTR may be returned when the driver is used very early in initialization. STM32 SPI driver will now survive repeated initializations
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@5026 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
@@ -69,12 +69,11 @@ static int rawinstream_getc(FAR struct lib_instream_s *this)
|
||||
}
|
||||
|
||||
/* Return EOF on any failure to read from the incoming byte stream. The
|
||||
* only expected error is EINTER meaning that the read was interrupted
|
||||
* only expected error is EINTR meaning that the read was interrupted
|
||||
* by a signal. A Zero return value would indicated an end-of-file
|
||||
* confition.
|
||||
*/
|
||||
|
||||
DEBUGASSERT(nwritten == 0 || get_errno() == EINTR);
|
||||
return EOF;
|
||||
}
|
||||
|
||||
|
||||
@@ -59,9 +59,11 @@ static void rawoutstream_putc(FAR struct lib_outstream_s *this, int ch)
|
||||
|
||||
DEBUGASSERT(this && rthis->fd >= 0);
|
||||
|
||||
/* Loop until the character is successfully transferred */
|
||||
/* Loop until the character is successfully transferred or until an
|
||||
* irrecoverable error occurs.
|
||||
*/
|
||||
|
||||
for (;;)
|
||||
do
|
||||
{
|
||||
nwritten = write(rthis->fd, &buffer, 1);
|
||||
if (nwritten == 1)
|
||||
@@ -75,8 +77,9 @@ static void rawoutstream_putc(FAR struct lib_outstream_s *this, int ch)
|
||||
* from write().
|
||||
*/
|
||||
|
||||
DEBUGASSERT(nwritten < 0 && get_errno() == EINTR);
|
||||
DEBUGASSERT(nwritten < 0);
|
||||
}
|
||||
while (get_errno() == EINTR);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
@@ -58,9 +58,11 @@ static void stdoutstream_putc(FAR struct lib_outstream_s *this, int ch)
|
||||
|
||||
DEBUGASSERT(this && sthis->stream);
|
||||
|
||||
/* Loop until the character is successfully transferred */
|
||||
/* Loop until the character is successfully transferred or an irrecoverable
|
||||
* error occurs.
|
||||
*/
|
||||
|
||||
for (;;)
|
||||
do
|
||||
{
|
||||
result = fputc(ch, sthis->stream);
|
||||
if (result != EOF)
|
||||
@@ -70,11 +72,10 @@ static void stdoutstream_putc(FAR struct lib_outstream_s *this, int ch)
|
||||
}
|
||||
|
||||
/* EINTR (meaning that fputc was interrupted by a signal) is the only
|
||||
* expected error.
|
||||
* recoverable error.
|
||||
*/
|
||||
|
||||
DEBUGASSERT(get_errno() == EINTR);
|
||||
}
|
||||
while (get_errno() == EINTR);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
@@ -69,7 +69,7 @@ static void syslogstream_putc(FAR struct lib_outstream_s *this, int ch)
|
||||
* error occurs.
|
||||
*/
|
||||
|
||||
for (;;)
|
||||
do
|
||||
{
|
||||
/* Write the character to the supported logging device */
|
||||
|
||||
@@ -85,9 +85,8 @@ static void syslogstream_putc(FAR struct lib_outstream_s *this, int ch)
|
||||
* syslog_putc() was awakened by a signal. This is not a real error and
|
||||
* must be ignored in this context.
|
||||
*/
|
||||
|
||||
DEBUGASSERT(ret == -EINTR);
|
||||
}
|
||||
while (ret == -EINTR);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
Reference in New Issue
Block a user