mos7840: fix chars_in_buffer() return value
Subsystems (2)
PATCH 1/1 mos7840: fix chars_in_buffer() return value
The TIOCOUTQ ioctl calls chars_in_buffer(), and some apps depend on a correct behaviour of that.
mos7840 implements it wrongly: if you write just one char, TIOCOUTQ will return 32.
This patch should fix it by accounting the number of chars actually writCaylan Van Larson <[email protected]>ten.
This patch, unfortunately, misses the Tesed-by tag.
The reported didn't test it, and I don't have the hardware in question.
--- drivers/usb/serial/mos7840.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/usb/serial/mos7840.c +4 -5
@@ -234,7 +234,7 @@ struct moschip_port {spinlock_t pool_lock;struct urb *write_urb_pool[NUM_URBS ]; -char busy[NUM_URBS ]; +int busy[NUM_URBS ];bool read_urb_busy;/* For device(s) with LED indicator */
@@ -1139,8 +1139,7 @@ static int mos7840_chars_in_buffer(struct tty_struct *tty)spin_lock_irqsave (&mos7840_port->pool_lock, flags);for (i =0 ; i <NUM_URBS ; ++i) {if (mos7840_port->busy[i]) { -struct urb *urb = mos7840_port->write_urb_pool[i]; - chars += urb->transfer_buffer_length; + chars += mos7840_port->busy[i]; } }spin_unlock_irqrestore (&mos7840_port->pool_lock, flags);
@@ -1323,10 +1322,11 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port,/* try to find a free urb in the list */ urb =NULL ; + transfer_size =min (count,URB_TRANSFER_BUFFER_SIZE );spin_lock_irqsave (&mos7840_port->pool_lock, flags);for (i =0 ; i <NUM_URBS ; ++i) {if (!mos7840_port->busy[i]) { - mos7840_port->busy[i] =1 ; + mos7840_port->busy[i] = transfer_size; urb = mos7840_port->write_urb_pool[i];dev_dbg (&port->dev,"URB:%d\n" , i);break ;
@@ -1345,7 +1345,6 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port,if (!urb->transfer_buffer) goto exit; } - transfer_size =min (count,URB_TRANSFER_BUFFER_SIZE );memcpy (urb->transfer_buffer, current_position, transfer_size);
Signature · 1 line
2.7.4
Hello.
Quoted 6 lines · Stas Sergeev
The TIOCOUTQ ioctl calls
chars_in_buffer(), and some apps depend on a correct behaviour of that.
mos7840 implements it wrongly: if you write just one char, TIOCOUTQ will return 32.
This patch should fix it by accounting the number of chars actually writCaylan Van Larson <[email protected]>ten.
???
Quoted 1 line
This patch, unfortunately, misses the Tesed-by tag.
Tested-by.
Quoted 1 line
The reported didn't test it, and I don't have the hardware in question.
Reporter?
Quoted 8 lines
Signed-off-by Stas Sergeev <[email protected]>Reported-by Caylan Van Larson <[email protected]>CC Caylan Van Larson <[email protected]>CC Alan Cox <[email protected]>CC Johan Hovold <[email protected]>CC Greg Kroah-Hartman <[email protected]>
[...]
MBR, Sergei
24.09.2016 16:57, Sergei Shtylyov пишет:
Quoted 13 lines
Hello.
Quoted 6 lines · Stas Sergeev
The TIOCOUTQ ioctl calls
chars_in_buffer(), and some apps depend on a correct behaviour of that.
mos7840 implements it wrongly: if you write just one char, TIOCOUTQ will return 32.
This patch should fix it by accounting the number of chars actually writCaylan Van Larson <[email protected]>ten.???
Quoted 7 lines
Quoted 1 line
This patch, unfortunately, misses the Tesed-by tag.
Tested-by.
Quoted 1 line
The reported didn't test it, and I don't have the hardware in question.
Reporter?
:)
Thanks, will re-send with corrections.