From: "Stefan Brüns" <stefan.bruens@rwth-aachen.de>
To: <linux-media@vger.kernel.org>
Cc: linux-kernel@vger.kernel.org,
"Mauro Carvalho Chehab" <mchehab@kernel.org>,
"Antti Palosaari" <crope@iki.fi>,
"Stefan Brüns" <stefan.bruens@rwth-aachen.de>
Subject: [PATCH 1/3] media: dvb-usb-v2: Report error on all error paths
Date: Fri, 12 Apr 2019 03:12:58 +0200 [thread overview]
Message-ID: <f58ff4ca-9b9e-44af-a617-cdaa9e71f15f@rwthex-w2-a.rwth-ad.de> (raw)
In-Reply-To: <20190412011300.5468-1-stefan.bruens@rwth-aachen.de>
actual_length != wlen is the only error path which does not generate an
error message. Adding an error message here allows to report a more
specific error and to remove the error reporting from the call sites.
Also clean up the error paths - in case of an error, the remaining
code is skipped, and ret is returned. Skip setting ret and return
immediately (no cleanup necessary).
---
drivers/media/usb/dvb-usb-v2/dvb_usb_urb.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/drivers/media/usb/dvb-usb-v2/dvb_usb_urb.c b/drivers/media/usb/dvb-usb-v2/dvb_usb_urb.c
index 5bafeb6486be..5b32d159f968 100644
--- a/drivers/media/usb/dvb-usb-v2/dvb_usb_urb.c
+++ b/drivers/media/usb/dvb-usb-v2/dvb_usb_urb.c
@@ -37,14 +37,19 @@ static int dvb_usb_v2_generic_io(struct dvb_usb_device *d,
ret = usb_bulk_msg(d->udev, usb_sndbulkpipe(d->udev,
d->props->generic_bulk_ctrl_endpoint), wbuf, wlen,
&actual_length, 2000);
- if (ret < 0)
+ if (ret) {
dev_err(&d->udev->dev, "%s: usb_bulk_msg() failed=%d\n",
KBUILD_MODNAME, ret);
- else
- ret = actual_length != wlen ? -EIO : 0;
+ return ret;
+ }
+ if (actual_length != wlen) {
+ dev_err(&d->udev->dev, "%s: usb_bulk_msg() write length=%d, actual=%d\n",
+ KBUILD_MODNAME, wlen, actual_length);
+ return -EIO;
+ }
- /* an answer is expected, and no error before */
- if (!ret && rbuf && rlen) {
+ /* an answer is expected */
+ if (rbuf && rlen) {
if (d->props->generic_bulk_ctrl_delay)
usleep_range(d->props->generic_bulk_ctrl_delay,
d->props->generic_bulk_ctrl_delay
--
2.21.0
next parent reply other threads:[~2019-04-12 1:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20190412011300.5468-1-stefan.bruens@rwth-aachen.de>
2019-04-12 1:12 ` Stefan Brüns [this message]
2019-05-19 10:17 ` [PATCH 1/3] media: dvb-usb-v2: Report error on all error paths Sean Young
2019-04-12 1:12 ` [PATCH 2/3] media: dvbsky: Remove duplicate error reporting for dvbsky_usb_generic_rw Stefan Brüns
2019-04-12 1:13 ` [PATCH 3/3] media: af9035: " Stefan Brüns
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=f58ff4ca-9b9e-44af-a617-cdaa9e71f15f@rwthex-w2-a.rwth-ad.de \
--to=stefan.bruens@rwth-aachen.de \
--cc=crope@iki.fi \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@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).