]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
tools: kwboot: Fix initializing tty device
authorPali Rohár <pali@kernel.org>
Fri, 24 Sep 2021 21:07:08 +0000 (23:07 +0200)
committerStefan Roese <sr@denx.de>
Fri, 1 Oct 2021 09:07:13 +0000 (11:07 +0200)
Retrieve current terminal settings via tcgetattr(), set to raw mode with
cfmakeraw(), enable receiver via CREAD and ignore modem control lines
via CLOCAL.

Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
tools/kwboot.c

index d8b950787be18c7d56b42025e70e2580d59bca9a..fc83161d70fc5f4085381b9895fe2c0d22273577 100644 (file)
@@ -648,11 +648,12 @@ kwboot_open_tty(const char *path, int baudrate)
        if (fd < 0)
                goto out;
 
-       memset(&tio, 0, sizeof(tio));
-
-       tio.c_iflag = 0;
-       tio.c_cflag = CREAD|CLOCAL|CS8;
+       rc = tcgetattr(fd, &tio);
+       if (rc)
+               goto out;
 
+       cfmakeraw(&tio);
+       tio.c_cflag |= CREAD|CLOCAL;
        tio.c_cc[VMIN] = 1;
        tio.c_cc[VTIME] = 10;