diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2009-09-22 19:54:53 (GMT) |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2009-09-22 20:01:40 (GMT) |
commit | ae19ffbadc1b2100285a5b5b3d0a4e0a11390904 (patch) | |
tree | 3c2086ab67398a019089a47ca3f362a4bc6db74f /drivers/staging/usbip/vhci_hcd.c | |
parent | 34e84f39a27d059a3e6ec6e8b94aafa702e6f220 (diff) | |
parent | 9173a8ef24a6b1b8031507b35b8ffe5f85a87692 (diff) | |
download | linux-fsl-qoriq-ae19ffbadc1b2100285a5b5b3d0a4e0a11390904.tar.xz |
Merge branch 'master' into for-linus
Diffstat (limited to 'drivers/staging/usbip/vhci_hcd.c')
-rw-r--r-- | drivers/staging/usbip/vhci_hcd.c | 156 |
1 files changed, 84 insertions, 72 deletions
diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c index f69ca34..6e91fc2 100644 --- a/drivers/staging/usbip/vhci_hcd.c +++ b/drivers/staging/usbip/vhci_hcd.c @@ -115,7 +115,7 @@ void rh_port_connect(int rhport, enum usb_device_speed speed) { unsigned long flags; - dbg_vhci_rh("rh_port_connect %d\n", rhport); + usbip_dbg_vhci_rh("rh_port_connect %d\n", rhport); spin_lock_irqsave(&the_controller->lock, flags); @@ -148,7 +148,7 @@ void rh_port_disconnect(int rhport) { unsigned long flags; - dbg_vhci_rh("rh_port_disconnect %d\n", rhport); + usbip_dbg_vhci_rh("rh_port_disconnect %d\n", rhport); spin_lock_irqsave(&the_controller->lock, flags); /* stop_activity(dum, driver); */ @@ -215,7 +215,7 @@ static int vhci_hub_status(struct usb_hcd *hcd, char *buf) spin_lock_irqsave(&vhci->lock, flags); if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) { - dbg_vhci_rh("hw accessible flag in on?\n"); + usbip_dbg_vhci_rh("hw accessible flag in on?\n"); goto done; } @@ -223,14 +223,14 @@ static int vhci_hub_status(struct usb_hcd *hcd, char *buf) for (rhport = 0; rhport < VHCI_NPORTS; rhport++) { if ((vhci->port_status[rhport] & PORT_C_MASK)) { /* The status of a port has been changed, */ - dbg_vhci_rh("port %d is changed\n", rhport); + usbip_dbg_vhci_rh("port %d is changed\n", rhport); *event_bits |= 1 << (rhport + 1); changed = 1; } } - uinfo("changed %d\n", changed); + usbip_uinfo("changed %d\n", changed); if (hcd->state == HC_STATE_SUSPENDED) usb_hcd_resume_root_hub(hcd); @@ -275,10 +275,11 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, * NOTE: * wIndex shows the port number and begins from 1. */ - dbg_vhci_rh("typeReq %x wValue %x wIndex %x\n", typeReq, wValue, + usbip_dbg_vhci_rh("typeReq %x wValue %x wIndex %x\n", typeReq, wValue, wIndex); if (wIndex > VHCI_NPORTS) - printk(KERN_ERR "%s: invalid port number %d\n", __func__, wIndex); + printk(KERN_ERR "%s: invalid port number %d\n", __func__, + wIndex); rhport = ((__u8)(wIndex & 0x00ff)) - 1; dum = hcd_to_vhci(hcd); @@ -286,7 +287,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, spin_lock_irqsave(&dum->lock, flags); /* store old status and compare now and old later */ - if (dbg_flag_vhci_rh) { + if (usbip_dbg_flag_vhci_rh) { int i = 0; for (i = 0; i < VHCI_NPORTS; i++) prev_port_status[i] = dum->port_status[i]; @@ -294,7 +295,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, switch (typeReq) { case ClearHubFeature: - dbg_vhci_rh(" ClearHubFeature\n"); + usbip_dbg_vhci_rh(" ClearHubFeature\n"); break; case ClearPortFeature: switch (wValue) { @@ -307,15 +308,16 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, } break; case USB_PORT_FEAT_POWER: - dbg_vhci_rh(" ClearPortFeature: USB_PORT_FEAT_POWER\n"); + usbip_dbg_vhci_rh(" ClearPortFeature: " + "USB_PORT_FEAT_POWER\n"); dum->port_status[rhport] = 0; /* dum->address = 0; */ /* dum->hdev = 0; */ dum->resuming = 0; break; case USB_PORT_FEAT_C_RESET: - dbg_vhci_rh(" ClearPortFeature: " - "USB_PORT_FEAT_C_RESET\n"); + usbip_dbg_vhci_rh(" ClearPortFeature: " + "USB_PORT_FEAT_C_RESET\n"); switch (dum->vdev[rhport].speed) { case USB_SPEED_HIGH: dum->port_status[rhport] |= @@ -329,20 +331,21 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, break; } default: - dbg_vhci_rh(" ClearPortFeature: default %x\n", wValue); + usbip_dbg_vhci_rh(" ClearPortFeature: default %x\n", + wValue); dum->port_status[rhport] &= ~(1 << wValue); } break; case GetHubDescriptor: - dbg_vhci_rh(" GetHubDescriptor\n"); + usbip_dbg_vhci_rh(" GetHubDescriptor\n"); hub_descriptor((struct usb_hub_descriptor *) buf); break; case GetHubStatus: - dbg_vhci_rh(" GetHubStatus\n"); + usbip_dbg_vhci_rh(" GetHubStatus\n"); *(__le32 *) buf = __constant_cpu_to_le32(0); break; case GetPortStatus: - dbg_vhci_rh(" GetPortStatus port %x\n", wIndex); + usbip_dbg_vhci_rh(" GetPortStatus port %x\n", wIndex); if (wIndex > VHCI_NPORTS || wIndex < 1) { printk(KERN_ERR "%s: invalid port number %d\n", __func__, wIndex); @@ -379,7 +382,8 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, if (dum->vdev[rhport].ud.status == VDEV_ST_NOTASSIGNED) { - dbg_vhci_rh(" enable rhport %d (status %u)\n", + usbip_dbg_vhci_rh(" enable rhport %d " + "(status %u)\n", rhport, dum->vdev[rhport].ud.status); dum->port_status[rhport] |= @@ -415,17 +419,17 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, ((u16 *) buf)[1] = cpu_to_le16(dum->port_status[rhport] >> 16); - dbg_vhci_rh(" GetPortStatus bye %x %x\n", ((u16 *)buf)[0], + usbip_dbg_vhci_rh(" GetPortStatus bye %x %x\n", ((u16 *)buf)[0], ((u16 *)buf)[1]); break; case SetHubFeature: - dbg_vhci_rh(" SetHubFeature\n"); + usbip_dbg_vhci_rh(" SetHubFeature\n"); retval = -EPIPE; break; case SetPortFeature: switch (wValue) { case USB_PORT_FEAT_SUSPEND: - dbg_vhci_rh(" SetPortFeature: " + usbip_dbg_vhci_rh(" SetPortFeature: " "USB_PORT_FEAT_SUSPEND\n"); printk(KERN_ERR "%s: not yet\n", __func__); #if 0 @@ -439,7 +443,8 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, #endif break; case USB_PORT_FEAT_RESET: - dbg_vhci_rh(" SetPortFeature: USB_PORT_FEAT_RESET\n"); + usbip_dbg_vhci_rh(" SetPortFeature: " + "USB_PORT_FEAT_RESET\n"); /* if it's already running, disconnect first */ if (dum->port_status[rhport] & USB_PORT_STAT_ENABLE) { dum->port_status[rhport] &= @@ -460,7 +465,8 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, /* FALLTHROUGH */ default: - dbg_vhci_rh(" SetPortFeature: default %d\n", wValue); + usbip_dbg_vhci_rh(" SetPortFeature: default %d\n", + wValue); dum->port_status[rhport] |= (1 << wValue); } break; @@ -475,12 +481,12 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, retval = -EPIPE; } - if (dbg_flag_vhci_rh) { + if (usbip_dbg_flag_vhci_rh) { printk(KERN_DEBUG "port %d\n", rhport); dump_port_status(prev_port_status[rhport]); dump_port_status(dum->port_status[rhport]); } - dbg_vhci_rh(" bye\n"); + usbip_dbg_vhci_rh(" bye\n"); spin_unlock_irqrestore(&dum->lock, flags); @@ -517,9 +523,10 @@ static void vhci_tx_urb(struct urb *urb) return; } + priv = kzalloc(sizeof(struct vhci_priv), GFP_ATOMIC); + spin_lock_irqsave(&vdev->priv_lock, flag); - priv = kzalloc(sizeof(struct vhci_priv), GFP_ATOMIC); if (!priv) { dev_err(&urb->dev->dev, "malloc vhci_priv\n"); spin_unlock_irqrestore(&vdev->priv_lock, flag); @@ -529,7 +536,7 @@ static void vhci_tx_urb(struct urb *urb) priv->seqnum = atomic_inc_return(&the_controller->seqnum); if (priv->seqnum == 0xffff) - uinfo("seqnum max\n"); + usbip_uinfo("seqnum max\n"); priv->vdev = vdev; priv->urb = urb; @@ -550,7 +557,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, int ret = 0; unsigned long flags; - dbg_vhci_hc("enter, usb_hcd %p urb %p mem_flags %d\n", + usbip_dbg_vhci_hc("enter, usb_hcd %p urb %p mem_flags %d\n", hcd, urb, mem_flags); /* patch to usb_sg_init() is in 2.5.60 */ @@ -558,13 +565,6 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, spin_lock_irqsave(&the_controller->lock, flags); - /* check HC is active or not */ - if (!HC_IS_RUNNING(hcd->state)) { - dev_err(dev, "HC is not running\n"); - spin_unlock_irqrestore(&the_controller->lock, flags); - return -ENODEV; - } - if (urb->status != -EINPROGRESS) { dev_err(dev, "URB already unlinked!, status %d\n", urb->status); spin_unlock_irqrestore(&the_controller->lock, flags); @@ -576,7 +576,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, goto no_need_unlink; /* - * The enumelation process is as follows; + * The enumeration process is as follows; * * 1. Get_Descriptor request to DevAddrs(0) EndPoint(0) * to get max packet length of default pipe @@ -594,7 +594,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, if (type != PIPE_CONTROL || !ctrlreq) { dev_err(dev, "invalid request to devnum 0\n"); - ret = EINVAL; + ret = -EINVAL; goto no_need_xmit; } @@ -620,7 +620,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, case USB_REQ_GET_DESCRIPTOR: if (ctrlreq->wValue == (USB_DT_DEVICE << 8)) - dbg_vhci_hc("Not yet?: " + usbip_dbg_vhci_hc("Not yet?: " "Get_Descriptor to device 0 " "(get max pipe size)\n"); @@ -653,7 +653,7 @@ no_need_unlink: usb_hcd_giveback_urb(vhci_to_hcd(the_controller), urb, urb->status); - return 0; + return ret; } /* @@ -708,7 +708,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) struct vhci_priv *priv; struct vhci_device *vdev; - uinfo("vhci_hcd: dequeue a urb %p\n", urb); + usbip_uinfo("vhci_hcd: dequeue a urb %p\n", urb); spin_lock_irqsave(&the_controller->lock, flags); @@ -726,7 +726,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) ret = usb_hcd_check_unlink_urb(hcd, urb, status); if (ret) { spin_unlock_irqrestore(&the_controller->lock, flags); - return 0; + return ret; } } @@ -739,13 +739,29 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) spin_lock_irqsave(&vdev->priv_lock, flags2); - uinfo("vhci_hcd: device %p seems to be disconnected\n", vdev); + usbip_uinfo("vhci_hcd: device %p seems to be disconnected\n", + vdev); list_del(&priv->list); kfree(priv); urb->hcpriv = NULL; spin_unlock_irqrestore(&vdev->priv_lock, flags2); + /* + * If tcp connection is alive, we have sent CMD_UNLINK. + * vhci_rx will receive RET_UNLINK and give back the URB. + * Otherwise, we give back it here. + */ + usbip_uinfo("vhci_hcd: vhci_urb_dequeue() gives back urb %p\n", + urb); + + usb_hcd_unlink_urb_from_ep(hcd, urb); + + spin_unlock_irqrestore(&the_controller->lock, flags); + usb_hcd_giveback_urb(vhci_to_hcd(the_controller), urb, + urb->status); + spin_lock_irqsave(&the_controller->lock, flags); + } else { /* tcp connection is alive */ unsigned long flags2; @@ -756,7 +772,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) /* setup CMD_UNLINK pdu */ unlink = kzalloc(sizeof(struct vhci_unlink), GFP_ATOMIC); if (!unlink) { - uerr("malloc vhci_unlink\n"); + usbip_uerr("malloc vhci_unlink\n"); spin_unlock_irqrestore(&vdev->priv_lock, flags2); spin_unlock_irqrestore(&the_controller->lock, flags); usbip_event_add(&vdev->ud, VDEV_EVENT_ERROR_MALLOC); @@ -765,11 +781,11 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) unlink->seqnum = atomic_inc_return(&the_controller->seqnum); if (unlink->seqnum == 0xffff) - uinfo("seqnum max\n"); + usbip_uinfo("seqnum max\n"); unlink->unlink_seqnum = priv->seqnum; - uinfo("vhci_hcd: device %p seems to be still connected\n", + usbip_uinfo("vhci_hcd: device %p seems to be still connected\n", vdev); /* send cmd_unlink and try to cancel the pending URB in the @@ -781,14 +797,10 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) } - /* - * If tcp connection is alive, we have sent CMD_UNLINK. - * vhci_rx will receive RET_UNLINK and give back the URB. - * Otherwise, we give back it here. - */ if (!vdev->ud.tcp_socket) { /* tcp connection is closed */ - uinfo("vhci_hcd: vhci_urb_dequeue() gives back urb %p\n", urb); + usbip_uinfo("vhci_hcd: vhci_urb_dequeue() gives back urb %p\n", + urb); usb_hcd_unlink_urb_from_ep(hcd, urb); @@ -800,7 +812,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) spin_unlock_irqrestore(&the_controller->lock, flags); - dbg_vhci_hc("leave\n"); + usbip_dbg_vhci_hc("leave\n"); return 0; } @@ -835,19 +847,19 @@ static void vhci_shutdown_connection(struct usbip_device *ud) /* need this? see stub_dev.c */ if (ud->tcp_socket) { - udbg("shutdown tcp_socket %p\n", ud->tcp_socket); + usbip_udbg("shutdown tcp_socket %p\n", ud->tcp_socket); kernel_sock_shutdown(ud->tcp_socket, SHUT_RDWR); } usbip_stop_threads(&vdev->ud); - uinfo("stop threads\n"); + usbip_uinfo("stop threads\n"); /* active connection is closed */ if (vdev->ud.tcp_socket != NULL) { sock_release(vdev->ud.tcp_socket); vdev->ud.tcp_socket = NULL; } - uinfo("release socket\n"); + usbip_uinfo("release socket\n"); vhci_device_unlink_cleanup(vdev); @@ -873,7 +885,7 @@ static void vhci_shutdown_connection(struct usbip_device *ud) */ rh_port_disconnect(vdev->rhport); - uinfo("disconnect device\n"); + usbip_uinfo("disconnect device\n"); } @@ -939,7 +951,7 @@ static int vhci_start(struct usb_hcd *hcd) int rhport; int err = 0; - dbg_vhci_hc("enter vhci_start\n"); + usbip_dbg_vhci_hc("enter vhci_start\n"); /* initialize private data of usb_hcd */ @@ -963,7 +975,7 @@ static int vhci_start(struct usb_hcd *hcd) /* vhci_hcd is now ready to be controlled through sysfs */ err = sysfs_create_group(&vhci_dev(vhci)->kobj, &dev_attr_group); if (err) { - uerr("create sysfs files\n"); + usbip_uerr("create sysfs files\n"); return err; } @@ -975,7 +987,7 @@ static void vhci_stop(struct usb_hcd *hcd) struct vhci_hcd *vhci = hcd_to_vhci(hcd); int rhport = 0; - dbg_vhci_hc("stop VHCI controller\n"); + usbip_dbg_vhci_hc("stop VHCI controller\n"); /* 1. remove the userland interface of vhci_hcd */ @@ -990,14 +1002,14 @@ static void vhci_stop(struct usb_hcd *hcd) } - uinfo("vhci_stop done\n"); + usbip_uinfo("vhci_stop done\n"); } /*----------------------------------------------------------------------*/ static int vhci_get_frame_number(struct usb_hcd *hcd) { - uerr("Not yet implemented\n"); + usbip_uerr("Not yet implemented\n"); return 0; } @@ -1077,9 +1089,9 @@ static int vhci_hcd_probe(struct platform_device *pdev) struct usb_hcd *hcd; int ret; - uinfo("proving...\n"); + usbip_uinfo("proving...\n"); - dbg_vhci_hc("name %s id %d\n", pdev->name, pdev->id); + usbip_dbg_vhci_hc("name %s id %d\n", pdev->name, pdev->id); /* will be removed */ if (pdev->dev.dma_mask) { @@ -1093,7 +1105,7 @@ static int vhci_hcd_probe(struct platform_device *pdev) */ hcd = usb_create_hcd(&vhci_hc_driver, &pdev->dev, dev_name(&pdev->dev)); if (!hcd) { - uerr("create hcd failed\n"); + usbip_uerr("create hcd failed\n"); return -ENOMEM; } @@ -1107,14 +1119,14 @@ static int vhci_hcd_probe(struct platform_device *pdev) */ ret = usb_add_hcd(hcd, 0, 0); if (ret != 0) { - uerr("usb_add_hcd failed %d\n", ret); + usbip_uerr("usb_add_hcd failed %d\n", ret); usb_put_hcd(hcd); the_controller = NULL; return ret; } - dbg_vhci_hc("bye\n"); + usbip_dbg_vhci_hc("bye\n"); return 0; } @@ -1166,11 +1178,11 @@ static int vhci_hcd_suspend(struct platform_device *pdev, pm_message_t state) spin_unlock(&the_controller->lock); if (connected > 0) { - uinfo("We have %d active connection%s. Do not suspend.\n", + usbip_uinfo("We have %d active connection%s. Do not suspend.\n", connected, (connected == 1 ? "" : "s")); ret = -EBUSY; } else { - uinfo("suspend vhci_hcd"); + usbip_uinfo("suspend vhci_hcd"); clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); } @@ -1235,7 +1247,7 @@ static int __init vhci_init(void) { int ret; - dbg_vhci_hc("enter\n"); + usbip_dbg_vhci_hc("enter\n"); if (usb_disabled()) return -ENODEV; @@ -1250,7 +1262,7 @@ static int __init vhci_init(void) if (ret < 0) goto err_platform_device_register; - dbg_vhci_hc("bye\n"); + usbip_dbg_vhci_hc("bye\n"); return ret; /* error occurred */ @@ -1258,18 +1270,18 @@ err_platform_device_register: platform_driver_unregister(&vhci_driver); err_driver_register: - dbg_vhci_hc("bye\n"); + usbip_dbg_vhci_hc("bye\n"); return ret; } module_init(vhci_init); static void __exit vhci_cleanup(void) { - dbg_vhci_hc("enter\n"); + usbip_dbg_vhci_hc("enter\n"); platform_device_unregister(&the_pdev); platform_driver_unregister(&vhci_driver); - dbg_vhci_hc("bye\n"); + usbip_dbg_vhci_hc("bye\n"); } module_exit(vhci_cleanup); |