From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B57EC433F5 for ; Wed, 6 Oct 2021 12:31:20 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AD0B46115A for ; Wed, 6 Oct 2021 12:31:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org AD0B46115A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CC2F78314B; Wed, 6 Oct 2021 14:31:16 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="Wj5XoQXD"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A8E788314B; Wed, 6 Oct 2021 14:31:14 +0200 (CEST) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A5C2B83173 for ; Wed, 6 Oct 2021 14:31:07 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: by mail.kernel.org (Postfix) with ESMTPSA id 528946115A; Wed, 6 Oct 2021 12:31:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1633523465; bh=Tzch8sEJHljXgMCxNsW9URFJB31N2h1rCBjCgzdXl3Y=; h=From:To:Cc:Subject:Date:From; b=Wj5XoQXDezH9Hn1/A4SrBmmSKGNQyEYO5d0SJgNNhkeZVknQoOptDe8bv+vshynh/ Z4A/1tYBfZCcevdlKcxX1yqJPm72i2+zyUUwkgadkUNhtFFtaVb1DLZti/O4q+cBEc s/LSp1uOV49VBCEz3L9iiKDxTULgXeKE+CPx1f/bqMuPYCUkIaa98GAhmPcGAarhuI 8cWCwoOeDdZUD7EJdH0plm23T8tbjcybN/hP0SYm24XwrqFLuv7POjFJV4AUfmnrU4 ZBNZOEuTE8AGrqWdHPcPjcDRojbPZm90AWhehSFyEeFyQbFe9sxI9NhgoWXsInKB01 lFu+eU3vP2FNg== Received: by pali.im (Postfix) id 59AFB76B; Wed, 6 Oct 2021 14:31:02 +0200 (CEST) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Stefan Roese Cc: =?UTF-8?q?Marek=20Beh=C3=BAn?= , u-boot@lists.denx.de Subject: [PATCH] tools: termios_linux.h: Fix tcsendbreak() implementation Date: Wed, 6 Oct 2021 14:30:25 +0200 Message-Id: <20211006123025.9788-1-pali@kernel.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean 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 --- 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