Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752159AbcDZFLt (ORCPT ); Tue, 26 Apr 2016 01:11:49 -0400 Received: from mail-db3on0055.outbound.protection.outlook.com ([157.55.234.55]:53211 "EHLO emea01-db3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750869AbcDZFLq convert rfc822-to-8bit (ORCPT ); Tue, 26 Apr 2016 01:11:46 -0400 From: Jun Li To: Peter Chen CC: Roger Quadros , "stern@rowland.harvard.edu" , "balbi@kernel.org" , "gregkh@linuxfoundation.org" , "peter.chen@freescale.com" , "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 07/12] usb: otg: add OTG/dual-role core Thread-Topic: [PATCH v6 07/12] usb: otg: add OTG/dual-role core Thread-Index: AQHRj0RO5BWWFaE5xk2PoA2IY651xp+bkXwggAAsm4CAAAScIA== Date: Tue, 26 Apr 2016 05:11:36 +0000 Message-ID: References: <1459865117-7032-1-git-send-email-rogerq@ti.com> <1459865117-7032-8-git-send-email-rogerq@ti.com> <20160426034711.GC2978@peterchendt> In-Reply-To: <20160426034711.GC2978@peterchendt> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=none action=none header.from=nxp.com; x-originating-ip: [123.151.195.53] x-ms-office365-filtering-correlation-id: eea16fd4-0733-4534-e04a-08d36d913db9 x-microsoft-exchange-diagnostics: 1;AM4PR04MB2130;5:OJNvf492tZwCG/2fv7DYRPN8swEX4F3dtlTCaw2pO1SRuXVwFJDBNmoMBUy5kUiszubMiJB+tr0/aKS6i70aSC3Hv8EqkuSXb8RAJ7LDeBQJa3FlrLThr+Hi7N9HRtL+fyIbt5DWnx721QtrfeApsw==;24:Cs8oYrQm2GTL1Xkp7WuVH6nPc/kUkTGR7VLlRo+LwfA4l+iLNW5vqi8v7luuJGhq12CrLIp2a0W7P15OydyyyigVvaHXls4df+fQHeTIF/U=;7:WiHmrNHm95WIERrG1OjK+TsBfA0Q9NyP3doUhdol9nuDokbrnD5NO59mcyhO/vcwb4wMStVWa6Q/PtlITYE+ihIKczcj7ZkjdN16nBkPxTDJl/CafeslzFGTtvRrIxCHIIot8wp3VrISBv8a7E0jVoq6z2BXI2T7HW6XjEtgHv92iIN9gejIPxx+Exq4OqOl 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:(9101521072)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6055026);SRVR:AM4PR04MB2130;BCL:0;PCL:0;RULEID:;SRVR:AM4PR04MB2130; x-forefront-prvs: 0924C6A0D5 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(6009001)(24454002)(13464003)(377454003)(586003)(76576001)(6116002)(3846002)(102836003)(76176999)(54356999)(93886004)(87936001)(50986999)(189998001)(9686002)(19580405001)(3660700001)(3280700002)(106116001)(33656002)(10400500002)(81166005)(19580395003)(2906002)(86362001)(5004730100002)(4326007)(92566002)(5008740100001)(110136002)(1220700001)(1096002)(122556002)(77096005)(15975445007)(11100500001)(66066001)(1411001)(5003600100002)(5002640100001)(2950100001)(2900100001)(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: 26 Apr 2016 05:11:36.1242 (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: 3569 Lines: 114 Hi > -----Original Message----- > From: Peter Chen [mailto:hzpeterchen@gmail.com] > Sent: Tuesday, April 26, 2016 11:47 AM > To: Jun Li > Cc: Roger Quadros ; stern@rowland.harvard.edu; > balbi@kernel.org; gregkh@linuxfoundation.org; peter.chen@freescale.com; > 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 07/12] usb: otg: add OTG/dual-role core > > On Tue, Apr 26, 2016 at 02:07:56AM +0000, Jun Li wrote: > > > +struct usb_otg *usb_otg_register(struct device *dev, > > > + struct usb_otg_config *config) { > > > + struct usb_otg *otg; > > > + struct otg_wait_data *wait; > > > + int ret = 0; > > > + > > > + if (!dev || !config || !config->fsm_ops) > > > + return ERR_PTR(-EINVAL); > > > + > > > + /* already in list? */ > > > + mutex_lock(&otg_list_mutex); > > > + if (usb_otg_get_data(dev)) { > > > + dev_err(dev, "otg: %s: device already in otg list\n", > > > + __func__); > > > + ret = -EINVAL; > > > + goto unlock; > > > + } > > > + > > > + /* allocate and add to list */ > > > + otg = kzalloc(sizeof(*otg), GFP_KERNEL); > > > + if (!otg) { > > > + ret = -ENOMEM; > > > + goto unlock; > > > + } > > > + > > > + otg->dev = dev; > > > + otg->caps = config->otg_caps; > > > + > > > + if ((otg->caps->hnp_support || otg->caps->srp_support || > > > + otg->caps->adp_support) && !config->otg_work) > > > + dev_info(dev, "otg: limiting to dual-role\n"); > > > > dev_err, this should be an error. > > The condition may be wrong, but it is an information to show that current > OTG is dual-role. This should not happen in any correct design, I even doubt if we should try to continue by "downgrade" it to be duel role, currently the only example user is dual role, so doing like this can't be tested by real case, this downgrade is not so easy like we image, at least for chipidea otg driver, simply replace a queue worker may not work, as we have much more difference between the 2 configs. Li Jun > > Peter > > > > > + > > > + if (config->otg_work) /* custom otg_work ? */ > > > + INIT_WORK(&otg->work, config->otg_work); > > > + else > > > + INIT_WORK(&otg->work, usb_otg_work); > > > + > > > + otg->wq = create_singlethread_workqueue("usb_otg"); > > > + if (!otg->wq) { > > > + dev_err(dev, "otg: %s: can't create workqueue\n", > > > + __func__); > > > + ret = -ENOMEM; > > > + goto err_wq; > > > + } > > > + > > > + /* set otg ops */ > > > + otg->fsm.ops = config->fsm_ops; > > > + > > > + mutex_init(&otg->fsm.lock); > > > + > > > + list_add_tail(&otg->list, &otg_list); > > > + mutex_unlock(&otg_list_mutex); > > > + > > > + /* were we in wait list? */ > > > + mutex_lock(&wait_list_mutex); > > > + wait = usb_otg_get_wait(dev); > > > + mutex_unlock(&wait_list_mutex); > > > + if (wait) { > > > + /* register pending host/gadget and flush from list */ > > > + usb_otg_flush_wait(dev); > > > + } > > > + > > > + return otg; > > > + > > > +err_wq: > > > + kfree(otg); > > > +unlock: > > > + mutex_unlock(&otg_list_mutex); > > > + return ERR_PTR(ret); > > > +} > > > +EXPORT_SYMBOL_GPL(usb_otg_register); > > > + > > > > -- > > 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 > > -- > Best Regards, > Peter Chen