From: Michal Nazarewicz <mina86@mina86.com>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: Felipe Balbi <felipe.balbi@linux.intel.com>,
linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
Michal Nazarewicz <mina86@mina86.com>
Subject: [PATCH] usb: gadget: mv_udc: clarify a switch with an implicit fall-through
Date: Wed, 8 Feb 2017 15:49:10 +0100 [thread overview]
Message-ID: <20170208144910.31405-1-mina86@mina86.com> (raw)
In-Reply-To: <20170208132154.GA30518@kroah.com>
Rearrange statements in mv_ep_enable function so that it’s obvious
what the switch does and how zlt, ios and mult variables are
initialised. Most notably, this gets rid of an implicit fall-through
so people don’t have to wonder whether it was intenional or not.
Addresses-Coverity-ID: 201385
Reported-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Signed-off-by: Michal Nazarewicz <mina86@mina86.com>
---
drivers/usb/gadget/udc/mv_udc_core.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/drivers/usb/gadget/udc/mv_udc_core.c b/drivers/usb/gadget/udc/mv_udc_core.c
index d82a91bddbd9..7440c9f92ec1 100644
--- a/drivers/usb/gadget/udc/mv_udc_core.c
+++ b/drivers/usb/gadget/udc/mv_udc_core.c
@@ -445,7 +445,8 @@ static int mv_ep_enable(struct usb_ep *_ep,
struct mv_dqh *dqh;
u16 max = 0;
u32 bit_pos, epctrlx, direction;
- unsigned char zlt = 0, ios = 0, mult = 0;
+ const unsigned char zlt = 1;
+ unsigned char ios, mult;
unsigned long flags;
ep = container_of(_ep, struct mv_ep, ep);
@@ -465,8 +466,6 @@ static int mv_ep_enable(struct usb_ep *_ep,
* disable HW zero length termination select
* driver handles zero length packet through req->req.zero
*/
- zlt = 1;
-
bit_pos = 1 << ((direction == EP_DIR_OUT ? 0 : 16) + ep->ep_num);
/* Check if the Endpoint is Primed */
@@ -481,16 +480,16 @@ static int mv_ep_enable(struct usb_ep *_ep,
(unsigned)bit_pos);
goto en_done;
}
+
/* Set the max packet length, interrupt on Setup and Mult fields */
+ ios = 0;
+ mult = 0;
switch (desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) {
case USB_ENDPOINT_XFER_BULK:
- zlt = 1;
- mult = 0;
+ case USB_ENDPOINT_XFER_INT:
break;
case USB_ENDPOINT_XFER_CONTROL:
ios = 1;
- case USB_ENDPOINT_XFER_INT:
- mult = 0;
break;
case USB_ENDPOINT_XFER_ISOC:
/* Calculate transactions needed for high bandwidth iso */
--
2.11.0.483.g087da7b7c-goog
next prev parent reply other threads:[~2017-02-08 14:49 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-08 7:22 [PATCH 1/2] drivers: usb: gadget: udc: add missing break in switch Gustavo A. R. Silva
2017-02-08 7:25 ` [PATCH 2/2] drivers: usb: gadget: udc: remove logically dead code Gustavo A. R. Silva
2017-02-08 9:23 ` [PATCH 1/2] drivers: usb: gadget: udc: add missing break in switch Felipe Balbi
2017-02-08 10:02 ` Gustavo A. R. Silva
2017-02-08 12:05 ` Felipe Balbi
2017-02-08 13:03 ` Greg KH
2017-02-08 13:13 ` Felipe Balbi
2017-02-08 13:16 ` Michal Nazarewicz
2017-02-08 13:21 ` Greg KH
2017-02-08 14:49 ` Michal Nazarewicz [this message]
2017-03-01 14:34 [PATCH] usb: gadget: mv_udc: clarify a switch with an implicit fall-through Michal Nazarewicz
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=20170208144910.31405-1-mina86@mina86.com \
--to=mina86@mina86.com \
--cc=felipe.balbi@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.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
all inboxes | Powered by JetHome®