Skip to content

Commit

Permalink
Staging: USB-IP code cleanup
Browse files Browse the repository at this point in the history
This includes fixes for all of the legit checkpatch.pl errors and
warnings.  I have also included several of the suggestions from the
linux-kernel mailing list when the USB-IP code was first added.

Signed-off-by: Brian G. Merrell <bgmerrell@novell.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Brian G. Merrell authored and Greg Kroah-Hartman committed Sep 15, 2009
1 parent 1dd7def commit b8868e4
Show file tree
Hide file tree
Showing 12 changed files with 360 additions and 337 deletions.
2 changes: 1 addition & 1 deletion drivers/staging/usbip/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ config USB_IP_COMMON
This enables pushing USB packets over IP to allow remote
machines access to USB devices directly. For more details,
and links to the userspace utility programs to let this work
properly, see http://usbip.naist.jp/
properly, see http://usbip.sourceforge.net/.

To compile this driver as a module, choose M here: the
module will be called usbip_common_mod.
Expand Down
16 changes: 8 additions & 8 deletions drivers/staging/usbip/stub_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ static void stub_shutdown_connection(struct usbip_device *ud)
* step 1?
*/
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);
}

Expand Down Expand Up @@ -259,7 +259,7 @@ static void stub_device_reset(struct usbip_device *ud)
struct usb_device *udev = interface_to_usbdev(sdev->interface);
int ret;

udbg("device reset");
usbip_udbg("device reset");
ret = usb_lock_device_for_reset(udev, sdev->interface);
if (ret < 0) {
dev_err(&udev->dev, "lock for reset\n");
Expand Down Expand Up @@ -356,7 +356,7 @@ static struct stub_device *stub_device_alloc(struct usb_interface *interface)

usbip_start_eh(&sdev->ud);

udbg("register new interface\n");
usbip_udbg("register new interface\n");
return sdev;
}

Expand All @@ -366,7 +366,7 @@ static int stub_device_free(struct stub_device *sdev)
return -EINVAL;

kfree(sdev);
udbg("kfree udev ok\n");
usbip_udbg("kfree udev ok\n");

return 0;
}
Expand Down Expand Up @@ -409,13 +409,13 @@ static int stub_probe(struct usb_interface *interface,
}

