From: Johan Hovold <johan@kernel.org>
To: Ladislav Michl <ladis@linux-mips.org>
Cc: linux-usb@vger.kernel.org, Johan Hovold <johan@kernel.org>
Subject: USB: serial: ti_usb_3410_5052: Avoid goto in bulk in callback
Date: Mon, 11 Dec 2017 11:10:35 +0100 [thread overview]
Message-ID: <20171211101035.GH5672@localhost> (raw)
On Mon, Dec 11, 2017 at 12:09:19AM +0100, Ladislav Michl wrote:
> Make status handling in bulk in callback function more compact,
> which renders goto pointless.
>
> Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
> ---
> drivers/usb/serial/ti_usb_3410_5052.c | 36 ++++++++++++++---------------------
> 1 file changed, 14 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
> index 6b22857f6e52..2786ec7bbca2 100644
> --- a/drivers/usb/serial/ti_usb_3410_5052.c
> +++ b/drivers/usb/serial/ti_usb_3410_5052.c
> @@ -1219,29 +1219,10 @@ static void ti_bulk_in_callback(struct urb *urb)
>
> switch (status) {
> case 0:
> - break;
> - case -ECONNRESET:
> - case -ENOENT:
> - case -ESHUTDOWN:
> - dev_dbg(dev, "%s - urb shutting down, %d\n", __func__, status);
> - return;
> - default:
> - dev_err(dev, "%s - nonzero urb status, %d\n",
> - __func__, status);
> - }
> -
> - if (status == -EPIPE)
> - goto exit;
> -
> - if (status) {
> - dev_err(dev, "%s - stopping read!\n", __func__);
> - return;
> - }
> -
> - if (urb->actual_length) {
> + if (!urb->actual_length)
> + break;
> usb_serial_debug_data(dev, __func__, urb->actual_length,
> urb->transfer_buffer);
> -
> if (!tport->tp_is_open)
> dev_dbg(dev, "%s - port closed, dropping data\n",
> __func__);
> @@ -1250,9 +1231,20 @@ static void ti_bulk_in_callback(struct urb *urb)
> spin_lock(&tport->tp_lock);
> port->icount.rx += urb->actual_length;
> spin_unlock(&tport->tp_lock);
> + break;
> + case -ECONNRESET:
> + case -ENOENT:
> + case -ESHUTDOWN:
> + dev_dbg(dev, "%s - urb shutting down, %d\n", __func__, status);
> + return;
> + case -EPIPE:
> + break;
> + default:
> + dev_err(dev, "%s - nonzero urb status, %d\n",
> + __func__, status);
> + return;
I'm afraid I don't consider this an improvement. I prefer using gotos
for error paths, while keeping the success path out of the status
switch.
Furthermore, this isn't functionally equivalent as we'd not longer log
an error for -EPIPE.
In fact, that -EPIPE is already on my TODO list as we really should not
be resubmitting URBs for a stalled endpoint in the first place. That in
turn should allow for some clean up of this callback.
Thanks,
Johan
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next reply other threads:[~2017-12-11 10:10 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-11 10:10 Johan Hovold [this message]
-- strict thread matches above, loose matches on Subject: below --
2017-12-13 11:50 USB: serial: ti_usb_3410_5052: Avoid goto in bulk in callback Johan Hovold
2017-12-13 11:32 Ladislav Michl
2017-12-13 11:16 Johan Hovold
2017-12-11 12:44 Ladislav Michl
2017-12-11 11:52 Johan Hovold
2017-12-11 11:32 Ladislav Michl
2017-12-10 23:09 Ladislav Michl
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171211101035.GH5672@localhost \
--to=johan@kernel.org \
--cc=ladis@linux-mips.org \
--cc=linux-usb@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).