lkml.org 
[lkml]   [2015]   [Mar]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC][PATCH 6/9] usb: gadget: udc: adapt to OTG
Date
Register with OTG core as part of usb_add_gadget_udc_release()
and unregister from it in usb_del_gadget_udc().

In the OTG use case we may not yet be in "b_peripheral"
state so we shouldn't allow starting the UDC till
OTG core says so.

Signed-off-by: Roger Quadros <rogerq@ti.com>
---
drivers/usb/gadget/udc/udc-core.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/udc-core.c b/drivers/usb/gadget/udc/udc-core.c
index 69b4123..aad5173 100644
--- a/drivers/usb/gadget/udc/udc-core.c
+++ b/drivers/usb/gadget/udc/udc-core.c
@@ -28,6 +28,7 @@
#include <linux/usb/ch9.h>
#include <linux/usb/gadget.h>
#include <linux/usb.h>
+#include <linux/usb/usb-otg.h>

/**
* struct usb_udc - describes one usb device controller
@@ -237,6 +238,7 @@ static inline void usb_gadget_udc_stop(struct usb_udc *udc)
static int usb_udc_start(struct usb_udc *udc)
{
int ret;
+ bool otg_can_start;

if (udc->running) {
dev_err(&udc->dev, "%s: not starting as already running\n",
@@ -244,7 +246,8 @@ static int usb_udc_start(struct usb_udc *udc)
return -EBUSY;
}

- if (udc->driver && udc->softconnect) {
+ otg_can_start = usb_otg_gadget_can_start(udc->gadget);
+ if (otg_can_start && udc->driver && udc->softconnect) {
ret = usb_gadget_udc_start(udc);
if (ret)
return ret;
@@ -432,6 +435,8 @@ int usb_add_gadget_udc_release(struct device *parent, struct usb_gadget *gadget,

mutex_unlock(&udc_lock);

+ usb_otg_register_gadget(gadget);
+
return 0;

err4:
@@ -509,6 +514,7 @@ found:
if (udc->driver)
usb_gadget_remove_driver(udc);

+ usb_otg_unregister_gadget(gadget);
kobject_uevent(&udc->dev.kobj, KOBJ_REMOVE);
flush_work(&gadget->work);
device_unregister(&udc->dev);
--
2.1.0


\
 
 \ /
  Last update: 2015-03-18 15:01    [W:0.492 / U:21.828 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site