We don't need to iterate over a list just to pull off the head. Signed-off-by: Bernard Blackham <b-linux...@largestprime.net> --- drivers/staging/usbip/vhci_tx.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/drivers/staging/usbip/vhci_tx.c b/drivers/staging/usbip/vhci_tx.c index 9b437e7..89c8cb2 100644 --- a/drivers/staging/usbip/vhci_tx.c +++ b/drivers/staging/usbip/vhci_tx.c @@ -47,19 +47,18 @@ static void setup_cmd_submit_pdu(struct usbip_header *pdup, struct urb *urb) static struct vhci_priv *dequeue_from_priv_tx(struct vhci_device *vdev) { unsigned long flags; - struct vhci_priv *priv, *tmp; + struct vhci_priv *priv = NULL; spin_lock_irqsave(&vdev->priv_lock, flags); - list_for_each_entry_safe(priv, tmp, &vdev->priv_tx, list) { + if (!list_empty(&vdev->priv_tx)) { + priv = list_first_entry(&vdev->priv_tx, struct vhci_priv, list); list_move_tail(&priv->list, &vdev->priv_rx); - spin_unlock_irqrestore(&vdev->priv_lock, flags); - return priv; } spin_unlock_irqrestore(&vdev->priv_lock, flags); - return NULL; + return priv; } static int vhci_send_cmd_submit(struct vhci_device *vdev) @@ -137,19 +136,19 @@ static int vhci_send_cmd_submit(struct vhci_device *vdev) static struct vhci_unlink *dequeue_from_unlink_tx(struct vhci_device *vdev) { unsigned long flags; - struct vhci_unlink *unlink, *tmp; + struct vhci_unlink *unlink = NULL; spin_lock_irqsave(&vdev->priv_lock, flags); - list_for_each_entry_safe(unlink, tmp, &vdev->unlink_tx, list) { + if (!list_empty(&vdev->unlink_tx)) { + unlink = list_first_entry(&vdev->unlink_tx, struct vhci_unlink, + list); list_move_tail(&unlink->list, &vdev->unlink_rx); - spin_unlock_irqrestore(&vdev->priv_lock, flags); - return unlink; } spin_unlock_irqrestore(&vdev->priv_lock, flags); - return NULL; + return unlink; } static int vhci_send_cmd_unlink(struct vhci_device *vdev) -- 1.7.10.4 -- 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