[PATCH 07/13] usb: gadget: composite: change pullup/pulldown dp strategy

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

 



- If the udc is ready to pullup dp and all functions at gadget driver
want to pullup dp, it will pullup dp.
- If the udc doesn't want to pullup dp or one of functions at gadget
driver doesn't want to pullup up. it will pull down dp.

Signed-off-by: Peter Chen <peter.chen@xxxxxxxxxxxxx>
---
 drivers/usb/gadget/composite.c |   17 ++++++++++++-----
 include/linux/usb/composite.h  |    3 +++
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index ada0905..770aa5e 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -310,7 +310,7 @@ int usb_function_activate(struct usb_function *function)
 		status = -EINVAL;
 	else {
 		cdev->deactivations--;
-		if (cdev->deactivations == 0)
+		if (cdev->deactivations == 0 && cdev->connect)
 			status = usb_gadget_connect(cdev->gadget);
 	}
 
@@ -2071,10 +2071,17 @@ composite_resume(struct usb_gadget *gadget)
  */
 int composite_connect(struct usb_gadget *gadget, bool connect)
 {
-	if (connect)
-		return usb_gadget_connect(gadget);
-	else
-		return usb_gadget_disconnect(gadget);
+	struct usb_composite_dev	*cdev = get_gadget_data(gadget);
+	int status = 0;
+
+	if (cdev->deactivations == 0 && connect)
+		status = usb_gadget_connect(gadget);
+	else if (!connect)
+		status = usb_gadget_disconnect(gadget);
+
+	cdev->connect = connect;
+
+	return status;
 }
 
 /*-------------------------------------------------------------------------*/
diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
index 820ca85..a9c7322 100644
--- a/include/linux/usb/composite.h
+++ b/include/linux/usb/composite.h
@@ -488,6 +488,9 @@ struct usb_composite_dev {
 
 	/* protects deactivations and delayed_status counts*/
 	spinlock_t			lock;
+
+	/* udc can accept pull dp or not  */
+	bool				connect;
 };
 
 extern int usb_string_id(struct usb_composite_dev *c);
-- 
1.7.9.5

--
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