uart: fixed to return the -EAGAIN error type when read/write. 09/151609/3
authorSegwon <segwon.han@samsung.com>
Thu, 21 Sep 2017 08:45:48 +0000 (17:45 +0900)
committerSegwon <segwon.han@samsung.com>
Thu, 21 Sep 2017 09:09:34 +0000 (18:09 +0900)
Signed-off-by: Segwon <segwon.han@samsung.com>
Change-Id: I726000397abcac13cfc571336823775c8df1e053

src/interface/uart.c

index b18d18d..34ff11e 100644 (file)
@@ -430,7 +430,9 @@ int uart_read(int file_hndl, uint8_t *buf, unsigned int length)
        }
 
        ret = read(file_hndl, (void *)buf, length);
-       if ((errno != EAGAIN && errno != EINTR) && ret < 0) {
+       if (ret <= 0) {
+               if (errno == EAGAIN)
+                       return -EAGAIN;
                char errmsg[MAX_ERR_LEN];
                strerror_r(errno, errmsg, MAX_ERR_LEN);
                _E("read failed, errmsg : %s", errmsg);
@@ -450,7 +452,9 @@ int uart_write(int file_hndl, uint8_t *buf, unsigned int length)
        }
 
        ret = write(file_hndl, buf, length);
-       if (ret < 0) {
+       if (ret <= 0) {
+               if (errno == EAGAIN)
+                       return -EAGAIN;
                char errmsg[MAX_ERR_LEN];
                strerror_r(errno, errmsg, MAX_ERR_LEN);
                _E("write failed, errmsg : %s", errmsg);