From patchwork Thu Dec 10 19:09:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Balbi X-Patchwork-Id: 58238 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp689442lbb; Thu, 10 Dec 2015 11:10:04 -0800 (PST) X-Received: by 10.98.10.197 with SMTP id 66mr9117023pfk.37.1449774604215; Thu, 10 Dec 2015 11:10:04 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r77si200819pfa.239.2015.12.10.11.10.03; Thu, 10 Dec 2015 11:10:04 -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 S1751716AbbLJTKB (ORCPT + 4 others); Thu, 10 Dec 2015 14:10:01 -0500 Received: from arroyo.ext.ti.com ([192.94.94.40]:50845 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751679AbbLJTKA (ORCPT ); Thu, 10 Dec 2015 14:10:00 -0500 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id tBAJA0Dt015405 for ; Thu, 10 Dec 2015 13:10:00 -0600 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id tBAJ9xKj025192 for ; Thu, 10 Dec 2015 13:09:59 -0600 Received: from dlep33.itg.ti.com (157.170.170.75) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.3.224.2; Thu, 10 Dec 2015 13:09:59 -0600 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id tBAJ9xsd006116; Thu, 10 Dec 2015 13:09:59 -0600 From: Felipe Balbi To: Linux USB Mailing List CC: Felipe Balbi Subject: [PATCH] usb: dwc3: gadget: pass a condition to dev_WARN_ONCE() Date: Thu, 10 Dec 2015 13:09:58 -0600 Message-ID: <1449774598-30565-1-git-send-email-balbi@ti.com> X-Mailer: git-send-email 2.6.3 MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org 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(-) -- 2.6.3 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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) + "%s is already disabled\n", + dep->name)) return 0; - } spin_lock_irqsave(&dwc->lock, flags); ret = __dwc3_gadget_ep_disable(dep);