From patchwork Thu Dec 10 21:51:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Balbi X-Patchwork-Id: 58247 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp765251lbb; Thu, 10 Dec 2015 13:51:59 -0800 (PST) X-Received: by 10.98.42.148 with SMTP id q142mr10496784pfq.0.1449784319747; Thu, 10 Dec 2015 13:51:59 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id iw2si22713068pac.46.2015.12.10.13.51.59; Thu, 10 Dec 2015 13:51:59 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753997AbbLJVv6 (ORCPT + 4 others); Thu, 10 Dec 2015 16:51:58 -0500 Received: from devils.ext.ti.com ([198.47.26.153]:44815 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753886AbbLJVv5 (ORCPT ); Thu, 10 Dec 2015 16:51:57 -0500 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id tBALpudZ003771; Thu, 10 Dec 2015 15:51:56 -0600 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id tBALpuUK001946; Thu, 10 Dec 2015 15:51:56 -0600 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.3.224.2; Thu, 10 Dec 2015 15:51:55 -0600 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id tBALptOA025492; Thu, 10 Dec 2015 15:51:55 -0600 From: Felipe Balbi To: David Cohen CC: Linux USB Mailing List Subject: Re: [PATCH] usb: dwc3: gadget: pass a condition to dev_WARN_ONCE() In-Reply-To: <20151210212103.GA14759@psi-dev26.jf.intel.com> References: <1449774598-30565-1-git-send-email-balbi@ti.com> <20151210212103.GA14759@psi-dev26.jf.intel.com> User-Agent: Notmuch/0.21 (http://notmuchmail.org) Emacs/24.5.1 (x86_64-pc-linux-gnu) Date: Thu, 10 Dec 2015 15:51:52 -0600 Message-ID: <87oadyhszr.fsf@saruman.tx.rr.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Hi, David Cohen 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 >> --- >> 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 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 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);