USB: ti_usb_3410_5052: query hardware-buffer status in chars_in_buffer
Query hardware-buffer status in chars_in_buffer should the write fifo be empty. This is needed to make the tty layer wait for hardware buffers to drain on close. Signed-off-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
		
					parent
					
						
							
								b5784f7d85
							
						
					
				
			
			
				commit
				
					
						2c992cd737
					
				
			
		
					 1 changed files with 8 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -687,6 +687,8 @@ static int ti_chars_in_buffer(struct tty_struct *tty)
 | 
			
		|||
	struct ti_port *tport = usb_get_serial_port_data(port);
 | 
			
		||||
	int chars = 0;
 | 
			
		||||
	unsigned long flags;
 | 
			
		||||
	int ret;
 | 
			
		||||
	u8 lsr;
 | 
			
		||||
 | 
			
		||||
	if (tport == NULL)
 | 
			
		||||
		return 0;
 | 
			
		||||
| 
						 | 
				
			
			@ -695,6 +697,12 @@ static int ti_chars_in_buffer(struct tty_struct *tty)
 | 
			
		|||
	chars = kfifo_len(&tport->write_fifo);
 | 
			
		||||
	spin_unlock_irqrestore(&tport->tp_lock, flags);
 | 
			
		||||
 | 
			
		||||
	if (!chars) {
 | 
			
		||||
		ret = ti_get_lsr(tport, &lsr);
 | 
			
		||||
		if (!ret && !(lsr & TI_LSR_TX_EMPTY))
 | 
			
		||||
			chars = 1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	dev_dbg(&port->dev, "%s - returns %d\n", __func__, chars);
 | 
			
		||||
	return chars;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue