xhci: Move allocating of command for new_dequeue_state to queue_set_tr_deq()
authorHans de Goede <hdegoede@redhat.com>
Wed, 20 Aug 2014 13:41:52 +0000 (16:41 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 24 Sep 2014 04:46:10 +0000 (21:46 -0700)
commit1e3452e3f08c5af7fb4b08551aaa96b6627c7416
tree2908d29ee0bae8e47385d5f86a12c42874826b4d
parentfac1f48584c1b6c745412cf8c5dbdc1725aad8f2
xhci: Move allocating of command for new_dequeue_state to queue_set_tr_deq()

There are multiple reasons for this:

1) This fixes a missing check for xhci_alloc_command failing in
   xhci_handle_cmd_stop_ep()
2) This adds a warning when we cannot set the new dequeue state because of
   xhci_alloc_command failing
3) It puts the allocation of the command after the sanity checks in
   queue_set_tr_deq(), avoiding leaking the command if those fail
4) Since queue_set_tr_deq now owns the command it can free it if queue_command
   fails
5) It reduces code duplication

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/host/xhci-ring.c
drivers/usb/host/xhci.c
drivers/usb/host/xhci.h