usb: gadget: Fix f_rmnet to maintain notifications after set_alt

This change fixes a corner case, in which two set_alt are being
called. When the second set_alt is called, the notification EP is
disabled, and the active notification is cancelled. But the actual
control packet is not dequeued from the response queue.
So in that case the control packet will not be sent to the host,
since it has no corresponding notification.

The solution is to re-add notification for every pending control
packet in the response queue.

CRs-Fixed: 361567
Change-Id: Id3a46de69556c98247e67fce8e5fd5c076088993
Signed-off-by: Amit Blay <ablay@codeaurora.org>
diff --git a/drivers/usb/gadget/f_rmnet.c b/drivers/usb/gadget/f_rmnet.c
index 53a6398..414a7b9 100644
--- a/drivers/usb/gadget/f_rmnet.c
+++ b/drivers/usb/gadget/f_rmnet.c
@@ -164,6 +164,8 @@
 	NULL,
 };
 
+static void frmnet_ctrl_response_available(struct f_rmnet *dev);
+
 /* ------- misc functions --------------------*/
 
 static inline struct f_rmnet *func_to_rmnet(struct usb_function *f)
@@ -554,6 +556,7 @@
 	struct f_rmnet			*dev = func_to_rmnet(f);
 	struct usb_composite_dev	*cdev = dev->cdev;
 	int				ret;
+	struct list_head *cpkt;
 
 	pr_debug("%s:dev:%p port#%d\n", __func__, dev, dev->port_num);
 
@@ -590,6 +593,11 @@
 
 	atomic_set(&dev->online, 1);
 
+	/* In case notifications were aborted, but there are pending control
+	   packets in the response queue, re-add the notifications */
+	list_for_each(cpkt, &dev->cpkt_resp_q)
+		frmnet_ctrl_response_available(dev);
+
 	return ret;
 }