Commit 9a8253a7 authored by Johan Hovold's avatar Johan Hovold
Browse files

USB: serial: io_edgeport: drop buffer-callback sanity checks



The driver write_room and chars_in_buffer callbacks used to incorrectly
return a negative errno in case they were called while or after the port
had been closed. The return value was later changed to zero by commit
d76f2f44 ("io_edgeport: Fix various bogus returns to the tty
layer") but the bogus sanity checks were left in place as were the
outdated function-header comments.

These callbacks will never be called for an uninitialised port so drop
the unnecessary sanity checks and the outdated comments.

Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
parent dcbc0ae4
Loading
Loading
Loading
Loading
+1 −26
Original line number Diff line number Diff line
@@ -1351,9 +1351,7 @@ static void send_more_port_data(struct edgeport_serial *edge_serial,
/*****************************************************************************
 * edge_write_room
 *	this function is called by the tty driver when it wants to know how
 *	many bytes of data we can accept for a specific port. If successful,
 *	we return the amount of room that we have for this port	(the txCredits)
 *	otherwise we return a negative error number.
 *	many bytes of data we can accept for a specific port.
 *****************************************************************************/
static unsigned int edge_write_room(struct tty_struct *tty)
{
@@ -1362,16 +1360,6 @@ static unsigned int edge_write_room(struct tty_struct *tty)
	unsigned int room;
	unsigned long flags;

	if (edge_port == NULL)
		return 0;
	if (edge_port->closePending)
		return 0;

	if (!edge_port->open) {
		dev_dbg(&port->dev, "%s - port not opened\n", __func__);
		return 0;
	}

	/* total of both buffers is still txCredit */
	spin_lock_irqsave(&edge_port->ep_lock, flags);
	room = edge_port->txCredits - edge_port->txfifo.count;
@@ -1387,9 +1375,6 @@ static unsigned int edge_write_room(struct tty_struct *tty)
 *	this function is called by the tty driver when it wants to know how
 *	many bytes of data we currently have outstanding in the port (data that
 *	has been written, but hasn't made it out the port yet)
 *	If successful, we return the number of bytes left to be written in the
 *	system,
 *	Otherwise we return a negative error number.
 *****************************************************************************/
static unsigned int edge_chars_in_buffer(struct tty_struct *tty)
{
@@ -1398,16 +1383,6 @@ static unsigned int edge_chars_in_buffer(struct tty_struct *tty)
	unsigned int num_chars;
	unsigned long flags;

	if (edge_port == NULL)
		return 0;
	if (edge_port->closePending)
		return 0;

	if (!edge_port->open) {
		dev_dbg(&port->dev, "%s - port not opened\n", __func__);
		return 0;
	}

	spin_lock_irqsave(&edge_port->ep_lock, flags);
	num_chars = edge_port->maxTxCredits - edge_port->txCredits +
						edge_port->txfifo.count;