Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752206AbbLNDsZ (ORCPT ); Sun, 13 Dec 2015 22:48:25 -0500 Received: from mga11.intel.com ([192.55.52.93]:9285 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750838AbbLNDsY (ORCPT ); Sun, 13 Dec 2015 22:48:24 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,425,1444719600"; d="scan'208";a="840476264" From: changbin.du@intel.com To: balbi@ti.com Cc: gregkh@linuxfoundation.org, John.Youn@synopsys.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, "Du, Changbin" Subject: [PATCH v2] usb: gadget: make usb_ep_enable return -EBUSY if ep has already enabled Date: Mon, 14 Dec 2015 11:40:21 +0800 Message-Id: <1450064421-30553-1-git-send-email-changbin.du@intel.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <8737vajjy7.fsf@saruman.tx.rr.com> References: <8737vajjy7.fsf@saruman.tx.rr.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1229 Lines: 42 From: "Du, Changbin" When usb_ep_enable on a enabled ep, the configuration of the ep probably has changed. In this scenario, the ep configuration in hw should be reprogrammed by udc driver. Hence, it is better to return an error to inform the caller. Signed-off-by: Du, Changbin --- change from v1: add WARN_ON_ONCE message. --- include/linux/usb/gadget.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index 3d583a1..b88df2a 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h @@ -267,8 +267,12 @@ static inline int usb_ep_enable(struct usb_ep *ep) { int ret; - if (ep->enabled) - return 0; + /** + * An enabled ep may has requests in progress, hence shouldn't + * reprogram its hw configuration. + */ + if (WARN_ON_ONCE(ep->enabled)) + return -EBUSY; ret = ep->ops->enable(ep, ep->desc); if (ret) -- 2.5.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/