From: Johan Hovold Date: Wed, 19 May 2021 09:20:03 +0000 (+0200) Subject: USB: serial: io_edgeport: drop buffer-callback sanity checks X-Git-Tag: v5.15~788^2~7^2~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9a8253a7c2da1d78183029a46bf04fb7beb933eb;p=platform%2Fkernel%2Flinux-starfive.git 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 d76f2f4462bb ("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: Greg Kroah-Hartman Signed-off-by: Johan Hovold --- diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c index 1f8dff4..ea4edf5e 100644 --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c @@ -1351,9 +1351,7 @@ exit_send: /***************************************************************************** * 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;