USB: serial: ch341: fix missing simulated-break margin

On devices which do not support break signalling a break condition is
simulated by sending a NUL byte at the lowest possible speed. The break
condition will be 9 bit periods long (start bit and eight data bits),
but the transmission itself also includes the stop bit.

Add the missing safety margin of one bit which is intended to account
for timing differences, and fix up the corresponding comment.

Signed-off-by: Michael Hanselmann <public@hansmi.ch>
Link: https://lore.kernel.org/r/9909b288-294d-16b9-9f14-51eb79c63b6c@msgid.hansmi.ch
[ johan: amend commit message ]
Signed-off-by: Johan Hovold <johan@kernel.org>
This commit is contained in:
Michael Hanselmann 2020-07-07 16:53:22 +02:00 committed by Johan Hovold
parent c7614ff9b7
commit 6d0bdc4284

View File

@ -604,11 +604,13 @@ static void ch341_simulate_break(struct tty_struct *tty, int break_state)
}
/*
* Compute expected transmission duration and add a single bit
* of safety margin (the actual NUL byte transmission is 8 bits
* plus one stop bit).
* Compute expected transmission duration including safety
* margin. The original baud rate is only restored after the
* computed point in time.
*
* 11 bits = 1 start, 8 data, 1 stop, 1 margin
*/
priv->break_end = jiffies + (10 * HZ / CH341_MIN_BPS);
priv->break_end = jiffies + (11 * HZ / CH341_MIN_BPS);
return;
}