if (udev->descriptor.bDeviceClass == USB_CLASS_HUB) {
udbg("this device %s is a usb hub device. skip!\n",
usbip_udbg("this device %s is a usb hub device. skip!\n",
udev_busid);
return -ENODEV;
}

if (!strcmp(udev->bus->bus_name, "vhci_hcd")) {
udbg("this device %s is attached on vhci_hcd. skip!\n",
usbip_udbg("this device %s is attached on vhci_hcd. skip!\n",
udev_busid);
return -ENODEV;
}
Expand Down Expand Up @@ -451,7 +451,7 @@ static void stub_disconnect(struct usb_interface *interface)
{
struct stub_device *sdev = usb_get_intfdata(interface);

udbg("Enter\n");
usbip_udbg("Enter\n");

/* get stub_device */
if (!sdev) {
Expand Down Expand Up @@ -479,5 +479,5 @@ static void stub_disconnect(struct usb_interface *interface)
stub_device_free(sdev);


udbg("bye\n");
usbip_udbg("bye\n");
}
8 changes: 4 additions & 4 deletions drivers/staging/usbip/stub_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,14 @@ static ssize_t store_match_busid(struct device_driver *dev, const char *buf,
if (add_match_busid(busid) < 0)
return -ENOMEM;
else {
udbg("add busid %s\n", busid);
usbip_udbg("add busid %s\n", busid);
return count;
}
} else if (!strncmp(buf, "del ", 4)) {
if (del_match_busid(busid) < 0)
return -ENODEV;
else {
udbg("del busid %s\n", busid);
usbip_udbg("del busid %s\n", busid);
return count;
}
} else
Expand Down Expand Up @@ -213,12 +213,12 @@ void stub_device_cleanup_urbs(struct stub_device *sdev)
{
struct stub_priv *priv;

udbg("free sdev %p\n", sdev);
usbip_udbg("free sdev %p\n", sdev);

while ((priv = stub_priv_pop(sdev))) {
struct urb *urb = priv->urb;

udbg(" free urb %p\n", urb);
usbip_udbg(" free urb %p\n", urb);
usb_kill_urb(urb);

kmem_cache_free(stub_priv_cache, priv);
Expand Down
49 changes: 27 additions & 22 deletions drivers/staging/usbip/stub_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ static int is_reset_device_cmd(struct urb *urb)

if ((req->bRequest == USB_REQ_SET_FEATURE) &&
(req->bRequestType == USB_RT_PORT) &&
(value = USB_PORT_FEAT_RESET)) {
dbg_stub_rx("reset_device_cmd, port %u\n", index);
(value == USB_PORT_FEAT_RESET)) {
usbip_dbg_stub_rx("reset_device_cmd, port %u\n", index);
return 1;
} else
return 0;
Expand Down Expand Up @@ -99,11 +99,11 @@ static int tweak_clear_halt_cmd(struct urb *urb)

ret = usb_clear_halt(urb->dev, target_pipe);
if (ret < 0)
uinfo("clear_halt error: devnum %d endp %d, %d\n",
urb->dev->devnum, target_endp, ret);
usbip_uinfo("clear_halt error: devnum %d endp %d, %d\n",
urb->dev->devnum, target_endp, ret);
else
uinfo("clear_halt done: devnum %d endp %d\n",
urb->dev->devnum, target_endp);
usbip_uinfo("clear_halt done: devnum %d endp %d\n",
urb->dev->devnum, target_endp);

return ret;
}
Expand All @@ -119,14 +119,15 @@ static int tweak_set_interface_cmd(struct urb *urb)
alternate = le16_to_cpu(req->wValue);
interface = le16_to_cpu(req->wIndex);

dbg_stub_rx("set_interface: inf %u alt %u\n", interface, alternate);
usbip_dbg_stub_rx("set_interface: inf %u alt %u\n", interface,
alternate);

ret = usb_set_interface(urb->dev, interface, alternate);
if (ret < 0)
uinfo("set_interface error: inf %u alt %u, %d\n",
interface, alternate, ret);
usbip_uinfo("set_interface error: inf %u alt %u, %d\n",
interface, alternate, ret);
else
uinfo("set_interface done: inf %u alt %u\n",
usbip_uinfo("set_interface done: inf %u alt %u\n",
interface,
alternate);

Expand Down Expand Up @@ -157,8 +158,9 @@ static int tweak_set_configuration_cmd(struct urb *urb)
* A user may need to set a special configuration value before
* exporting the device.
*/
uinfo("set_configuration (%d) to %s\n", config, dev_name(&urb->dev->dev));
uinfo("but, skip!\n");
usbip_uinfo("set_configuration (%d) to %s\n", config,
dev_name(&urb->dev->dev));
usbip_uinfo("but, skip!\n");

return 0;
/* return usb_driver_set_configuration(urb->dev, config); */
Expand All @@ -175,7 +177,8 @@ static int tweak_reset_device_cmd(struct urb *urb)
value = le16_to_cpu(req->wValue);
index = le16_to_cpu(req->wIndex);

uinfo("reset_device (port %d) to %s\n", index, dev_name(&urb->dev->dev));
usbip_uinfo("reset_device (port %d) to %s\n", index,
dev_name(&urb->dev->dev));

/* all interfaces should be owned by usbip driver, so just reset it. */
ret = usb_lock_device_for_reset(urb->dev, NULL);
Expand Down Expand Up @@ -220,7 +223,7 @@ static void tweak_special_requests(struct urb *urb)
else if (is_reset_device_cmd(urb))
tweak_reset_device_cmd(urb);
else
dbg_stub_rx("no need to tweak\n");
usbip_dbg_stub_rx("no need to tweak\n");
}

/*
Expand Down Expand Up @@ -292,7 +295,8 @@ static int stub_recv_cmd_unlink(struct stub_device *sdev,
}
}

dbg_stub_rx("seqnum %d is not pending\n", pdu->u.cmd_unlink.seqnum);
usbip_dbg_stub_rx("seqnum %d is not pending\n",
pdu->u.cmd_unlink.seqnum);

/*
* The urb of the unlink target is not found in priv_init queue. It was
Expand Down Expand Up @@ -383,7 +387,7 @@ static struct usb_host_endpoint *get_ep_from_epnum(struct usb_device *udev,
epnum = (ep->desc.bEndpointAddress & 0x7f);

if (epnum == epnum0) {
/* uinfo("found epnum %d\n", epnum0); */
/* usbip_uinfo("found epnum %d\n", epnum0);*/
found = 1;
break;
}
Expand Down Expand Up @@ -526,7 +530,8 @@ static void stub_recv_cmd_submit(struct stub_device *sdev,
ret = usb_submit_urb(priv->urb, GFP_KERNEL);

if (ret == 0)
dbg_stub_rx("submit urb ok, seqnum %u\n", pdu->base.seqnum);
usbip_dbg_stub_rx("submit urb ok, seqnum %u\n",
pdu->base.seqnum);
else {
dev_err(&sdev->interface->dev, "submit_urb error, %d\n", ret);
usbip_dump_header(pdu);
Expand All @@ -539,7 +544,7 @@ static void stub_recv_cmd_submit(struct stub_device *sdev,
usbip_event_add(ud, SDEV_EVENT_ERROR_SUBMIT);
}

dbg_stub_rx("Leave\n");
usbip_dbg_stub_rx("Leave\n");
return;
}

Expand All @@ -551,7 +556,7 @@ static void stub_rx_pdu(struct usbip_device *ud)
struct stub_device *sdev = container_of(ud, struct stub_device, ud);
struct device *dev = &sdev->interface->dev;

dbg_stub_rx("Enter\n");
usbip_dbg_stub_rx("Enter\n");

memset(&pdu, 0, sizeof(pdu));

Expand All @@ -565,7 +570,7 @@ static void stub_rx_pdu(struct usbip_device *ud)

usbip_header_correct_endian(&pdu, 0);

if (dbg_flag_stub_rx)
if (usbip_dbg_flag_stub_rx)
usbip_dump_header(&pdu);

if (!valid_request(sdev, &pdu)) {
Expand Down Expand Up @@ -598,11 +603,11 @@ void stub_rx_loop(struct usbip_task *ut)

while (1) {
if (signal_pending(current)) {
dbg_stub_rx("signal caught!\n");
usbip_dbg_stub_rx("signal caught!\n");
break;
}

if (usbip_event_happend(ud))
if (usbip_event_happened(ud))
break;

stub_rx_pdu(ud);
Expand Down
26 changes: 14 additions & 12 deletions drivers/staging/usbip/stub_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,28 +66,30 @@ void stub_complete(struct urb *urb)
struct stub_device *sdev = priv->sdev;
unsigned long flags;

dbg_stub_tx("complete! status %d\n", urb->status);
usbip_dbg_stub_tx("complete! status %d\n", urb->status);


switch (urb->status) {
case 0:
/* OK */
break;
case -ENOENT:
uinfo("stopped by a call of usb_kill_urb() because of"
usbip_uinfo("stopped by a call of usb_kill_urb() because of"
"cleaning up a virtual connection\n");
return;
case -ECONNRESET:
uinfo("unlinked by a call of usb_unlink_urb()\n");
usbip_uinfo("unlinked by a call of usb_unlink_urb()\n");
break;
case -EPIPE:
uinfo("endpoint %d is stalled\n", usb_pipeendpoint(urb->pipe));
usbip_uinfo("endpoint %d is stalled\n",
usb_pipeendpoint(urb->pipe));
break;
case -ESHUTDOWN:
uinfo("device removed?\n");
usbip_uinfo("device removed?\n");
break;
default:
uinfo("urb completion with non-zero status %d\n", urb->status);
usbip_uinfo("urb completion with non-zero status %d\n",
urb->status);
}

/* link a urb to the queue of tx. */
Expand Down Expand Up @@ -181,7 +183,7 @@ static int stub_send_ret_submit(struct stub_device *sdev)
memset(&msg, 0, sizeof(msg));
memset(&iov, 0, sizeof(iov));

dbg_stub_tx("setup txdata urb %p\n", urb);
usbip_dbg_stub_tx("setup txdata urb %p\n", urb);


/* 1. setup usbip_header */
Expand Down Expand Up @@ -227,7 +229,7 @@ static int stub_send_ret_submit(struct stub_device *sdev)
}

kfree(iso_buffer);
dbg_stub_tx("send txdata\n");
usbip_dbg_stub_tx("send txdata\n");

total_size += txsize;
}
Expand Down Expand Up @@ -287,7 +289,7 @@ static int stub_send_ret_unlink(struct stub_device *sdev)
memset(&msg, 0, sizeof(msg));
memset(&iov, 0, sizeof(iov));

dbg_stub_tx("setup ret unlink %lu\n", unlink->seqnum);
usbip_dbg_stub_tx("setup ret unlink %lu\n", unlink->seqnum);

/* 1. setup usbip_header */
setup_ret_unlink_pdu(&pdu_header, unlink);
Expand All @@ -308,7 +310,7 @@ static int stub_send_ret_unlink(struct stub_device *sdev)
}


dbg_stub_tx("send txdata\n");
usbip_dbg_stub_tx("send txdata\n");

total_size += txsize;
}
Expand Down Expand Up @@ -336,11 +338,11 @@ void stub_tx_loop(struct usbip_task *ut)

while (1) {
if (signal_pending(current)) {
dbg_stub_tx("signal catched\n");
usbip_dbg_stub_tx("signal catched\n");
break;
}

if (usbip_event_happend(ud))
if (usbip_event_happened(ud))
break;

/*
Expand Down
Loading

0 comments on commit b8868e4

Please sign in to comment.