Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1387126
| From | Peter Chen <hzpeterchen@gmail.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v6 07/12] usb: otg: add OTG/dual-role core |
| Date | 2016-04-26 05:50 +0200 |
| Message-ID | <rs2aB-HK-1@gated-at.bofh.it> (permalink) |
| References | <rkzQ5-4UX-1@gated-at.bofh.it> <rkzQ7-4UX-35@gated-at.bofh.it> <rs0BP-7Xv-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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.
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
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
RE: [PATCH v6 07/12] usb: otg: add OTG/dual-role core Jun Li <jun.li@nxp.com> - 2016-04-26 04:10 +0200
Re: [PATCH v6 07/12] usb: otg: add OTG/dual-role core Peter Chen <hzpeterchen@gmail.com> - 2016-04-26 05:50 +0200
RE: [PATCH v6 07/12] usb: otg: add OTG/dual-role core Jun Li <jun.li@nxp.com> - 2016-04-26 07:20 +0200
Re: [PATCH v6 07/12] usb: otg: add OTG/dual-role core Peter Chen <hzpeterchen@gmail.com> - 2016-04-26 08:30 +0200
RE: [PATCH v6 07/12] usb: otg: add OTG/dual-role core Jun Li <jun.li@nxp.com> - 2016-04-26 09:10 +0200
Re: [PATCH v6 07/12] usb: otg: add OTG/dual-role core Peter Chen <hzpeterchen@gmail.com> - 2016-04-26 10:30 +0200
Re: [PATCH v6 07/12] usb: otg: add OTG/dual-role core Peter Chen <hzpeterchen@gmail.com> - 2016-04-27 05:30 +0200
Re: [PATCH v6 07/12] usb: otg: add OTG/dual-role core Roger Quadros <rogerq@ti.com> - 2016-04-27 13:10 +0200
Re: [PATCH v6 07/12] usb: otg: add OTG/dual-role core Peter Chen <hzpeterchen@gmail.com> - 2016-04-28 04:10 +0200
Re: [PATCH v6 07/12] usb: otg: add OTG/dual-role core Roger Quadros <rogerq@ti.com> - 2016-04-28 10:10 +0200
Re: [PATCH v6 07/12] usb: otg: add OTG/dual-role core Roger Quadros <rogerq@ti.com> - 2016-04-27 13:20 +0200
csiph-web