usb: dwc3: gadget: pass a condition to dev_WARN_ONCE()
authorFelipe Balbi <balbi@ti.com>
Thu, 10 Dec 2015 19:08:20 +0000 (13:08 -0600)
committerFelipe Balbi <balbi@ti.com>
Wed, 16 Dec 2015 16:07:27 +0000 (10:07 -0600)
instead of using:

if (condition) {
dev_WARN_ONCE(dev, true, "foo");
return -EINVAL;
}

let's use:

if (dev_WARN_ONCE(dev, condition, "foo"))
return -EINVAL;

Signed-off-by: Felipe Balbi <balbi@ti.com>
drivers/usb/dwc3/gadget.c

index 975801839355a90dabeaeed3c7aaaff85d176747..64b2a8303d33dd1d5220e238d9dedbd52937eeaf 100644 (file)
@@ -661,11 +661,10 @@ static int dwc3_gadget_ep_enable(struct usb_ep *ep,
        dep = to_dwc3_ep(ep);
        dwc = dep->dwc;
 
-       if (dep->flags & DWC3_EP_ENABLED) {
-               dev_WARN_ONCE(dwc->dev, true, "%s is already enabled\n",
-                               dep->name);
+       if (dev_WARN_ONCE(dwc->dev, dep->flags & DWC3_EP_ENABLED,
+                                       "%s is already enabled\n",
+                                       dep->name))
                return 0;
-       }
 
        spin_lock_irqsave(&dwc->lock, flags);
        ret = __dwc3_gadget_ep_enable(dep, desc, ep->comp_desc, false, false);
@@ -689,11 +688,10 @@ static int dwc3_gadget_ep_disable(struct usb_ep *ep)
        dep = to_dwc3_ep(ep);
        dwc = dep->dwc;
 
-       if (!(dep->flags & DWC3_EP_ENABLED)) {
-               dev_WARN_ONCE(dwc->dev, true, "%s is already disabled\n",
-                               dep->name);
+       if (dev_WARN_ONCE(dwc->dev, !(dep->flags & DWC3_EP_ENABLED),
+                                       "%s is already disabled\n",
+                                       dep->name))
                return 0;
-       }
 
        spin_lock_irqsave(&dwc->lock, flags);
        ret = __dwc3_gadget_ep_disable(dep);