#include "usbip_common.h"
#include "vhci.h"
-
/* get URB from transmitted urb queue. caller must hold vdev->priv_lock */
-struct urb *pickup_urb_and_free_priv(struct vhci_device *vdev,
- __u32 seqnum)
+struct urb *pickup_urb_and_free_priv(struct vhci_device *vdev, __u32 seqnum)
{
struct vhci_priv *priv, *tmp;
struct urb *urb = NULL;
status = urb->status;
usbip_dbg_vhci_rx("find urb %p vurb %p seqnum %u\n",
- urb, priv, seqnum);
+ urb, priv, seqnum);
/* TODO: fix logic here to improve indent situtation */
if (status != -EINPROGRESS) {
if (status == -ENOENT ||
- status == -ECONNRESET)
+ status == -ECONNRESET)
dev_info(&urb->dev->dev,
"urb %p was unlinked "
"%ssynchronuously.\n", urb,
}
static void vhci_recv_ret_submit(struct vhci_device *vdev,
- struct usbip_header *pdu)
+ struct usbip_header *pdu)
{
struct usbip_device *ud = &vdev->ud;
struct urb *urb;
spin_lock(&vdev->priv_lock);
-
urb = pickup_urb_and_free_priv(vdev, pdu->base.seqnum);
-
spin_unlock(&vdev->priv_lock);
if (!urb) {
usbip_uerr("cannot find a urb of seqnum %u\n",
- pdu->base.seqnum);
+ pdu->base.seqnum);
usbip_uinfo("max seqnum %d\n",
- atomic_read(&the_controller->seqnum));
+ atomic_read(&the_controller->seqnum));
usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
return;
}
-
/* unpack the pdu to a urb */
usbip_pack_pdu(pdu, urb, USBIP_RET_SUBMIT, 0);
-
/* recv transfer buffer */
if (usbip_recv_xbuff(ud, urb) < 0)
return;
-
/* recv iso_packet_descriptor */
if (usbip_recv_iso(ud, urb) < 0)
return;
if (usbip_dbg_flag_vhci_rx)
usbip_dump_urb(urb);
-
usbip_dbg_vhci_rx("now giveback urb %p\n", urb);
spin_lock(&the_controller->lock);
usb_hcd_giveback_urb(vhci_to_hcd(the_controller), urb, urb->status);
-
usbip_dbg_vhci_rx("Leave\n");
return;
}
-
static struct vhci_unlink *dequeue_pending_unlink(struct vhci_device *vdev,
- struct usbip_header *pdu)
+ struct usbip_header *pdu)
{
struct vhci_unlink *unlink, *tmp;
usbip_uinfo("unlink->seqnum %lu\n", unlink->seqnum);
if (unlink->seqnum == pdu->base.seqnum) {
usbip_dbg_vhci_rx("found pending unlink, %lu\n",
- unlink->seqnum);
+ unlink->seqnum);
list_del(&unlink->list);
spin_unlock(&vdev->priv_lock);
return NULL;
}
-
static void vhci_recv_ret_unlink(struct vhci_device *vdev,
- struct usbip_header *pdu)
+ struct usbip_header *pdu)
{
struct vhci_unlink *unlink;
struct urb *urb;
unlink = dequeue_pending_unlink(vdev, pdu);
if (!unlink) {
usbip_uinfo("cannot find the pending unlink %u\n",
- pdu->base.seqnum);
+ pdu->base.seqnum);
return;
}
spin_lock(&vdev->priv_lock);
-
urb = pickup_urb_and_free_priv(vdev, unlink->unlink_seqnum);
-
spin_unlock(&vdev->priv_lock);
if (!urb) {
* back the URB.
*/
usbip_uinfo("the urb (seqnum %d) was already given backed\n",
- pdu->base.seqnum);
+ pdu->base.seqnum);
} else {
usbip_dbg_vhci_rx("now giveback urb %p\n", urb);
spin_unlock(&the_controller->lock);
usb_hcd_giveback_urb(vhci_to_hcd(the_controller), urb,
- urb->status);
+ urb->status);
}
kfree(unlink);
int empty = 0;
spin_lock(&vdev->priv_lock);
-
empty = list_empty(&vdev->priv_rx);
-
spin_unlock(&vdev->priv_lock);
return empty;
struct usbip_header pdu;
struct vhci_device *vdev = container_of(ud, struct vhci_device, ud);
-
usbip_dbg_vhci_rx("Enter\n");
memset(&pdu, 0, sizeof(pdu));
}
if (ret != sizeof(pdu)) {
usbip_uerr("received pdu size is %d, should be %d\n",
- ret, (unsigned int)sizeof(pdu));
+ ret, (unsigned int)sizeof(pdu));
usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
return;
}
}
}
-
/*-------------------------------------------------------------------------*/
int vhci_rx_loop(void *data)
{
struct usbip_device *ud = data;
-
while (!kthread_should_stop()) {
if (usbip_event_happened(ud))
break;