]> git.baikalelectronics.ru Git - kernel.git/commit
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)
commita51688688f8abb96faff577bff9cee4cbe99d0c4
treeff1b347072f71f29f42f717e842cff50dff26127
parentba54309099e2ecd6c05dcba5e9d43638a9bbd8f0
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
c6876fdecb10863a12da8e47bb92993c1e304806
(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