[PATCH v2 4/7] usb: chipidea: create the gadget at ci_hdrc_probe even at host role

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Since we can't load/unload gadget module on the fly, we can't
de-init gadget structure during the otg switch.
We have to create gadget at the probe function no matter current
role is the host or device, of cource, the gadget will not
be created for host-only port.

Signed-off-by: Peter Chen <peter.chen@xxxxxxxxxxxxx>
---
 drivers/usb/chipidea/ci.h   |   10 +++++++---
 drivers/usb/chipidea/core.c |    7 ++++++-
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
index d32f932..c704aa7 100644
--- a/drivers/usb/chipidea/ci.h
+++ b/drivers/usb/chipidea/ci.h
@@ -188,9 +188,13 @@ static inline int ci_role_start(struct ci13xxx *ci, enum ci_role role)
 	if (!ci->roles[role])
 		return -ENXIO;
 
-	ret = ci->roles[role]->start(ci);
-	if (!ret)
-		ci->role = role;
+	/* Only host role is supported at this function*/
+	if (role == CI_ROLE_HOST) {
+		ret = ci->roles[role]->start(ci);
+		if (!ret)
+			ci->role = role;
+	}
+
 	return ret;
 }
 
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 87544ad..ec73993 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -590,7 +590,9 @@ static int __devinit ci_hdrc_probe(struct platform_device *pdev)
 
 	ret = ci_hdrc_gadget_init(ci);
 	if (ret)
-		dev_info(dev, "doesn't support gadget\n");
+		dev_info(dev,
+			"doesn't support gadget or its start fails: %d\n",
+			ret);
 
 	if (!ci->roles[CI_ROLE_HOST] && !ci->roles[CI_ROLE_GADGET]) {
 		dev_err(dev, "no supported roles\n");
@@ -614,6 +616,9 @@ static int __devinit ci_hdrc_probe(struct platform_device *pdev)
 		/* if otg is supported, create struct usb_otg */
 		ci_hdrc_otg_init(ci);
 
+	if (ci->roles[CI_ROLE_GADGET])
+		ci->roles[CI_ROLE_GADGET]->start(ci);
+
 	ret = ci_role_start(ci, ci->role);
 	if (ret) {
 		dev_err(dev, "can't start %s role, ret=%d\n",
-- 
1.7.0.4


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux