All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tools: termios_linux.h: Fix tcsendbreak() implementation
@ 2021-10-06 12:30 Pali Rohár
  2021-10-21  5:36 ` Stefan Roese
  0 siblings, 1 reply; 3+ messages in thread
From: Pali Rohár @ 2021-10-06 12:30 UTC (permalink / raw)
  To: Stefan Roese; +Cc: Marek Behún, u-boot

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] tools: termios_linux.h: Fix tcsendbreak() implementation
  2021-10-06 12:30 [PATCH] tools: termios_linux.h: Fix tcsendbreak() implementation Pali Rohár
@ 2021-10-21  5:36 ` Stefan Roese
  2021-10-21  7:46   ` Stefan Roese
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Roese @ 2021-10-21  5:36 UTC (permalink / raw)
  To: Pali Rohár; +Cc: Marek Behún, u-boot

On 06.10.21 14:30, Pali Rohár wrote:
> 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>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan

> ---
>   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)
> 


Viele Grüße,
Stefan

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] tools: termios_linux.h: Fix tcsendbreak() implementation
  2021-10-21  5:36 ` Stefan Roese
@ 2021-10-21  7:46   ` Stefan Roese
  0 siblings, 0 replies; 3+ messages in thread
From: Stefan Roese @ 2021-10-21  7:46 UTC (permalink / raw)
  To: Pali Rohár; +Cc: Marek Behún, u-boot

On 21.10.21 07:36, Stefan Roese wrote:
> On 06.10.21 14:30, Pali Rohár wrote:
>> 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>
> 
> Reviewed-by: Stefan Roese <sr@denx.de>

Applied to u-boot-marvell/master

Thanks,
Stefan

> Thanks,
> Stefan
> 
>> ---
>>   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)
>>
> 
> 
> Viele Grüße,
> Stefan
> 


Viele Grüße,
Stefan

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-10-21  7:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-06 12:30 [PATCH] tools: termios_linux.h: Fix tcsendbreak() implementation Pali Rohár
2021-10-21  5:36 ` Stefan Roese
2021-10-21  7:46   ` Stefan Roese

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.