From: Lu Baolu <baolu...@linux.intel.com>

Use list_is_singular() to check if cmd_list has only one entry.

[use list_empty() in queue command instead -Mathias]
Signed-off-by: Lu Baolu <baolu...@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.ny...@linux.intel.com>
---
 drivers/usb/host/xhci-ring.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 2374a13..b11f479 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -1425,7 +1425,7 @@ static void handle_cmd_completion(struct xhci_hcd *xhci,
        }
 
        /* restart timer if this wasn't the last command */
-       if (cmd->cmd_list.next != &xhci->cmd_list) {
+       if (!list_is_singular(&xhci->cmd_list)) {
                xhci->current_cmd = list_entry(cmd->cmd_list.next,
                                               struct xhci_command, cmd_list);
                xhci_mod_cmd_timer(xhci, XHCI_CMD_DEFAULT_TIMEOUT);
@@ -3802,14 +3802,15 @@ static int queue_command(struct xhci_hcd *xhci, struct 
xhci_command *cmd,
        }
 
        cmd->command_trb = xhci->cmd_ring->enqueue;
-       list_add_tail(&cmd->cmd_list, &xhci->cmd_list);
 
        /* if there are no other commands queued we start the timeout timer */
-       if (xhci->cmd_list.next == &cmd->cmd_list) {
+       if (list_empty(&xhci->cmd_list)) {
                xhci->current_cmd = cmd;
                xhci_mod_cmd_timer(xhci, XHCI_CMD_DEFAULT_TIMEOUT);
        }
 
+       list_add_tail(&cmd->cmd_list, &xhci->cmd_list);
+
        queue_trb(xhci, xhci->cmd_ring, false, field1, field2, field3,
                        field4 | xhci->cmd_ring->cycle_state);
        return 0;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to