2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-21 11:44:01 +08:00

usb: dwc3: gadget: simplify run_stop() break condition

it's clear now that when is_on=true, we must loop
until DWC3_DSTS_DEVCTRLHLT clears; while when
is_on=false we must loop until DWC3_DSTS_DEVCTRLHLT
gets set.

Instead of adding actual if() statements, we can
rely on XOR operation to evaluate to true only when
the above conditions apply. Then, we can move the
break condition back to the while() statement
together with our timeout check and the resulting
code is very compact and simpler to read.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
This commit is contained in:
Felipe Balbi 2016-06-09 16:47:05 +03:00
parent f2df679b6c
commit b6d4e16e83

View File

@ -1574,14 +1574,8 @@ static int dwc3_gadget_run_stop(struct dwc3 *dwc, int is_on, int suspend)
do { do {
reg = dwc3_readl(dwc->regs, DWC3_DSTS); reg = dwc3_readl(dwc->regs, DWC3_DSTS);
if (is_on) { reg &= DWC3_DSTS_DEVCTRLHLT;
if (!(reg & DWC3_DSTS_DEVCTRLHLT)) } while (--timeout && !(!is_on ^ !reg));
break;
} else {
if (reg & DWC3_DSTS_DEVCTRLHLT)
break;
}
} while (--timeout);
if (!timeout) if (!timeout)
return -ETIMEDOUT; return -ETIMEDOUT;