usb: gadget: composite: conditionally dequeue os_desc and setup requests
authorFelipe Balbi <balbi@ti.com>
Thu, 18 Sep 2014 15:01:55 +0000 (10:01 -0500)
committerFelipe Balbi <balbi@ti.com>
Mon, 3 Nov 2014 16:00:55 +0000 (10:00 -0600)
commita7c12eaf2e5eea0c15242ebb7d1d3b6e7fcb62bb
treeff1b347072f71f29f42f717e842cff50dff26127
parent57943716ff1b0733ab0d9879e572bad04166660a
usb: gadget: composite: conditionally dequeue os_desc and setup requests

In case we unload a gadget driver while any of
os_desc_req or req are still pending, we need
to make sure to dequeue them.

By using our setup_pending and os_desc_pending
flags we achieve that in a way that doesn't
cause any regressions because we won't dequeue
a request which was already completed.

The original idea came from Li Jun's commit
f2267089ea17fa97b796b1b4247e3f8957655df3
(usb: gadget: composite: dequeue cdev->req
before free it in composite_dev_cleanup) which,
unfortunately, caused two regressions (kfree()
being called before usb_ep_dequeue() and calling
usb_ep_dequeue() when the request was already
completed). That commit also didn't take care
of os_desc_req which can fall into the same
situation so we must care for that one too.

Note that in order to make code slightly easier
to read, we introduce composite_ep_queue() which
hides details about how to fiddle with our pending
flags.

Signed-off-by: Felipe Balbi <balbi@ti.com>
drivers/usb/gadget/composite.c