usb: dwc3: gadget: pass a condition to dev_WARN_ONCE()

Message ID 87oadyhszr.fsf@saruman.tx.rr.com
State Accepted
Commit 95ca961c758cd9ce789247098b09c39017637e58
Headers show

Commit Message

Felipe Balbi Dec. 10, 2015, 9:51 p.m.
Hi,

David Cohen <david.a.cohen@linux.intel.com> writes:
> Hi Felipe,

>

> On Thu, Dec 10, 2015 at 01:09:58PM -0600, Felipe Balbi wrote:

>> 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 | 14 ++++++--------

>>  1 file changed, 6 insertions(+), 8 deletions(-)

>> 

>> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c

>> index 3063c5ba5563..96cc1d756d99 100644

>> --- a/drivers/usb/dwc3/gadget.c

>> +++ b/drivers/usb/dwc3/gadget.c

>> @@ -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)

>

> You missed a , after the condition.


yup, already fixed.

8<---------------------------------------------------------------
commit 4b2ec826d09cd0307b8250fa21795b718cdb7d37
Author: Felipe Balbi <balbi@ti.com>
Date:   Thu Dec 10 13:08:20 2015 -0600

    usb: dwc3: gadget: pass a condition to dev_WARN_ONCE()
    
    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>




-- 
balbi

Patch

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 3063c5ba5563..1212ae4a3c2f 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -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);