USB: android: Wakeup both reader and writer processes upon TX/RX error

The writer process is blocked on a wait queue if there are no free
TX requests.  It is unblocked from TX completion handler. When error
is encountered on RX path, wakeup the writer thread.  If the host
stops reading the data after RX errors, the writer process will never
be unblocked.  Similarly wakeup reader process when error is encountered
on TX path.

(cherry picked from commit e8757ca19d3f2230af507fc44262f9c92af37b59)

CRs-Fixed: 449129
Change-Id: I4fa133d293c96b629d1506a0054b048e9551abd1
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
diff --git a/drivers/usb/gadget/f_adb.c b/drivers/usb/gadget/f_adb.c
index 9d7eb33..dabb673 100644
--- a/drivers/usb/gadget/f_adb.c
+++ b/drivers/usb/gadget/f_adb.c
@@ -316,7 +316,8 @@
 	}
 
 	/* wait for a request to complete */
-	ret = wait_event_interruptible(dev->read_wq, dev->rx_done);
+	ret = wait_event_interruptible(dev->read_wq, dev->rx_done ||
+				atomic_read(&dev->error));
 	if (ret < 0) {
 		if (ret != -ERESTARTSYS)
 		atomic_set(&dev->error, 1);
@@ -338,6 +339,9 @@
 		r = -EIO;
 
 done:
+	if (atomic_read(&dev->error))
+		wake_up(&dev->write_wq);
+
 	adb_unlock(&dev->read_excl);
 	pr_debug("adb_read returning %d\n", r);
 	return r;
@@ -406,6 +410,9 @@
 	if (req)
 		adb_req_put(dev, &dev->tx_idle, req);
 
+	if (atomic_read(&dev->error))
+		wake_up(&dev->read_wq);
+
 	adb_unlock(&dev->write_excl);
 	pr_debug("adb_write returning %d\n", r);
 	return r;