USB: android: Fix adb device file closing bug

adb device file closing and config disabling can happen in
parallel during composition switch.  If adb device file
is closed prior to config disable, adb function driver request
android to disable configuration.  But this is not undone later
when adb device file is opened.  Due to this bug config remains
disabled after composition switch completion.  Fix this bug.

CRs-Fixed: 414360

Change-Id: Ia7b352c63d860028c02b8dd7a52522460557e6fd
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
Signed-off-by: Neha Pandey <nehap@codeaurora.org>
diff --git a/drivers/usb/gadget/f_adb.c b/drivers/usb/gadget/f_adb.c
index 7aebc06..9d7eb33 100644
--- a/drivers/usb/gadget/f_adb.c
+++ b/drivers/usb/gadget/f_adb.c
@@ -56,6 +56,7 @@
 	struct usb_request *rx_req;
 	int rx_done;
 	bool notify_close;
+	bool close_notified;
 };
 
 static struct usb_interface_descriptor adb_interface_desc = {
@@ -424,8 +425,10 @@
 	/* clear the error latch */
 	atomic_set(&_adb_dev->error, 0);
 
-	if (_adb_dev->notify_close)
+	if (_adb_dev->close_notified) {
+		_adb_dev->close_notified = false;
 		adb_ready_callback();
+	}
 
 	_adb_dev->notify_close = true;
 	return 0;
@@ -443,8 +446,10 @@
 	 * undesired.  We want to force bus reset only for certain
 	 * commands like "adb root" and "adb usb".
 	 */
-	if (_adb_dev->notify_close)
+	if (_adb_dev->notify_close) {
 		adb_closed_callback();
+		_adb_dev->close_notified = true;
+	}
 
 	adb_unlock(&_adb_dev->open_excl);
 	return 0;
@@ -625,7 +630,9 @@
 	atomic_set(&dev->open_excl, 0);
 	atomic_set(&dev->read_excl, 0);
 	atomic_set(&dev->write_excl, 0);
-	dev->notify_close = true;
+
+	/* config is disabled by default if adb is present. */
+	dev->close_notified = true;
 
 	INIT_LIST_HEAD(&dev->tx_idle);