aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2016-09-09 06:01:51 -0400
committerFelipe Balbi <felipe.balbi@linux.intel.com>2016-09-09 07:56:06 -0400
commitd6e10bf2ba4783881670731faf8d3705cad488eb (patch)
tree0ab281fbb3cf757e448b4a77090f064ee68ec804 /drivers/usb
parentc9ffc78745f89e300fe704348dd8e6800acf4d18 (diff)
usb: dwc3: avoid -Wmaybe-uninitialized warning
Cleaning up the loop in dwc3_cleanup_done_reqs() introduced a gcc warning if built with "-Wmaybe-uninitialized": drivers/usb/dwc3/gadget.c: In function 'dwc3_endpoint_transfer_complete': drivers/usb/dwc3/gadget.c:2015:9: 'trb' may be used uninitialized in this function [-Wmaybe-uninitialized] I believe it is a false positive and we always have a valid 'trb' pointer at the end of the function, but neither I nor the compiler are able to prove that. This works around the warning by computing a flag earlier in the function when it's guaranteed to be valid, which tells the compiler that it's safe and makes it easier to understand to me. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Fixes: 31162af447d7 ("usb: dwc3: gadget: avoid while (1) loop on completion") Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/dwc3/gadget.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 37a86522fa88..a5d496dd53b2 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1934,6 +1934,7 @@ static int dwc3_cleanup_done_reqs(struct dwc3 *dwc, struct dwc3_ep *dep,
1934{ 1934{
1935 struct dwc3_request *req, *n; 1935 struct dwc3_request *req, *n;
1936 struct dwc3_trb *trb; 1936 struct dwc3_trb *trb;
1937 bool ioc = false;
1937 int ret; 1938 int ret;
1938 1939
1939 list_for_each_entry_safe(req, n, &dep->started_list, list) { 1940 list_for_each_entry_safe(req, n, &dep->started_list, list) {
@@ -1981,8 +1982,12 @@ static int dwc3_cleanup_done_reqs(struct dwc3 *dwc, struct dwc3_ep *dep,
1981 1982
1982 dwc3_gadget_giveback(dep, req, status); 1983 dwc3_gadget_giveback(dep, req, status);
1983 1984
1984 if (ret) 1985 if (ret) {
1986 if ((event->status & DEPEVT_STATUS_IOC) &&
1987 (trb->ctrl & DWC3_TRB_CTRL_IOC))
1988 ioc = true;
1985 break; 1989 break;
1990 }
1986 } 1991 }
1987 1992
1988 /* 1993 /*
@@ -2010,10 +2015,9 @@ static int dwc3_cleanup_done_reqs(struct dwc3 *dwc, struct dwc3_ep *dep,
2010 return 1; 2015 return 1;
2011 } 2016 }
2012 2017
2013 if (usb_endpoint_xfer_isoc(dep->endpoint.desc)) 2018 if (usb_endpoint_xfer_isoc(dep->endpoint.desc) && ioc)
2014 if ((event->status & DEPEVT_STATUS_IOC) && 2019 return 0;
2015 (trb->ctrl & DWC3_TRB_CTRL_IOC)) 2020
2016 return 0;
2017 return 1; 2021 return 1;
2018} 2022}
2019 2023