Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 50a5f70c authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman
Browse files

USB: serial: clean up generic write start busy test



Submit write urb if it is not already in use and we have buffered data.

Signed-off-by: default avatarJohan Hovold <jhovold@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 1a1405e2
Loading
Loading
Loading
Loading
+4 −11
Original line number Diff line number Diff line
@@ -259,21 +259,14 @@ static int usb_serial_generic_write_start(struct usb_serial_port *port)
	int result;
	int count;
	unsigned long flags;
	bool start_io;

	/* Atomically determine whether we can and need to start a USB
	 * operation. */
	spin_lock_irqsave(&port->lock, flags);
	if (port->write_urb_busy)
		start_io = false;
	else {
		start_io = (kfifo_len(&port->write_fifo) != 0);
		port->write_urb_busy = start_io;
	}
	if (port->write_urb_busy || !kfifo_len(&port->write_fifo)) {
		spin_unlock_irqrestore(&port->lock, flags);

	if (!start_io)
		return 0;
	}
	port->write_urb_busy = 1;
	spin_unlock_irqrestore(&port->lock, flags);

	data = port->write_urb->transfer_buffer;
	count = kfifo_out_locked(&port->write_fifo, data, port->bulk_out_size, &port->lock);