aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorPali Rohár <pali@kernel.org>2021-09-24 23:07:10 +0200
committerStefan Roese <sr@denx.de>2021-10-01 11:07:13 +0200
commit911515b339109d4bdf992441d5efdf4a6f885f95 (patch)
treeb25f03ec57f132cd5807e33a0a57d445de2df3c4 /tools
parent24a471bc4bac8aa3a52ad7fa209494b6bc38e58d (diff)
downloadu-boot-911515b339109d4bdf992441d5efdf4a6f885f95.zip
u-boot-911515b339109d4bdf992441d5efdf4a6f885f95.tar.gz
u-boot-911515b339109d4bdf992441d5efdf4a6f885f95.tar.bz2
tools: kwboot: Disable non-blocking mode
The kwboot utility does not handle EAGAIN / EBUSY errors, it expects blocking mode on tty - it uses select() to check if data is available. Disable non-blocking mode by clearing O_NDELAY flag which was set by open(). We can't just take O_NDELAY from open(), because it is required there until the CLOCAL flag is set on the tty. Signed-off-by: Pali Rohár <pali@kernel.org> Signed-off-by: Marek Behún <marek.behun@nic.cz>
Diffstat (limited to 'tools')
-rw-r--r--tools/kwboot.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/tools/kwboot.c b/tools/kwboot.c
index a527c79..5e491f3 100644
--- a/tools/kwboot.c
+++ b/tools/kwboot.c
@@ -639,7 +639,7 @@ baud_fail:
static int
kwboot_open_tty(const char *path, int baudrate)
{
- int rc, fd;
+ int rc, fd, flags;
struct termios tio;
rc = -1;
@@ -661,6 +661,14 @@ kwboot_open_tty(const char *path, int baudrate)
if (rc)
goto out;
+ flags = fcntl(fd, F_GETFL);
+ if (flags < 0)
+ goto out;
+
+ rc = fcntl(fd, F_SETFL, flags & ~O_NDELAY);
+ if (rc)
+ goto out;
+
rc = kwboot_tty_change_baudrate(fd, baudrate);
if (rc)
goto out;