From c704e0e1df93328a336780c8e3dd87ad44b4f351 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Pali=20Roh=C3=A1r?= Date: Fri, 24 Sep 2021 23:07:08 +0200 Subject: [PATCH] tools: kwboot: Fix initializing tty device MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Marek Behún Reviewed-by: Stefan Roese --- tools/kwboot.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tools/kwboot.c b/tools/kwboot.c index d8b950787b..fc83161d70 100644 --- a/tools/kwboot.c +++ b/tools/kwboot.c @@ -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; -- 2.39.5