From: Segwon Date: Thu, 21 Sep 2017 08:43:06 +0000 (+0900) Subject: uart: added flush logic before close. X-Git-Tag: accepted/tizen/unified/20170926.165628~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7bf252014bceded96fd0ff3b2d05aa5e41367aa4;p=platform%2Fcore%2Fsystem%2Fperipheral-bus.git uart: added flush logic before close. Signed-off-by: Segwon Change-Id: I639ade4199c50518974b7a5f94c2752677d144b5 --- diff --git a/src/interface/uart.c b/src/interface/uart.c index fd15ca5..b18d18d 100644 --- a/src/interface/uart.c +++ b/src/interface/uart.c @@ -77,13 +77,31 @@ int uart_open(int port, int *file_hndl) int uart_close(int file_hndl) { + int status; + _D("file_hndl : %d", file_hndl); - if (!file_hndl) { + if (file_hndl < 0) { _E("Invalid NULL parameter"); return -EINVAL; } - close(file_hndl); + + status = uart_flush(file_hndl); + if (status < 0) { + char errmsg[MAX_ERR_LEN]; + strerror_r(errno, errmsg, MAX_ERR_LEN); + _E("Failed to close fd : %d, errmsg : %s", file_hndl, errmsg); + return -EIO; + } + + status = close(file_hndl); + if (status < 0) { + char errmsg[MAX_ERR_LEN]; + strerror_r(errno, errmsg, MAX_ERR_LEN); + _E("Failed to close fd : %d, errmsg : %s", file_hndl, errmsg); + return -EIO; + } + return 0; }