[PATCH] tools: termios_linux.h: Fix tcsendbreak() implementation

Pali Rohár pali at kernel.org
Wed Oct 6 14:30:25 CEST 2021

There are two Linux ioctls which implements tcsendbreak() functionality:

TCSBRK with non-zero parameter implements tcdrain() and with zero parameter
implements tcsendbreak() for duration of 0.25s.

TCSBRKP with zero parameter is same as TCSBRK and with non-zero parameter
implements tcsendbreak() for duration in deciseconds specified by
parameter. TCSBRKP does not have to be provided by older toolchain

So tcsendbreak() has to either use TCSBRK with zero parameter or TCSBRKP
with any parameter.

Fix code to use TCSBRKP and fallback to TCSBRK with 0.

Signed-off-by: Pali Rohár <pali at kernel.org>
 tools/termios_linux.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tools/termios_linux.h b/tools/termios_linux.h
index d73989b625a2..e100c8e4eb5f 100644
--- a/tools/termios_linux.h
+++ b/tools/termios_linux.h
@@ -90,7 +90,11 @@ static inline int tcflush(int fd, int q)
 static inline int tcsendbreak(int fd, int d)
-	return ioctl(fd, TCSBRK, d);
+#ifdef TCSBRKP
+	return ioctl(fd, TCSBRKP, d);
+	return ioctl(fd, TCSBRK, 0);
 static inline int tcflow(int fd, int a)

More information about the U-Boot mailing list