It is up to the line discipline to ensure that there is only a single
thread running between write_room() and the write() or put_char() call
(which is currently done thanks to lock_kernel(). If it isn't, the
tty locking broke and we have bigger problems.)
Without this guarantee, how do you propose to handle the following case:
- we have a "\n" character from user space.
- we have O_ONLCR set.
- we have only one character available in the output buffer in the driver.
This means we need to write two characters "\r\n" to the driver. If we
try to write "\r\n" using your proposed solution, we'd write "\r". How
do we remember that we need to write a "\n" (or some other string of
characters for that matter) ?
Now consider if we could remember we've only written half the string.
What happens if we've written "\r", then some tty echo occurs, then
we write "\n" ?
If these cases don't work with a new API, the new API is even more buggy
than the existing one.
(For user output, n_tty currently guarantees that we will not drop any
characters written from user space, as long as we remain single-threaded
between write_room() and put_char() or write() methods.)
Looking at rfcomm, this is probably part of your problem:
return dlc->mtu * (dlc->tx_credits ? : 10);
Also, rfcomm should be fixed to use the put_char / flush_buffer methods.
These are there to batch up single chars to make things more efficient,
and I wouldn't be surprised if a stream of single chars were eating up
all your tx credits.
I'm surprised that rfcomm, being a packet based communication system,
doesn't implement put_char.
-- Russell King (rmk@arm.linux.org.uk) The developer of ARM Linux http://www.arm.linux.org.uk/personal/aboutme.html- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/