From 147ca8205dca7605bb8ac18ffbafdaa28495e656 Mon Sep 17 00:00:00 2001 From: Chandana Kishori Chiluveru Date: Tue, 11 Jun 2019 12:38:42 +0530 Subject: [PATCH] USB: configfs: Send DISCONNECT uevent during UDC bind commit ("USB: configfs: Don't send DISCONNECT uevent during unbind") removed sending disconnect uevent from unbind path. In normal disconnect path kernel will notify the disconnect event from dwc3_disconnect_gadget() function. If their is a race between composition switch and cable disconnect dwc gadget pointers may become null from composition unbind rules and then we end up not sending any disconnect notification to usespace and status remains in usb connected state in usb preferences screen. Hence fix this issue by scheduling android work from bind path which will send disconnect event to userspace. Change-Id: Ic53d8d9f6e5ae19d28bb1c23722a62a38f80ec08 Signed-off-by: Chandana Kishori Chiluveru --- drivers/usb/gadget/configfs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c index e4cb53b136a5..68f4137e0aaa 100644 --- a/drivers/usb/gadget/configfs.c +++ b/drivers/usb/gadget/configfs.c @@ -323,6 +323,9 @@ static ssize_t gadget_dev_desc_UDC_store(struct config_item *item, gi->composite.gadget_driver.udc_name = NULL; goto err; } +#ifdef CONFIG_USB_CONFIGFS_UEVENT + schedule_work(&gi->work); +#endif } mutex_unlock(&gi->lock); return len;