public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: "Pali Rohár" <pali@kernel.org>
To: Stefan Roese <sr@denx.de>
Cc: "Marek Behún" <marek.behun@nic.cz>, u-boot@lists.denx.de
Subject: [PATCH] tools: termios_linux.h: Fix tcsendbreak() implementation
Date: Wed,  6 Oct 2021 14:30:25 +0200	[thread overview]
Message-ID: <20211006123025.9788-1-pali@kernel.org> (raw)

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

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
versions.

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@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);
+#else
+	return ioctl(fd, TCSBRK, 0);
+#endif
 }
 
 static inline int tcflow(int fd, int a)
-- 
2.20.1


             reply	other threads:[~2021-10-06 12:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-06 12:30 Pali Rohár [this message]
2021-10-21  5:36 ` [PATCH] tools: termios_linux.h: Fix tcsendbreak() implementation Stefan Roese
2021-10-21  7:46   ` Stefan Roese

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211006123025.9788-1-pali@kernel.org \
    --to=pali@kernel.org \
    --cc=marek.behun@nic.cz \
    --cc=sr@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox