Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751871AbcDUGiW (ORCPT ); Thu, 21 Apr 2016 02:38:22 -0400 Received: from mail-db3on0097.outbound.protection.outlook.com ([157.55.234.97]:55004 "EHLO emea01-db3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751796AbcDUGiU convert rfc822-to-8bit (ORCPT ); Thu, 21 Apr 2016 02:38:20 -0400 From: Jun Li To: Roger Quadros , "stern@rowland.harvard.edu" , "balbi@kernel.org" , "gregkh@linuxfoundation.org" , "peter.chen@freescale.com" CC: "dan.j.williams@intel.com" , "jun.li@freescale.com" , "mathias.nyman@linux.intel.com" , "tony@atomide.com" , "Joao.Pinto@synopsys.com" , "abrestic@chromium.org" , "r.baldyga@samsung.com" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-omap@vger.kernel.org" Subject: RE: [PATCH v6 09/12] usb: gadget: udc: adapt to OTG core Thread-Topic: [PATCH v6 09/12] usb: gadget: udc: adapt to OTG core Thread-Index: AQHRj0RV7MO/tAbHz06QbtTGgchQCZ+UDbgw Date: Thu, 21 Apr 2016 06:38:16 +0000 Message-ID: References: <1459865117-7032-1-git-send-email-rogerq@ti.com> <1459865117-7032-10-git-send-email-rogerq@ti.com> In-Reply-To: <1459865117-7032-10-git-send-email-rogerq@ti.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: ti.com; dkim=none (message not signed) header.d=none;ti.com; dmarc=none action=none header.from=nxp.com; x-originating-ip: [199.59.225.131] x-ms-office365-filtering-correlation-id: 113cd8a8-6cc7-4902-533d-08d369af8591 x-microsoft-exchange-diagnostics: 1;AM4PR04MB2130;5:44tKyj+1xaAHCsCxdVLUmGRmB44kZ6Rs9aHYr0Ky136ksQ27uUevu3zSFxmIUKreAKekKVF4IPt/6PLzV8YQQ/OK4KHPHK2KUkZvrz5pZmvceWlXs8JjdaMB+/oxu4cyb9cHn5fFWRJSd/SC/A1QZru/T8mnK2cdt6Y0Ci6iLs/5ggAXsCothzpoUij7Em5u;24:3pU1TD7+0XHBwqfmk7sde8V9xNvLYh3KaVcMWDkFlksAW5d64D4AYcpvFvb/61hqvgowSpNRhCRpu+8+36Qxn7pYukrW3sx0BCFzcqSlxCE=;7:FTRmUR59FWx1rOX5FPewFmoZTuN06glslo5LBHJRUzbUkb5zqXnZX27fy8HZqGU/GFu+mOr7savfIH14YHiAi+bDOQGyq4DVZ51d2Ozx0f3us/+9UwvjgKcZWOfGP9dDJhGUakQwdtR9oEsgXPfg3XC3yDAlj0I39TbgnXnIqnF/LJBEGwnUCjLp146qoOcItoowipHr1Hxtwsyd7OpmQ2N/yzlpKr/ILzxj4eqK4AY= x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:AM4PR04MB2130; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(9101521026)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6055026);SRVR:AM4PR04MB2130;BCL:0;PCL:0;RULEID:;SRVR:AM4PR04MB2130; x-forefront-prvs: 091949432C x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(6009001)(76576001)(33656002)(74316001)(5008740100001)(92566002)(5003600100002)(6116002)(1096002)(586003)(102836003)(1220700001)(3846002)(5002640100001)(10400500002)(189998001)(5001770100001)(2171001)(87936001)(81166005)(2906002)(11100500001)(2201001)(5004730100002)(2950100001)(77096005)(2900100001)(9686002)(66066001)(3660700001)(76176999)(86362001)(106116001)(50986999)(122556002)(54356999)(3280700002)(2501003)(7059030);DIR:OUT;SFP:1101;SCL:1;SRVR:AM4PR04MB2130;H:AM4PR04MB2130.eurprd04.prod.outlook.com;FPR:;SPF:None;MLV:sfv;LANG:en; spamdiagnosticoutput: 1:23 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Apr 2016 06:38:16.8583 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR04MB2130 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1996 Lines: 83 Hi, ... > > /** > + * usb_gadget_start - start the usb gadget controller and connect to > +bus > + * @gadget: the gadget device to start > + * > + * This is external API for use by OTG core. > + * > + * Start the usb device controller and connect to bus (enable pull). > + */ > +static int usb_gadget_start(struct usb_gadget *gadget) { > + int ret; > + struct usb_udc *udc = NULL; > + > + dev_dbg(&gadget->dev, "%s\n", __func__); > + mutex_lock(&udc_lock); > + list_for_each_entry(udc, &udc_list, list) > + if (udc->gadget == gadget) > + goto found; > + > + dev_err(gadget->dev.parent, "%s: gadget not registered.\n", > + __func__); > + mutex_unlock(&udc_lock); > + return -EINVAL; > + > +found: > + ret = usb_gadget_udc_start(udc); > + if (ret) > + dev_err(&udc->dev, "USB Device Controller didn't start: %d\n", > + ret); > + else > + usb_udc_connect_control(udc); For drd, it's fine, but for real otg, gadget connect should be done by loc_conn() instead of gadget start. > + > + mutex_unlock(&udc_lock); > + > + return ret; > +} > + > +/** > + * usb_gadget_stop - disconnect from bus and stop the usb gadget > + * @gadget: The gadget device we want to stop > + * > + * This is external API for use by OTG core. > + * > + * Disconnect from the bus (disable pull) and stop the > + * gadget controller. > + */ > +static int usb_gadget_stop(struct usb_gadget *gadget) { > + struct usb_udc *udc = NULL; > + > + dev_dbg(&gadget->dev, "%s\n", __func__); > + mutex_lock(&udc_lock); > + list_for_each_entry(udc, &udc_list, list) > + if (udc->gadget == gadget) > + goto found; > + > + dev_err(gadget->dev.parent, "%s: gadget not registered.\n", > + __func__); > + mutex_unlock(&udc_lock); > + return -EINVAL; > + > +found: > + usb_gadget_disconnect(udc->gadget); Likewise, gadget disconnect also should be done by loc_conn() instead of gadget stop. > + udc->driver->disconnect(udc->gadget); > + usb_gadget_udc_stop(udc); > + mutex_unlock(&udc_lock); > + > + return 0; > +} > + Li Jun