Commit 071d1d47 authored by matt mooney's avatar matt mooney Committed by Greg Kroah-Hartman

staging: usbip: vhci_hcd.c: coding style cleanup

Fix alignment for consistency and remove extraneous lines.
Move MODULE_ macros to the end of file.
Make bit_desc[] an array of const pointers.
Add KERN_ level to a couple of printks.
Signed-off-by: default avatarmatt mooney <mfm@muteddisk.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent ddbc9bc9
...@@ -27,11 +27,6 @@ ...@@ -27,11 +27,6 @@
#define DRIVER_AUTHOR "Takahiro Hirofuchi" #define DRIVER_AUTHOR "Takahiro Hirofuchi"
#define DRIVER_DESC "Virtual Host Controller Interface Driver for USB/IP" #define DRIVER_DESC "Virtual Host Controller Interface Driver for USB/IP"
#define DRIVER_LICENCE "GPL" #define DRIVER_LICENCE "GPL"
MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_LICENSE(DRIVER_LICENCE);
/* /*
* TODO * TODO
...@@ -43,15 +38,13 @@ MODULE_LICENSE(DRIVER_LICENCE); ...@@ -43,15 +38,13 @@ MODULE_LICENSE(DRIVER_LICENCE);
* - clean up everything * - clean up everything
*/ */
/* See usb gadget dummy hcd */ /* See usb gadget dummy hcd */
static int vhci_hub_status(struct usb_hcd *hcd, char *buff); static int vhci_hub_status(struct usb_hcd *hcd, char *buff);
static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
u16 wIndex, char *buff, u16 wLength); u16 wIndex, char *buff, u16 wLength);
static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
gfp_t mem_flags); gfp_t mem_flags);
static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status); static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status);
static int vhci_start(struct usb_hcd *vhci_hcd); static int vhci_start(struct usb_hcd *vhci_hcd);
static void vhci_stop(struct usb_hcd *hcd); static void vhci_stop(struct usb_hcd *hcd);
...@@ -62,42 +55,41 @@ static const char driver_desc[] = "USB/IP Virtual Host Controller"; ...@@ -62,42 +55,41 @@ static const char driver_desc[] = "USB/IP Virtual Host Controller";
struct vhci_hcd *the_controller; struct vhci_hcd *the_controller;
static const char *bit_desc[] = { static const char * const bit_desc[] = {
"CONNECTION", /*0*/ "CONNECTION", /*0*/
"ENABLE", /*1*/ "ENABLE", /*1*/
"SUSPEND", /*2*/ "SUSPEND", /*2*/
"OVER_CURRENT", /*3*/ "OVER_CURRENT", /*3*/
"RESET", /*4*/ "RESET", /*4*/
"R5", /*5*/ "R5", /*5*/
"R6", /*6*/ "R6", /*6*/
"R7", /*7*/ "R7", /*7*/
"POWER", /*8*/ "POWER", /*8*/
"LOWSPEED", /*9*/ "LOWSPEED", /*9*/
"HIGHSPEED", /*10*/ "HIGHSPEED", /*10*/
"PORT_TEST", /*11*/ "PORT_TEST", /*11*/
"INDICATOR", /*12*/ "INDICATOR", /*12*/
"R13", /*13*/ "R13", /*13*/
"R14", /*14*/ "R14", /*14*/
"R15", /*15*/ "R15", /*15*/
"C_CONNECTION", /*16*/ "C_CONNECTION", /*16*/
"C_ENABLE", /*17*/ "C_ENABLE", /*17*/
"C_SUSPEND", /*18*/ "C_SUSPEND", /*18*/
"C_OVER_CURRENT", /*19*/ "C_OVER_CURRENT", /*19*/
"C_RESET", /*20*/ "C_RESET", /*20*/
"R21", /*21*/ "R21", /*21*/
"R22", /*22*/ "R22", /*22*/
"R23", /*23*/ "R23", /*23*/
"R24", /*24*/ "R24", /*24*/
"R25", /*25*/ "R25", /*25*/
"R26", /*26*/ "R26", /*26*/
"R27", /*27*/ "R27", /*27*/
"R28", /*28*/ "R28", /*28*/
"R29", /*29*/ "R29", /*29*/
"R30", /*30*/ "R30", /*30*/
"R31", /*31*/ "R31", /*31*/
}; };
static void dump_port_status(u32 status) static void dump_port_status(u32 status)
{ {
int i = 0; int i = 0;
...@@ -105,14 +97,11 @@ static void dump_port_status(u32 status) ...@@ -105,14 +97,11 @@ static void dump_port_status(u32 status)
printk(KERN_DEBUG "status %08x:", status); printk(KERN_DEBUG "status %08x:", status);
for (i = 0; i < 32; i++) { for (i = 0; i < 32; i++) {
if (status & (1 << i)) if (status & (1 << i))
printk(" %s", bit_desc[i]); printk(KERN_DEBUG " %s", bit_desc[i]);
} }
printk(KERN_DEBUG "\n");
printk("\n");
} }
void rh_port_connect(int rhport, enum usb_device_speed speed) void rh_port_connect(int rhport, enum usb_device_speed speed)
{ {
unsigned long flags; unsigned long flags;
...@@ -156,26 +145,22 @@ void rh_port_disconnect(int rhport) ...@@ -156,26 +145,22 @@ void rh_port_disconnect(int rhport)
the_controller->port_status[rhport] |= the_controller->port_status[rhport] |=
(1 << USB_PORT_FEAT_C_CONNECTION); (1 << USB_PORT_FEAT_C_CONNECTION);
/* not yet complete the disconnection /* not yet complete the disconnection
* spin_lock(&vdev->ud.lock); * spin_lock(&vdev->ud.lock);
* vdev->ud.status = VHC_ST_DISCONNECT; * vdev->ud.status = VHC_ST_DISCONNECT;
* spin_unlock(&vdev->ud.lock); */ * spin_unlock(&vdev->ud.lock); */
spin_unlock_irqrestore(&the_controller->lock, flags); spin_unlock_irqrestore(&the_controller->lock, flags);
usb_hcd_poll_rh_status(vhci_to_hcd(the_controller)); usb_hcd_poll_rh_status(vhci_to_hcd(the_controller));
} }
/*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/
#define PORT_C_MASK \ #define PORT_C_MASK \
((USB_PORT_STAT_C_CONNECTION \ ((USB_PORT_STAT_C_CONNECTION \
| USB_PORT_STAT_C_ENABLE \ | USB_PORT_STAT_C_ENABLE \
| USB_PORT_STAT_C_SUSPEND \ | USB_PORT_STAT_C_SUSPEND \
| USB_PORT_STAT_C_OVERCURRENT \ | USB_PORT_STAT_C_OVERCURRENT \
| USB_PORT_STAT_C_RESET) << 16) | USB_PORT_STAT_C_RESET) << 16)
/* /*
...@@ -210,7 +195,6 @@ static int vhci_hub_status(struct usb_hcd *hcd, char *buf) ...@@ -210,7 +195,6 @@ static int vhci_hub_status(struct usb_hcd *hcd, char *buf)
int rhport; int rhport;
int changed = 0; int changed = 0;
*event_bits = 0; *event_bits = 0;
vhci = hcd_to_vhci(hcd); vhci = hcd_to_vhci(hcd);
...@@ -278,10 +262,10 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, ...@@ -278,10 +262,10 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
* wIndex shows the port number and begins from 1. * wIndex shows the port number and begins from 1.
*/ */
usbip_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); wIndex);
if (wIndex > VHCI_NPORTS) if (wIndex > VHCI_NPORTS)
printk(KERN_ERR "%s: invalid port number %d\n", __func__, printk(KERN_ERR "%s: invalid port number %d\n", __func__,
wIndex); wIndex);
rhport = ((__u8)(wIndex & 0x00ff)) - 1; rhport = ((__u8)(wIndex & 0x00ff)) - 1;
dum = hcd_to_vhci(hcd); dum = hcd_to_vhci(hcd);
...@@ -311,7 +295,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, ...@@ -311,7 +295,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
break; break;
case USB_PORT_FEAT_POWER: case USB_PORT_FEAT_POWER:
usbip_dbg_vhci_rh(" ClearPortFeature: " usbip_dbg_vhci_rh(" ClearPortFeature: "
"USB_PORT_FEAT_POWER\n"); "USB_PORT_FEAT_POWER\n");
dum->port_status[rhport] = 0; dum->port_status[rhport] = 0;
/* dum->address = 0; */ /* dum->address = 0; */
/* dum->hdev = 0; */ /* dum->hdev = 0; */
...@@ -319,22 +303,22 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, ...@@ -319,22 +303,22 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
break; break;
case USB_PORT_FEAT_C_RESET: case USB_PORT_FEAT_C_RESET:
usbip_dbg_vhci_rh(" ClearPortFeature: " usbip_dbg_vhci_rh(" ClearPortFeature: "
"USB_PORT_FEAT_C_RESET\n"); "USB_PORT_FEAT_C_RESET\n");
switch (dum->vdev[rhport].speed) { switch (dum->vdev[rhport].speed) {
case USB_SPEED_HIGH: case USB_SPEED_HIGH:
dum->port_status[rhport] |= dum->port_status[rhport] |=
USB_PORT_STAT_HIGH_SPEED; USB_PORT_STAT_HIGH_SPEED;
break; break;
case USB_SPEED_LOW: case USB_SPEED_LOW:
dum->port_status[rhport] |= dum->port_status[rhport] |=
USB_PORT_STAT_LOW_SPEED; USB_PORT_STAT_LOW_SPEED;
break; break;
default: default:
break; break;
} }
default: default:
usbip_dbg_vhci_rh(" ClearPortFeature: default %x\n", usbip_dbg_vhci_rh(" ClearPortFeature: default %x\n",
wValue); wValue);
dum->port_status[rhport] &= ~(1 << wValue); dum->port_status[rhport] &= ~(1 << wValue);
} }
break; break;
...@@ -375,39 +359,38 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, ...@@ -375,39 +359,38 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
} }
if ((dum->port_status[rhport] & (1 << USB_PORT_FEAT_RESET)) != if ((dum->port_status[rhport] & (1 << USB_PORT_FEAT_RESET)) !=
0 && time_after(jiffies, dum->re_timeout)) { 0 && time_after(jiffies, dum->re_timeout)) {
dum->port_status[rhport] |= dum->port_status[rhport] |=
(1 << USB_PORT_FEAT_C_RESET); (1 << USB_PORT_FEAT_C_RESET);
dum->port_status[rhport] &= dum->port_status[rhport] &=
~(1 << USB_PORT_FEAT_RESET); ~(1 << USB_PORT_FEAT_RESET);
dum->re_timeout = 0; dum->re_timeout = 0;
if (dum->vdev[rhport].ud.status == if (dum->vdev[rhport].ud.status ==
VDEV_ST_NOTASSIGNED) { VDEV_ST_NOTASSIGNED) {
usbip_dbg_vhci_rh(" enable rhport %d " usbip_dbg_vhci_rh(" enable rhport %d "
"(status %u)\n", "(status %u)\n",
rhport, rhport,
dum->vdev[rhport].ud.status); dum->vdev[rhport].ud.status);
dum->port_status[rhport] |= dum->port_status[rhport] |=
USB_PORT_STAT_ENABLE; USB_PORT_STAT_ENABLE;
} }
#if 0 #if 0
if (dum->driver) { if (dum->driver) {
dum->port_status[rhport] |= dum->port_status[rhport] |=
USB_PORT_STAT_ENABLE; USB_PORT_STAT_ENABLE;
/* give it the best speed we agree on */ /* give it the best speed we agree on */
dum->gadget.speed = dum->driver->speed; dum->gadget.speed = dum->driver->speed;
dum->gadget.ep0->maxpacket = 64; dum->gadget.ep0->maxpacket = 64;
switch (dum->gadget.speed) { switch (dum->gadget.speed) {
case USB_SPEED_HIGH: case USB_SPEED_HIGH:
dum->port_status[rhport] |= dum->port_status[rhport] |=
USB_PORT_STAT_HIGH_SPEED; USB_PORT_STAT_HIGH_SPEED;
break; break;
case USB_SPEED_LOW: case USB_SPEED_LOW:
dum->gadget.ep0->maxpacket = 8; dum->gadget.ep0->maxpacket = 8;
dum->port_status[rhport] |= dum->port_status[rhport] |=
USB_PORT_STAT_LOW_SPEED; USB_PORT_STAT_LOW_SPEED;
break; break;
default: default:
dum->gadget.speed = USB_SPEED_FULL; dum->gadget.speed = USB_SPEED_FULL;
...@@ -415,14 +398,12 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, ...@@ -415,14 +398,12 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
} }
} }
#endif #endif
} }
((u16 *) buf)[0] = cpu_to_le16(dum->port_status[rhport]); ((u16 *) buf)[0] = cpu_to_le16(dum->port_status[rhport]);
((u16 *) buf)[1] = ((u16 *) buf)[1] = cpu_to_le16(dum->port_status[rhport] >> 16);
cpu_to_le16(dum->port_status[rhport] >> 16);
usbip_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]); ((u16 *)buf)[1]);
break; break;
case SetHubFeature: case SetHubFeature:
usbip_dbg_vhci_rh(" SetHubFeature\n"); usbip_dbg_vhci_rh(" SetHubFeature\n");
...@@ -432,11 +413,11 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, ...@@ -432,11 +413,11 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
switch (wValue) { switch (wValue) {
case USB_PORT_FEAT_SUSPEND: case USB_PORT_FEAT_SUSPEND:
usbip_dbg_vhci_rh(" SetPortFeature: " usbip_dbg_vhci_rh(" SetPortFeature: "
"USB_PORT_FEAT_SUSPEND\n"); "USB_PORT_FEAT_SUSPEND\n");
printk(KERN_ERR "%s: not yet\n", __func__); printk(KERN_ERR "%s: not yet\n", __func__);
#if 0 #if 0
dum->port_status[rhport] |= dum->port_status[rhport] |=
(1 << USB_PORT_FEAT_SUSPEND); (1 << USB_PORT_FEAT_SUSPEND);
if (dum->driver->suspend) { if (dum->driver->suspend) {
spin_unlock(&dum->lock); spin_unlock(&dum->lock);
dum->driver->suspend(&dum->gadget); dum->driver->suspend(&dum->gadget);
...@@ -446,13 +427,13 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, ...@@ -446,13 +427,13 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
break; break;
case USB_PORT_FEAT_RESET: case USB_PORT_FEAT_RESET:
usbip_dbg_vhci_rh(" SetPortFeature: " usbip_dbg_vhci_rh(" SetPortFeature: "
"USB_PORT_FEAT_RESET\n"); "USB_PORT_FEAT_RESET\n");
/* if it's already running, disconnect first */ /* if it's already running, disconnect first */
if (dum->port_status[rhport] & USB_PORT_STAT_ENABLE) { if (dum->port_status[rhport] & USB_PORT_STAT_ENABLE) {
dum->port_status[rhport] &= dum->port_status[rhport] &=
~(USB_PORT_STAT_ENABLE | ~(USB_PORT_STAT_ENABLE |
USB_PORT_STAT_LOW_SPEED | USB_PORT_STAT_LOW_SPEED |
USB_PORT_STAT_HIGH_SPEED); USB_PORT_STAT_HIGH_SPEED);
#if 0 #if 0
if (dum->driver) { if (dum->driver) {
dev_dbg(hardware, "disconnect\n"); dev_dbg(hardware, "disconnect\n");
...@@ -468,7 +449,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, ...@@ -468,7 +449,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
/* FALLTHROUGH */ /* FALLTHROUGH */
default: default:
usbip_dbg_vhci_rh(" SetPortFeature: default %d\n", usbip_dbg_vhci_rh(" SetPortFeature: default %d\n",
wValue); wValue);
dum->port_status[rhport] |= (1 << wValue); dum->port_status[rhport] |= (1 << wValue);
} }
break; break;
...@@ -545,7 +526,6 @@ static void vhci_tx_urb(struct urb *urb) ...@@ -545,7 +526,6 @@ static void vhci_tx_urb(struct urb *urb)
urb->hcpriv = (void *) priv; urb->hcpriv = (void *) priv;
list_add_tail(&priv->list, &vdev->priv_tx); list_add_tail(&priv->list, &vdev->priv_tx);
wake_up(&vdev->waitq_tx); wake_up(&vdev->waitq_tx);
...@@ -561,7 +541,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, ...@@ -561,7 +541,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
struct vhci_device *vdev; struct vhci_device *vdev;
usbip_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); hcd, urb, mem_flags);
/* patch to usb_sg_init() is in 2.5.60 */ /* patch to usb_sg_init() is in 2.5.60 */
BUG_ON(!urb->transfer_buffer && urb->transfer_buffer_length); BUG_ON(!urb->transfer_buffer && urb->transfer_buffer_length);
...@@ -578,7 +558,8 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, ...@@ -578,7 +558,8 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
/* refuse enqueue for dead connection */ /* refuse enqueue for dead connection */
spin_lock(&vdev->ud.lock); spin_lock(&vdev->ud.lock);
if (vdev->ud.status == VDEV_ST_NULL || vdev->ud.status == VDEV_ST_ERROR) { if (vdev->ud.status == VDEV_ST_NULL ||
vdev->ud.status == VDEV_ST_ERROR) {
usbip_uerr("enqueue for inactive port %d\n", vdev->rhport); usbip_uerr("enqueue for inactive port %d\n", vdev->rhport);
spin_unlock(&vdev->ud.lock); spin_unlock(&vdev->ud.lock);
spin_unlock_irqrestore(&the_controller->lock, flags); spin_unlock_irqrestore(&the_controller->lock, flags);
...@@ -599,11 +580,10 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, ...@@ -599,11 +580,10 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
* 2. Set_Address request to DevAddr(0) EndPoint(0) * 2. Set_Address request to DevAddr(0) EndPoint(0)
* *
*/ */
if (usb_pipedevice(urb->pipe) == 0) { if (usb_pipedevice(urb->pipe) == 0) {
__u8 type = usb_pipetype(urb->pipe); __u8 type = usb_pipetype(urb->pipe);
struct usb_ctrlrequest *ctrlreq = struct usb_ctrlrequest *ctrlreq =
(struct usb_ctrlrequest *) urb->setup_packet; (struct usb_ctrlrequest *) urb->setup_packet;
if (type != PIPE_CONTROL || !ctrlreq) { if (type != PIPE_CONTROL || !ctrlreq) {
dev_err(dev, "invalid request to devnum 0\n"); dev_err(dev, "invalid request to devnum 0\n");
...@@ -636,8 +616,8 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, ...@@ -636,8 +616,8 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
case USB_REQ_GET_DESCRIPTOR: case USB_REQ_GET_DESCRIPTOR:
if (ctrlreq->wValue == (USB_DT_DEVICE << 8)) if (ctrlreq->wValue == (USB_DT_DEVICE << 8))
usbip_dbg_vhci_hc("Not yet?: " usbip_dbg_vhci_hc("Not yet?: "
"Get_Descriptor to device 0 " "Get_Descriptor to device 0 "
"(get max pipe size)\n"); "(get max pipe size)\n");
if (vdev->udev) if (vdev->udev)
usb_put_dev(vdev->udev); usb_put_dev(vdev->udev);
...@@ -657,7 +637,6 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, ...@@ -657,7 +637,6 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
out: out:
vhci_tx_urb(urb); vhci_tx_urb(urb);
spin_unlock_irqrestore(&the_controller->lock, flags); spin_unlock_irqrestore(&the_controller->lock, flags);
return 0; return 0;
...@@ -726,7 +705,6 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) ...@@ -726,7 +705,6 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
usbip_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); spin_lock_irqsave(&the_controller->lock, flags);
priv = urb->hcpriv; priv = urb->hcpriv;
...@@ -756,7 +734,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) ...@@ -756,7 +734,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
spin_lock_irqsave(&vdev->priv_lock, flags2); spin_lock_irqsave(&vdev->priv_lock, flags2);
usbip_uinfo("vhci_hcd: device %p seems to be disconnected\n", usbip_uinfo("vhci_hcd: device %p seems to be disconnected\n",
vdev); vdev);
list_del(&priv->list); list_del(&priv->list);
kfree(priv); kfree(priv);
urb->hcpriv = NULL; urb->hcpriv = NULL;
...@@ -769,13 +747,13 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) ...@@ -769,13 +747,13 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
* Otherwise, we give back it here. * Otherwise, we give back it here.
*/ */
usbip_uinfo("vhci_hcd: vhci_urb_dequeue() gives back urb %p\n", usbip_uinfo("vhci_hcd: vhci_urb_dequeue() gives back urb %p\n",
urb); urb);
usb_hcd_unlink_urb_from_ep(hcd, urb); usb_hcd_unlink_urb_from_ep(hcd, urb);
spin_unlock_irqrestore(&the_controller->lock, flags); spin_unlock_irqrestore(&the_controller->lock, flags);
usb_hcd_giveback_urb(vhci_to_hcd(the_controller), urb, usb_hcd_giveback_urb(vhci_to_hcd(the_controller), urb,
urb->status); urb->status);
spin_lock_irqsave(&the_controller->lock, flags); spin_lock_irqsave(&the_controller->lock, flags);
} else { } else {
...@@ -802,7 +780,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) ...@@ -802,7 +780,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
unlink->unlink_seqnum = priv->seqnum; unlink->unlink_seqnum = priv->seqnum;
usbip_uinfo("vhci_hcd: device %p seems to be still connected\n", usbip_uinfo("vhci_hcd: device %p seems to be still connected\n",
vdev); vdev);
/* send cmd_unlink and try to cancel the pending URB in the /* send cmd_unlink and try to cancel the pending URB in the
* peer */ * peer */
...@@ -838,8 +816,8 @@ static void vhci_device_unlink_cleanup(struct vhci_device *vdev) ...@@ -838,8 +816,8 @@ static void vhci_device_unlink_cleanup(struct vhci_device *vdev)
urb = pickup_urb_and_free_priv(vdev, unlink->unlink_seqnum); urb = pickup_urb_and_free_priv(vdev, unlink->unlink_seqnum);
if (!urb) { if (!urb) {
usbip_uinfo("the urb (seqnum %lu) was already given back\n", usbip_uinfo("the urb (seqnum %lu) was already given "
unlink->unlink_seqnum); "back\n", unlink->unlink_seqnum);
list_del(&unlink->list); list_del(&unlink->list);
kfree(unlink); kfree(unlink);
continue; continue;
...@@ -851,7 +829,8 @@ static void vhci_device_unlink_cleanup(struct vhci_device *vdev) ...@@ -851,7 +829,8 @@ static void vhci_device_unlink_cleanup(struct vhci_device *vdev)
usb_hcd_unlink_urb_from_ep(vhci_to_hcd(the_controller), urb); usb_hcd_unlink_urb_from_ep(vhci_to_hcd(the_controller), urb);
spin_unlock(&the_controller->lock); spin_unlock(&the_controller->lock);
usb_hcd_giveback_urb(vhci_to_hcd(the_controller), urb, urb->status); usb_hcd_giveback_urb(vhci_to_hcd(the_controller), urb,
urb->status);
list_del(&unlink->list); list_del(&unlink->list);
kfree(unlink); kfree(unlink);
...@@ -930,7 +909,6 @@ static void vhci_device_reset(struct usbip_device *ud) ...@@ -930,7 +909,6 @@ static void vhci_device_reset(struct usbip_device *ud)
vdev->udev = NULL; vdev->udev = NULL;
ud->tcp_socket = NULL; ud->tcp_socket = NULL;
ud->status = VDEV_ST_NULL; ud->status = VDEV_ST_NULL;
spin_unlock(&ud->lock); spin_unlock(&ud->lock);
...@@ -939,9 +917,7 @@ static void vhci_device_reset(struct usbip_device *ud) ...@@ -939,9 +917,7 @@ static void vhci_device_reset(struct usbip_device *ud)
static void vhci_device_unusable(struct usbip_device *ud) static void vhci_device_unusable(struct usbip_device *ud)
{ {
spin_lock(&ud->lock); spin_lock(&ud->lock);
ud->status = VDEV_ST_ERROR; ud->status = VDEV_ST_ERROR;
spin_unlock(&ud->lock); spin_unlock(&ud->lock);
} }
...@@ -984,7 +960,6 @@ static int vhci_start(struct usb_hcd *hcd) ...@@ -984,7 +960,6 @@ static int vhci_start(struct usb_hcd *hcd)
usbip_dbg_vhci_hc("enter vhci_start\n"); usbip_dbg_vhci_hc("enter vhci_start\n");
/* initialize private data of usb_hcd */ /* initialize private data of usb_hcd */
for (rhport = 0; rhport < VHCI_NPORTS; rhport++) { for (rhport = 0; rhport < VHCI_NPORTS; rhport++) {
...@@ -996,13 +971,10 @@ static int vhci_start(struct usb_hcd *hcd) ...@@ -996,13 +971,10 @@ static int vhci_start(struct usb_hcd *hcd)
atomic_set(&vhci->seqnum, 0); atomic_set(&vhci->seqnum, 0);
spin_lock_init(&vhci->lock); spin_lock_init(&vhci->lock);
hcd->power_budget = 0; /* no limit */ hcd->power_budget = 0; /* no limit */
hcd->state = HC_STATE_RUNNING; hcd->state = HC_STATE_RUNNING;
hcd->uses_new_polling = 1; hcd->uses_new_polling = 1;
/* vhci_hcd is now ready to be controlled through sysfs */ /* vhci_hcd is now ready to be controlled through sysfs */
err = sysfs_create_group(&vhci_dev(vhci)->kobj, &dev_attr_group); err = sysfs_create_group(&vhci_dev(vhci)->kobj, &dev_attr_group);
if (err) { if (err) {
...@@ -1020,7 +992,6 @@ static void vhci_stop(struct usb_hcd *hcd) ...@@ -1020,7 +992,6 @@ static void vhci_stop(struct usb_hcd *hcd)
usbip_dbg_vhci_hc("stop VHCI controller\n"); usbip_dbg_vhci_hc("stop VHCI controller\n");
/* 1. remove the userland interface of vhci_hcd */ /* 1. remove the userland interface of vhci_hcd */
sysfs_remove_group(&vhci_dev(vhci)->kobj, &dev_attr_group); sysfs_remove_group(&vhci_dev(vhci)->kobj, &dev_attr_group);
...@@ -1032,7 +1003,6 @@ static void vhci_stop(struct usb_hcd *hcd) ...@@ -1032,7 +1003,6 @@ static void vhci_stop(struct usb_hcd *hcd)
usbip_stop_eh(&vdev->ud); usbip_stop_eh(&vdev->ud);
} }
usbip_uinfo("vhci_stop done\n"); usbip_uinfo("vhci_stop done\n");
} }
...@@ -1044,7 +1014,6 @@ static int vhci_get_frame_number(struct usb_hcd *hcd) ...@@ -1044,7 +1014,6 @@ static int vhci_get_frame_number(struct usb_hcd *hcd)
return 0; return 0;
} }
#ifdef CONFIG_PM #ifdef CONFIG_PM
/* FIXME: suspend/resume */ /* FIXME: suspend/resume */
...@@ -1092,8 +1061,6 @@ static int vhci_bus_resume(struct usb_hcd *hcd) ...@@ -1092,8 +1061,6 @@ static int vhci_bus_resume(struct usb_hcd *hcd)
#define vhci_bus_resume NULL #define vhci_bus_resume NULL
#endif #endif
static struct hc_driver vhci_hc_driver = { static struct hc_driver vhci_hc_driver = {
.description = driver_name, .description = driver_name,
.product_desc = driver_desc, .product_desc = driver_desc,
...@@ -1156,12 +1123,10 @@ static int vhci_hcd_probe(struct platform_device *pdev) ...@@ -1156,12 +1123,10 @@ static int vhci_hcd_probe(struct platform_device *pdev)
return ret; return ret;
} }
usbip_dbg_vhci_hc("bye\n"); usbip_dbg_vhci_hc("bye\n");
return 0; return 0;
} }
static int vhci_hcd_remove(struct platform_device *pdev) static int vhci_hcd_remove(struct platform_device *pdev)
{ {
struct usb_hcd *hcd; struct usb_hcd *hcd;
...@@ -1179,12 +1144,9 @@ static int vhci_hcd_remove(struct platform_device *pdev) ...@@ -1179,12 +1144,9 @@ static int vhci_hcd_remove(struct platform_device *pdev)
usb_put_hcd(hcd); usb_put_hcd(hcd);
the_controller = NULL; the_controller = NULL;
return 0; return 0;
} }
#ifdef CONFIG_PM #ifdef CONFIG_PM
/* what should happen for USB/IP under suspend/resume? */ /* what should happen for USB/IP under suspend/resume? */
...@@ -1203,14 +1165,14 @@ static int vhci_hcd_suspend(struct platform_device *pdev, pm_message_t state) ...@@ -1203,14 +1165,14 @@ static int vhci_hcd_suspend(struct platform_device *pdev, pm_message_t state)
for (rhport = 0; rhport < VHCI_NPORTS; rhport++) for (rhport = 0; rhport < VHCI_NPORTS; rhport++)
if (the_controller->port_status[rhport] & if (the_controller->port_status[rhport] &
USB_PORT_STAT_CONNECTION) USB_PORT_STAT_CONNECTION)
connected += 1; connected += 1;
spin_unlock(&the_controller->lock); spin_unlock(&the_controller->lock);
if (connected > 0) { if (connected > 0) {
usbip_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")); connected, (connected == 1 ? "" : "s"));
ret = -EBUSY; ret = -EBUSY;
} else { } else {
usbip_uinfo("suspend vhci_hcd"); usbip_uinfo("suspend vhci_hcd");
...@@ -1240,7 +1202,6 @@ static int vhci_hcd_resume(struct platform_device *pdev) ...@@ -1240,7 +1202,6 @@ static int vhci_hcd_resume(struct platform_device *pdev)
#endif #endif
static struct platform_driver vhci_driver = { static struct platform_driver vhci_driver = {
.probe = vhci_hcd_probe, .probe = vhci_hcd_probe,
.remove = __devexit_p(vhci_hcd_remove), .remove = __devexit_p(vhci_hcd_remove),
...@@ -1299,12 +1260,10 @@ static int __init vhci_init(void) ...@@ -1299,12 +1260,10 @@ static int __init vhci_init(void)
/* error occurred */ /* error occurred */
err_platform_device_register: err_platform_device_register:
platform_driver_unregister(&vhci_driver); platform_driver_unregister(&vhci_driver);
err_driver_register: err_driver_register:
usbip_dbg_vhci_hc("bye\n"); usbip_dbg_vhci_hc("bye\n");
return ret; return ret;
} }
module_init(vhci_init);
static void __exit vhci_cleanup(void) static void __exit vhci_cleanup(void)
{ {
...@@ -1315,4 +1274,10 @@ static void __exit vhci_cleanup(void) ...@@ -1315,4 +1274,10 @@ static void __exit vhci_cleanup(void)
usbip_dbg_vhci_hc("bye\n"); usbip_dbg_vhci_hc("bye\n");
} }
module_init(vhci_init);
module_exit(vhci_cleanup); module_exit(vhci_cleanup);
MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_LICENSE(DRIVER_LICENCE);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment