From 27edbe3583b4243a4638b67fd8a5686d08e1d50c Mon Sep 17 00:00:00 2001 From: Meng Dongyang Date: Wed, 28 Mar 2018 15:41:53 +0800 Subject: [PATCH] usb: gadget: configfs: send connect detective event when get descriptor In current code, the connect detective event will be send before the connect state of controller change. The event is sent when receive the first setup packet and the connect state of controller is changed when receive set address command. So if disconnect interrupt trigger between the first setup packet and set address command, the disconnect process will not be done, while the application state has been changed and keep in connected. As a result, the UI may still show the USB connect option event if the device has been disconnect from PC. This patch send the connect uevent when get descriptor of configuration which follow set address command to make sure the application state change after controller. Change-Id: Icf2124327db93687b4b644672edb0dbecc8f127a Signed-off-by: Meng Dongyang --- drivers/usb/gadget/configfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c index bccc2e0af58a..f58afe5b92ad 100644 --- a/drivers/usb/gadget/configfs.c +++ b/drivers/usb/gadget/configfs.c @@ -1489,7 +1489,8 @@ static int android_setup(struct usb_gadget *gadget, struct usb_function_instance *fi; spin_lock_irqsave(&cdev->lock, flags); - if (!gi->connected) { + if (c->bRequest == USB_REQ_GET_DESCRIPTOR && + (c->wValue >> 8) == USB_DT_CONFIG && !gi->connected) { gi->connected = 1; schedule_work(&gi->work); }