Re: [patch V2 03/13] USB: serial: keyspan_pda: Consolidate room query
From: Johan Hovold
Date: Sun Oct 25 2020 - 13:05:51 EST
On Mon, Oct 19, 2020 at 12:06:32PM +0200, Thomas Gleixner wrote:
> From: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
>
> Having two copies of the same code doesn't make the code more readable and
> allocating a buffer of 1 byte for a synchronous operation is a pointless
> exercise.
As Alan pointed out, this buffer is in fact required and not pointless
at all even if reallocating it may be suboptimal.
Note however that there are several further allocations done by
usb_control_msg() for each control request.
> Allocate a byte buffer at init which can be used instead. The buffer is
> only used in open() and tty->write(). Console writes are not calling into
> the query. open() obviously happens before write() and the writes are
> serialized by bit 0 of port->write_urbs_free which protects also the
> transaction itself.
As I mentioned in my comments to the previous patch, I've rewritten the
driver so that is no longer does this query in the write path. I kept
the buffer allocation for now though in case you want to rework this one
top.
Johan