* [PATCH 00/12] staging: usbip @ 2011-05-20 4:36 ` matt mooney 0 siblings, 0 replies; 42+ messages in thread From: matt mooney @ 2011-05-20 4:36 UTC (permalink / raw) To: Greg Kroah-Hartman; +Cc: linux-kernel, kernel-janitors matt mooney (12): staging: usbip: replace usbip_u{dbg,err,info} and printk with dev_ and pr_ staging: usbip: remove unnecessary lines and extra return statements staging: usbip: stub_main.c: reorder functions staging: usbip: stub_main.c: code cleanup staging: usbip: stub_main.c: rename init and exit functions staging: usbip: stub_main.c: use KMEM_CACHE macro staging: usbip: usbip_common.c: fix misspelled function name staging: usbip: usbip_common.h: reorganize and document request headers staging: usbip: stub_dev.c: move stub_driver definition and update driver name staging: usbip: userspace: bind_driver.c: update kernel module name staging: usbip: usbip_common.c: rename init and exit functions staging: usbip: vhci_hcd.c: rename init and exit functions drivers/staging/usbip/stub.h | 1 + drivers/staging/usbip/stub_dev.c | 93 +++---- drivers/staging/usbip/stub_main.c | 212 +++++++--------- drivers/staging/usbip/stub_rx.c | 23 +- drivers/staging/usbip/stub_tx.c | 30 +- drivers/staging/usbip/usbip_common.c | 257 +++++++++---------- drivers/staging/usbip/usbip_common.h | 284 +++++++++----------- drivers/staging/usbip/usbip_event.c | 3 +- drivers/staging/usbip/userspace/src/bind-driver.c | 4 +- drivers/staging/usbip/vhci_hcd.c | 106 +++----- drivers/staging/usbip/vhci_rx.c | 35 ++-- drivers/staging/usbip/vhci_sysfs.c | 14 +- drivers/staging/usbip/vhci_tx.c | 8 +- 13 files changed, 479 insertions(+), 591 deletions(-) -- 1.7.5.1 ^ permalink raw reply [flat|nested] 42+ messages in thread
* [PATCH 00/12] staging: usbip @ 2011-05-20 4:36 ` matt mooney 0 siblings, 0 replies; 42+ messages in thread From: matt mooney @ 2011-05-20 4:36 UTC (permalink / raw) To: Greg Kroah-Hartman; +Cc: linux-kernel, kernel-janitors matt mooney (12): staging: usbip: replace usbip_u{dbg,err,info} and printk with dev_ and pr_ staging: usbip: remove unnecessary lines and extra return statements staging: usbip: stub_main.c: reorder functions staging: usbip: stub_main.c: code cleanup staging: usbip: stub_main.c: rename init and exit functions staging: usbip: stub_main.c: use KMEM_CACHE macro staging: usbip: usbip_common.c: fix misspelled function name staging: usbip: usbip_common.h: reorganize and document request headers staging: usbip: stub_dev.c: move stub_driver definition and update driver name staging: usbip: userspace: bind_driver.c: update kernel module name staging: usbip: usbip_common.c: rename init and exit functions staging: usbip: vhci_hcd.c: rename init and exit functions drivers/staging/usbip/stub.h | 1 + drivers/staging/usbip/stub_dev.c | 93 +++---- drivers/staging/usbip/stub_main.c | 212 +++++++--------- drivers/staging/usbip/stub_rx.c | 23 +- drivers/staging/usbip/stub_tx.c | 30 +- drivers/staging/usbip/usbip_common.c | 257 +++++++++---------- drivers/staging/usbip/usbip_common.h | 284 +++++++++----------- drivers/staging/usbip/usbip_event.c | 3 +- drivers/staging/usbip/userspace/src/bind-driver.c | 4 +- drivers/staging/usbip/vhci_hcd.c | 106 +++----- drivers/staging/usbip/vhci_rx.c | 35 ++-- drivers/staging/usbip/vhci_sysfs.c | 14 +- drivers/staging/usbip/vhci_tx.c | 8 +- 13 files changed, 479 insertions(+), 591 deletions(-) -- 1.7.5.1 ^ permalink raw reply [flat|nested] 42+ messages in thread
* [PATCH 01/12] staging: usbip: replace usbip_u{dbg,err,info} and printk with dev_ and pr_ 2011-05-20 4:36 ` matt mooney @ 2011-05-20 4:36 ` matt mooney -1 siblings, 0 replies; 42+ messages in thread From: matt mooney @ 2011-05-20 4:36 UTC (permalink / raw) To: Greg Kroah-Hartman; +Cc: linux-kernel, kernel-janitors This switches all of the usbip_u{dbg,err,info} and printk statements to dev_<level>, if possible, or pr_<level> macros. And removes a few unnecessary debug statements. Signed-off-by: matt mooney <mfm@muteddisk.com> --- drivers/staging/usbip/stub_dev.c | 44 +++---- drivers/staging/usbip/stub_main.c | 19 ++-- drivers/staging/usbip/stub_rx.c | 23 ++-- drivers/staging/usbip/stub_tx.c | 17 ++-- drivers/staging/usbip/usbip_common.c | 230 +++++++++++++++------------------ drivers/staging/usbip/usbip_common.h | 46 +------ drivers/staging/usbip/usbip_event.c | 3 +- drivers/staging/usbip/vhci_hcd.c | 89 +++++-------- drivers/staging/usbip/vhci_rx.c | 33 +++--- drivers/staging/usbip/vhci_sysfs.c | 14 +- drivers/staging/usbip/vhci_tx.c | 8 +- 11 files changed, 220 insertions(+), 306 deletions(-) diff --git a/drivers/staging/usbip/stub_dev.c b/drivers/staging/usbip/stub_dev.c index c71d0a3..6e99ec8 100644 --- a/drivers/staging/usbip/stub_dev.c +++ b/drivers/staging/usbip/stub_dev.c @@ -196,7 +196,8 @@ static void stub_shutdown_connection(struct usbip_device *ud) * step 1? */ if (ud->tcp_socket) { - usbip_udbg("shutdown tcp_socket %p\n", ud->tcp_socket); + dev_dbg(&sdev->udev->dev, "shutdown tcp_socket %p\n", + ud->tcp_socket); kernel_sock_shutdown(ud->tcp_socket, SHUT_RDWR); } @@ -244,12 +245,11 @@ static void stub_device_reset(struct usbip_device *ud) struct usb_device *udev = sdev->udev; int ret; - usbip_udbg("device reset"); + dev_dbg(&udev->dev, "device reset"); ret = usb_lock_device_for_reset(udev, sdev->interface); if (ret < 0) { dev_err(&udev->dev, "lock for reset\n"); - spin_lock(&ud->lock); ud->status = SDEV_ST_ERROR; spin_unlock(&ud->lock); @@ -336,7 +336,8 @@ static struct stub_device *stub_device_alloc(struct usb_device *udev, usbip_start_eh(&sdev->ud); - usbip_udbg("register new interface\n"); + dev_dbg(&interface->dev, "register new interface\n"); + return sdev; } @@ -346,7 +347,7 @@ static int stub_device_free(struct stub_device *sdev) return -EINVAL; kfree(sdev); - usbip_udbg("kfree udev ok\n"); + pr_debug("kfree udev ok\n"); return 0; } @@ -376,9 +377,8 @@ static int stub_probe(struct usb_interface *interface, busid_priv = get_busid_priv(udev_busid); if (!busid_priv || (busid_priv->status == STUB_BUSID_REMOV) || (busid_priv->status == STUB_BUSID_OTHER)) { - dev_info(&interface->dev, - "this device %s is not in match_busid table. skip!\n", - udev_busid); + dev_info(&interface->dev, "%s is not in match_busid table... " + "skip!\n", udev_busid); /* * Return value should be ENODEV or ENOXIO to continue trying @@ -388,15 +388,15 @@ static int stub_probe(struct usb_interface *interface, return -ENODEV; } - if (udev->descriptor.bDeviceClass == USB_CLASS_HUB) { - usbip_udbg("this device %s is a usb hub device. skip!\n", - udev_busid); + if (udev->descriptor.bDeviceClass == USB_CLASS_HUB) { + dev_dbg(&udev->dev, "%s is a usb hub device... skip!\n", + udev_busid); return -ENODEV; } if (!strcmp(udev->bus->bus_name, "vhci_hcd")) { - usbip_udbg("this device %s is attached on vhci_hcd. skip!\n", - udev_busid); + dev_dbg(&udev->dev, "%s is attached on vhci_hcd... skip!\n", + udev_busid); return -ENODEV; } @@ -406,8 +406,7 @@ static int stub_probe(struct usb_interface *interface, return -ENODEV; busid_priv->interf_count++; - dev_info(&interface->dev, - "USB/IP Stub: register a new interface " + dev_info(&interface->dev, "usbip-host: register new interface " "(bus %u dev %u ifn %u)\n", udev->bus->busnum, udev->devnum, interface->cur_altsetting->desc.bInterfaceNumber); @@ -417,7 +416,7 @@ static int stub_probe(struct usb_interface *interface, err = stub_add_files(&interface->dev); if (err) { - dev_err(&interface->dev, "create sysfs files for %s\n", + dev_err(&interface->dev, "stub_add_files for %s\n", udev_busid); usb_set_intfdata(interface, NULL); busid_priv->interf_count--; @@ -434,7 +433,7 @@ static int stub_probe(struct usb_interface *interface, if (!sdev) return -ENOMEM; - dev_info(&interface->dev, "USB/IP Stub: register a new device " + dev_info(&interface->dev, "usbip-host: register new device " "(bus %u dev %u ifn %u)\n", udev->bus->busnum, udev->devnum, interface->cur_altsetting->desc.bInterfaceNumber); @@ -449,8 +448,7 @@ static int stub_probe(struct usb_interface *interface, err = stub_add_files(&interface->dev); if (err) { - dev_err(&interface->dev, "create sysfs files for %s\n", - udev_busid); + dev_err(&interface->dev, "stub_add_files for %s\n", udev_busid); usb_set_intfdata(interface, NULL); usb_put_intf(interface); @@ -486,10 +484,9 @@ static void stub_disconnect(struct usb_interface *interface) const char *udev_busid = dev_name(interface->dev.parent); struct bus_id_priv *busid_priv; - busid_priv = get_busid_priv(udev_busid); - - usbip_udbg("Enter\n"); + dev_dbg(&interface->dev, "Enter\n"); + busid_priv = get_busid_priv(udev_busid); if (!busid_priv) { BUG(); return; @@ -499,7 +496,7 @@ static void stub_disconnect(struct usb_interface *interface) /* get stub_device */ if (!sdev) { - err(" could not get device from inteface data"); + dev_err(&interface->dev, "could not get device"); /* BUG(); */ return; } @@ -543,5 +540,4 @@ static void stub_disconnect(struct usb_interface *interface) busid_priv->status = STUB_BUSID_OTHER; del_match_busid((char *)udev_busid); } - usbip_udbg("bye\n"); } diff --git a/drivers/staging/usbip/stub_main.c b/drivers/staging/usbip/stub_main.c index 5568110..e9085d6 100644 --- a/drivers/staging/usbip/stub_main.c +++ b/drivers/staging/usbip/stub_main.c @@ -178,14 +178,14 @@ static ssize_t store_match_busid(struct device_driver *dev, const char *buf, if (add_match_busid(busid) < 0) return -ENOMEM; else { - usbip_udbg("add busid %s\n", busid); + pr_debug("add busid %s\n", busid); return count; } } else if (!strncmp(buf, "del ", 4)) { if (del_match_busid(busid) < 0) return -ENODEV; else { - usbip_udbg("del busid %s\n", busid); + pr_debug("del busid %s\n", busid); return count; } } else @@ -239,12 +239,12 @@ void stub_device_cleanup_urbs(struct stub_device *sdev) { struct stub_priv *priv; - usbip_udbg("free sdev %p\n", sdev); + dev_dbg(&sdev->udev->dev, "free sdev %p\n", sdev); while ((priv = stub_priv_pop(sdev))) { struct urb *urb = priv->urb; - usbip_udbg(" free urb %p\n", urb); + dev_dbg(&sdev->udev->dev, "free urb %p\n", urb); usb_kill_urb(urb); kmem_cache_free(stub_priv_cache, priv); @@ -265,20 +265,17 @@ static int __init usb_stub_init(void) SLAB_HWCACHE_ALIGN, NULL); if (!stub_priv_cache) { - printk(KERN_ERR KBUILD_MODNAME - ": create stub_priv_cache error\n"); + pr_err("create stub_priv_cache error\n"); return -ENOMEM; } ret = usb_register(&stub_driver); if (ret) { - printk(KERN_ERR KBUILD_MODNAME ": usb_register failed %d\n", - ret); + pr_err("usb_register failed %d\n", ret); goto error_usb_register; } - printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_DESC " " USBIP_VERSION - "\n"); + pr_info(DRIVER_DESC " " USBIP_VERSION "\n"); init_busid_table(); @@ -286,7 +283,7 @@ static int __init usb_stub_init(void) &driver_attr_match_busid); if (ret) { - printk(KERN_ERR KBUILD_MODNAME ": create driver sysfs\n"); + pr_err("create driver sysfs\n"); goto error_create_file; } diff --git a/drivers/staging/usbip/stub_rx.c b/drivers/staging/usbip/stub_rx.c index e245609..a5c1fa1 100644 --- a/drivers/staging/usbip/stub_rx.c +++ b/drivers/staging/usbip/stub_rx.c @@ -102,11 +102,11 @@ static int tweak_clear_halt_cmd(struct urb *urb) ret = usb_clear_halt(urb->dev, target_pipe); if (ret < 0) - usbip_uinfo("clear_halt error: devnum %d endp %d, %d\n", - urb->dev->devnum, target_endp, ret); + dev_err(&urb->dev->dev, "usb_clear_halt error: devnum %d endp " + "%d ret %d\n", urb->dev->devnum, target_endp, ret); else - usbip_uinfo("clear_halt done: devnum %d endp %d\n", - urb->dev->devnum, target_endp); + dev_info(&urb->dev->dev, "usb_clear_halt done: devnum %d endp " + "%d\n", urb->dev->devnum, target_endp); return ret; } @@ -127,11 +127,11 @@ static int tweak_set_interface_cmd(struct urb *urb) ret = usb_set_interface(urb->dev, interface, alternate); if (ret < 0) - usbip_uinfo("set_interface error: inf %u alt %u, %d\n", - interface, alternate, ret); + dev_err(&urb->dev->dev, "usb_set_interface error: inf %u alt " + "%u ret %d\n", interface, alternate, ret); else - usbip_uinfo("set_interface done: inf %u alt %u\n", - interface, alternate); + dev_info(&urb->dev->dev, "usb_set_interface done: inf %u alt " + "%u\n", interface, alternate); return ret; } @@ -160,9 +160,8 @@ static int tweak_set_configuration_cmd(struct urb *urb) * A user may need to set a special configuration value before * exporting the device. */ - usbip_uinfo("set_configuration %d to %s\n", - config, dev_name(&urb->dev->dev)); - usbip_uinfo("but, skip!\n"); + dev_info(&urb->dev->dev, "usb_set_configuration %d to %s... skip!\n", + config, dev_name(&urb->dev->dev)); return 0; /* return usb_driver_set_configuration(urb->dev, config); */ @@ -173,7 +172,7 @@ static int tweak_reset_device_cmd(struct urb *urb) struct stub_priv *priv = (struct stub_priv *) urb->context; struct stub_device *sdev = priv->sdev; - usbip_uinfo("reset_device %s\n", dev_name(&urb->dev->dev)); + dev_info(&urb->dev->dev, "usb_queue_reset_device\n"); /* * usb_lock_device_for_reset caused a deadlock: it causes the driver diff --git a/drivers/staging/usbip/stub_tx.c b/drivers/staging/usbip/stub_tx.c index 3c332c2..fda2bc9 100644 --- a/drivers/staging/usbip/stub_tx.c +++ b/drivers/staging/usbip/stub_tx.c @@ -75,22 +75,23 @@ void stub_complete(struct urb *urb) /* OK */ break; case -ENOENT: - usbip_uinfo("stopped by a call of usb_kill_urb() because of" - "cleaning up a virtual connection\n"); + dev_info(&urb->dev->dev, "stopped by a call to usb_kill_urb() " + "because of cleaning up a virtual connection\n"); return; case -ECONNRESET: - usbip_uinfo("unlinked by a call of usb_unlink_urb()\n"); + dev_info(&urb->dev->dev, "unlinked by a call to " + "usb_unlink_urb()\n"); break; case -EPIPE: - usbip_uinfo("endpoint %d is stalled\n", - usb_pipeendpoint(urb->pipe)); + dev_info(&urb->dev->dev, "endpoint %d is stalled\n", + usb_pipeendpoint(urb->pipe)); break; case -ESHUTDOWN: - usbip_uinfo("device removed?\n"); + dev_info(&urb->dev->dev, "device removed?\n"); break; default: - usbip_uinfo("urb completion with non-zero status %d\n", - urb->status); + dev_info(&urb->dev->dev, "urb completion with non-zero status " + "%d\n", urb->status); break; } diff --git a/drivers/staging/usbip/usbip_common.c b/drivers/staging/usbip/usbip_common.c index 68f5106..433a3b6 100644 --- a/drivers/staging/usbip/usbip_common.c +++ b/drivers/staging/usbip/usbip_common.c @@ -56,7 +56,7 @@ DEVICE_ATTR(usbip_debug, (S_IRUGO | S_IWUSR), show_flag, store_flag); static void usbip_dump_buffer(char *buff, int bufflen) { - print_hex_dump(KERN_DEBUG, "usb-ip", DUMP_PREFIX_OFFSET, 16, 4, + print_hex_dump(KERN_DEBUG, "usbip-core", DUMP_PREFIX_OFFSET, 16, 4, buff, bufflen, false); } @@ -67,30 +67,25 @@ static void usbip_dump_pipe(unsigned int p) unsigned char dev = usb_pipedevice(p); unsigned char dir = usb_pipein(p); - printk(KERN_DEBUG "dev(%d) ", dev); - printk(KERN_DEBUG "ep(%d) ", ep); - printk(KERN_DEBUG "%s ", dir ? "IN" : "OUT"); + pr_debug("dev(%d) ep(%d) [%s] ", dev, ep, dir ? "IN" : "OUT"); switch (type) { case PIPE_ISOCHRONOUS: - printk(KERN_DEBUG "%s ", "ISO"); + pr_debug("ISO\n"); break; case PIPE_INTERRUPT: - printk(KERN_DEBUG "%s ", "INT"); + pr_debug("INT\n"); break; case PIPE_CONTROL: - printk(KERN_DEBUG "%s ", "CTL"); + pr_debug("CTRL\n"); break; case PIPE_BULK: - printk(KERN_DEBUG "%s ", "BLK"); + pr_debug("BULK\n"); break; default: - printk(KERN_DEBUG "ERR"); + pr_debug("ERR\n"); break; } - - printk(KERN_DEBUG "\n"); - } static void usbip_dump_usb_device(struct usb_device *udev) @@ -98,61 +93,59 @@ static void usbip_dump_usb_device(struct usb_device *udev) struct device *dev = &udev->dev; int i; - dev_dbg(dev, " devnum(%d) devpath(%s)", + dev_dbg(dev, " devnum(%d) devpath(%s) ", udev->devnum, udev->devpath); switch (udev->speed) { case USB_SPEED_HIGH: - printk(KERN_DEBUG " SPD_HIGH"); + pr_debug("SPD_HIGH "); break; case USB_SPEED_FULL: - printk(KERN_DEBUG " SPD_FULL"); + pr_debug("SPD_FULL "); break; case USB_SPEED_LOW: - printk(KERN_DEBUG " SPD_LOW"); + pr_debug("SPD_LOW "); break; case USB_SPEED_UNKNOWN: - printk(KERN_DEBUG " SPD_UNKNOWN"); + pr_debug("SPD_UNKNOWN "); break; default: - printk(KERN_DEBUG " SPD_ERROR"); + pr_debug("SPD_ERROR "); break; } - printk(KERN_DEBUG " tt %p, ttport %d", udev->tt, udev->ttport); - printk(KERN_DEBUG "\n"); + pr_debug("tt %p, ttport %d\n", udev->tt, udev->ttport); dev_dbg(dev, " "); for (i = 0; i < 16; i++) - printk(KERN_DEBUG " %2u", i); - printk(KERN_DEBUG "\n"); + pr_debug(" %2u", i); + pr_debug("\n"); dev_dbg(dev, " toggle0(IN) :"); for (i = 0; i < 16; i++) - printk(KERN_DEBUG " %2u", (udev->toggle[0] & (1 << i)) ? 1 : 0); - printk(KERN_DEBUG "\n"); + pr_debug(" %2u", (udev->toggle[0] & (1 << i)) ? 1 : 0); + pr_debug("\n"); dev_dbg(dev, " toggle1(OUT):"); for (i = 0; i < 16; i++) - printk(KERN_DEBUG " %2u", (udev->toggle[1] & (1 << i)) ? 1 : 0); - printk(KERN_DEBUG "\n"); - + pr_debug(" %2u", (udev->toggle[1] & (1 << i)) ? 1 : 0); + pr_debug("\n"); dev_dbg(dev, " epmaxp_in :"); for (i = 0; i < 16; i++) { if (udev->ep_in[i]) - printk(KERN_DEBUG " %2u", - le16_to_cpu(udev->ep_in[i]->desc.wMaxPacketSize)); + pr_debug(" %2u", + le16_to_cpu(udev->ep_in[i]->desc.wMaxPacketSize)); } - printk(KERN_DEBUG "\n"); + pr_debug("\n"); dev_dbg(dev, " epmaxp_out :"); for (i = 0; i < 16; i++) { if (udev->ep_out[i]) - printk(KERN_DEBUG " %2u", - le16_to_cpu(udev->ep_out[i]->desc.wMaxPacketSize)); + pr_debug(" %2u", + le16_to_cpu(udev->ep_out[i]->desc.wMaxPacketSize)); } - printk(KERN_DEBUG "\n"); + pr_debug("\n"); dev_dbg(dev, "parent %p, bus %p\n", udev->parent, udev->bus); @@ -171,19 +164,19 @@ static void usbip_dump_request_type(__u8 rt) { switch (rt & USB_RECIP_MASK) { case USB_RECIP_DEVICE: - printk(KERN_DEBUG "DEVICE"); + pr_debug("DEVICE"); break; case USB_RECIP_INTERFACE: - printk(KERN_DEBUG "INTERF"); + pr_debug("INTERF"); break; case USB_RECIP_ENDPOINT: - printk(KERN_DEBUG "ENDPOI"); + pr_debug("ENDPOI"); break; case USB_RECIP_OTHER: - printk(KERN_DEBUG "OTHER "); + pr_debug("OTHER "); break; default: - printk(KERN_DEBUG "------"); + pr_debug("------"); break; } } @@ -191,73 +184,64 @@ static void usbip_dump_request_type(__u8 rt) static void usbip_dump_usb_ctrlrequest(struct usb_ctrlrequest *cmd) { if (!cmd) { - printk(KERN_DEBUG " %s : null pointer\n", __func__); + pr_debug(" : null pointer\n"); return; } - printk(KERN_DEBUG " "); - printk(KERN_DEBUG "bRequestType(%02X) ", cmd->bRequestType); - printk(KERN_DEBUG "bRequest(%02X) " , cmd->bRequest); - printk(KERN_DEBUG "wValue(%04X) ", cmd->wValue); - printk(KERN_DEBUG "wIndex(%04X) ", cmd->wIndex); - printk(KERN_DEBUG "wLength(%04X) ", cmd->wLength); - - printk(KERN_DEBUG "\n "); + pr_debug(" "); + pr_debug("bRequestType(%02X) bRequest(%02X) wValue(%04X) wIndex(%04X) " + "wLength(%04X) ", cmd->bRequestType, cmd->bRequest, + cmd->wValue, cmd->wIndex, cmd->wLength); + pr_debug("\n "); if ((cmd->bRequestType & USB_TYPE_MASK) == USB_TYPE_STANDARD) { - printk(KERN_DEBUG "STANDARD "); + pr_debug("STANDARD "); switch (cmd->bRequest) { case USB_REQ_GET_STATUS: - printk(KERN_DEBUG "GET_STATUS"); + pr_debug("GET_STATUS\n"); break; case USB_REQ_CLEAR_FEATURE: - printk(KERN_DEBUG "CLEAR_FEAT"); + pr_debug("CLEAR_FEAT\n"); break; case USB_REQ_SET_FEATURE: - printk(KERN_DEBUG "SET_FEAT "); + pr_debug("SET_FEAT \n"); break; case USB_REQ_SET_ADDRESS: - printk(KERN_DEBUG "SET_ADDRRS"); + pr_debug("SET_ADDRRS\n"); break; case USB_REQ_GET_DESCRIPTOR: - printk(KERN_DEBUG "GET_DESCRI"); + pr_debug("GET_DESCRI\n"); break; case USB_REQ_SET_DESCRIPTOR: - printk(KERN_DEBUG "SET_DESCRI"); + pr_debug("SET_DESCRI\n"); break; case USB_REQ_GET_CONFIGURATION: - printk(KERN_DEBUG "GET_CONFIG"); + pr_debug("GET_CONFIG\n"); break; case USB_REQ_SET_CONFIGURATION: - printk(KERN_DEBUG "SET_CONFIG"); + pr_debug("SET_CONFIG\n"); break; case USB_REQ_GET_INTERFACE: - printk(KERN_DEBUG "GET_INTERF"); + pr_debug("GET_INTERF\n"); break; case USB_REQ_SET_INTERFACE: - printk(KERN_DEBUG "SET_INTERF"); + pr_debug("SET_INTERF\n"); break; case USB_REQ_SYNCH_FRAME: - printk(KERN_DEBUG "SYNC_FRAME"); + pr_debug("SYNC_FRAME\n"); break; default: - printk(KERN_DEBUG "REQ(%02X) ", cmd->bRequest); + pr_debug("REQ(%02X) \n", cmd->bRequest); break; } - - printk(KERN_DEBUG " "); usbip_dump_request_type(cmd->bRequestType); - - } else if ((cmd->bRequestType & USB_TYPE_MASK) == USB_TYPE_CLASS) - printk(KERN_DEBUG "CLASS "); - - else if ((cmd->bRequestType & USB_TYPE_MASK) == USB_TYPE_VENDOR) - printk(KERN_DEBUG "VENDOR "); - - else if ((cmd->bRequestType & USB_TYPE_MASK) == USB_TYPE_RESERVED) - printk(KERN_DEBUG "RESERVED"); - - printk(KERN_DEBUG "\n"); + } else if ((cmd->bRequestType & USB_TYPE_MASK) == USB_TYPE_CLASS) { + pr_debug("CLASS \n"); + } else if ((cmd->bRequestType & USB_TYPE_MASK) == USB_TYPE_VENDOR) { + pr_debug("VENDOR \n"); + } else if ((cmd->bRequestType & USB_TYPE_MASK) == USB_TYPE_RESERVED) { + pr_debug("RESERVED\n"); + } } void usbip_dump_urb(struct urb *urb) @@ -265,16 +249,15 @@ void usbip_dump_urb(struct urb *urb) struct device *dev; if (!urb) { - printk(KERN_DEBUG KBUILD_MODNAME - ":%s: urb: null pointer!!\n", __func__); + pr_debug("urb: null pointer!!\n"); return; } if (!urb->dev) { - printk(KERN_DEBUG KBUILD_MODNAME - ":%s: urb->dev: null pointer!!\n", __func__); + pr_debug("urb->dev: null pointer!!\n"); return; } + dev = &urb->dev->dev; dev_dbg(dev, " urb :%p\n", urb); @@ -309,39 +292,42 @@ EXPORT_SYMBOL_GPL(usbip_dump_urb); void usbip_dump_header(struct usbip_header *pdu) { - usbip_udbg("BASE: cmd %u seq %u devid %u dir %u ep %u\n", - pdu->base.command, - pdu->base.seqnum, - pdu->base.devid, - pdu->base.direction, - pdu->base.ep); + pr_debug("BASE: cmd %u seq %u devid %u dir %u ep %u\n", + pdu->base.command, + pdu->base.seqnum, + pdu->base.devid, + pdu->base.direction, + pdu->base.ep); switch (pdu->base.command) { case USBIP_CMD_SUBMIT: - usbip_udbg("CMD_SUBMIT: " - "x_flags %u x_len %u sf %u #p %u iv %u\n", - pdu->u.cmd_submit.transfer_flags, - pdu->u.cmd_submit.transfer_buffer_length, - pdu->u.cmd_submit.start_frame, - pdu->u.cmd_submit.number_of_packets, - pdu->u.cmd_submit.interval); + pr_debug("USBIP_CMD_SUBMIT: " + "x_flags %u x_len %u sf %u #p %d iv %d\n", + pdu->u.cmd_submit.transfer_flags, + pdu->u.cmd_submit.transfer_buffer_length, + pdu->u.cmd_submit.start_frame, + pdu->u.cmd_submit.number_of_packets, + pdu->u.cmd_submit.interval); break; case USBIP_CMD_UNLINK: - usbip_udbg("CMD_UNLINK: seq %u\n", pdu->u.cmd_unlink.seqnum); + pr_debug("USBIP_CMD_UNLINK: seq %u\n", + pdu->u.cmd_unlink.seqnum); break; case USBIP_RET_SUBMIT: - usbip_udbg("RET_SUBMIT: st %d al %u sf %d #p %d ec %d\n", - pdu->u.ret_submit.status, - pdu->u.ret_submit.actual_length, - pdu->u.ret_submit.start_frame, - pdu->u.ret_submit.number_of_packets, - pdu->u.ret_submit.error_count); + pr_debug("USBIP_RET_SUBMIT: st %d al %u sf %d #p %d ec %d\n", + pdu->u.ret_submit.status, + pdu->u.ret_submit.actual_length, + pdu->u.ret_submit.start_frame, + pdu->u.ret_submit.number_of_packets, + pdu->u.ret_submit.error_count); + break; case USBIP_RET_UNLINK: - usbip_udbg("RET_UNLINK: status %d\n", pdu->u.ret_unlink.status); + pr_debug("USBIP_RET_UNLINK: status %d\n", + pdu->u.ret_unlink.status); break; default: /* NOT REACHED */ - usbip_udbg("unknown command\n"); + pr_err("unknown command\n"); break; } } @@ -363,21 +349,20 @@ int usbip_xmit(int send, struct socket *sock, char *buf, usbip_dbg_xmit("enter\n"); if (!sock || !buf || !size) { - printk(KERN_ERR "%s: invalid arg, sock %p buff %p size %d\n", - __func__, sock, buf, size); + pr_err("invalid arg, sock %p buff %p size %d\n", sock, buf, + size); return -EINVAL; } if (usbip_dbg_flag_xmit) { if (send) { if (!in_interrupt()) - printk(KERN_DEBUG "%-10s:", current->comm); + pr_debug("%-10s:", current->comm); else - printk(KERN_DEBUG "interrupt :"); + pr_debug("interrupt :"); - printk(KERN_DEBUG "%s: sending... , sock %p, buf %p, " - "size %d, msg_flags %d\n", __func__, - sock, buf, size, msg_flags); + pr_debug("sending... , sock %p, buf %p, size %d, " + "msg_flags %d\n", sock, buf, size, msg_flags); usbip_dump_buffer(buf, size); } } @@ -400,9 +385,9 @@ int usbip_xmit(int send, struct socket *sock, char *buf, MSG_WAITALL); if (result <= 0) { - usbip_udbg("usbip_xmit: %s sock %p buf %p size %u ret " - "%d total %d\n", send ? "send" : "receive", - sock, buf, size, result, total); + pr_debug("%s sock %p buf %p size %u ret %d total %d\n", + send ? "send" : "receive", sock, buf, size, + result, total); goto err; } @@ -415,20 +400,18 @@ int usbip_xmit(int send, struct socket *sock, char *buf, if (usbip_dbg_flag_xmit) { if (!send) { if (!in_interrupt()) - printk(KERN_DEBUG "%-10s:", current->comm); + pr_debug("%-10s:", current->comm); else - printk(KERN_DEBUG "interrupt :"); + pr_debug("interrupt :"); - printk(KERN_DEBUG "usbip_xmit: receiving....\n"); + pr_debug("receiving....\n"); usbip_dump_buffer(bp, osize); - printk(KERN_DEBUG "usbip_xmit: received, osize %d ret " - "%d size %d total %d\n", osize, result, size, - total); + pr_debug("received, osize %d ret %d size %d total %d\n", + osize, result, size, total); } if (send) - printk(KERN_DEBUG "usbip_xmit: send, total %d\n", - total); + pr_debug("send, total %d\n", total); } return total; @@ -446,7 +429,7 @@ struct socket *sockfd_to_socket(unsigned int sockfd) file = fget(sockfd); if (!file) { - printk(KERN_ERR "%s: invalid sockfd\n", __func__); + pr_err("invalid sockfd\n"); return NULL; } @@ -532,8 +515,7 @@ void usbip_pack_pdu(struct usbip_header *pdu, struct urb *urb, int cmd, break; default: /* NOT REACHED */ - err("unknown command"); - /* BUG(); */ + pr_err("unknown command\n"); break; } } @@ -639,8 +621,7 @@ void usbip_header_correct_endian(struct usbip_header *pdu, int send) break; default: /* NOT REACHED */ - err("unknown command in pdu header: %d", cmd); - /* BUG(); */ + pr_err("unknown command\n"); break; } } @@ -722,7 +703,7 @@ int usbip_recv_iso(struct usbip_device *ud, struct urb *urb) /* my Bluetooth dongle gets ISO URBs which are np = 0 */ if (np == 0) { - /* usbip_uinfo("iso np == 0\n"); */ + /* pr_info("iso np == 0\n"); */ /* usbip_dump_urb(urb); */ return 0; } @@ -860,8 +841,7 @@ EXPORT_SYMBOL_GPL(usbip_recv_xbuff); static int __init usbip_common_init(void) { - printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_DESC " " USBIP_VERSION - "\n"); + pr_info(DRIVER_DESC " v" USBIP_VERSION "\n"); return 0; } diff --git a/drivers/staging/usbip/usbip_common.h b/drivers/staging/usbip/usbip_common.h index fd84ab2..4a641c5 100644 --- a/drivers/staging/usbip/usbip_common.h +++ b/drivers/staging/usbip/usbip_common.h @@ -32,25 +32,13 @@ #define USBIP_VERSION "1.0.0" -/** - * usbip_udbg - print debug messages if CONFIG_USB_IP_DEBUG is defined - * @fmt: - * @args: - */ -#ifdef CONFIG_USB_IP_DEBUG - -#define usbip_udbg(fmt, args...) \ - do { \ - printk(KERN_DEBUG "%-10s:(%s,%d) %s: " fmt, \ - (in_interrupt() ? "interrupt" : (current)->comm),\ - __FILE__, __LINE__, __func__, ##args); \ - } while (0) +#undef pr_fmt +#ifdef DEBUG +#define pr_fmt(fmt) KBUILD_MODNAME ": %s:%d: " fmt, __func__, __LINE__ #else - -#define usbip_udbg(fmt, args...) do { } while (0) - -#endif /* CONFIG_USB_IP_DEBUG */ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#endif enum { usbip_debug_xmit = (1 << 0), @@ -85,7 +73,7 @@ extern struct device_attribute dev_attr_usbip_debug; #define usbip_dbg_with_flag(flag, fmt, args...) \ do { \ if (flag & usbip_debug_flag) \ - usbip_udbg(fmt , ##args); \ + pr_debug(fmt, ##args); \ } while (0) #define usbip_dbg_sysfs(fmt, args...) \ @@ -115,28 +103,6 @@ extern struct device_attribute dev_attr_usbip_debug; #define usbip_dbg_stub_tx(fmt, args...) \ usbip_dbg_with_flag(usbip_debug_stub_tx, fmt , ##args) -/** - * usbip_uerr - print error messages - * @fmt: - * @args: - */ -#define usbip_uerr(fmt, args...) \ - do { \ - printk(KERN_ERR "%-10s: ***ERROR*** (%s,%d) %s: " fmt, \ - (in_interrupt() ? "interrupt" : (current)->comm),\ - __FILE__, __LINE__, __func__, ##args); \ - } while (0) - -/** - * usbip_uinfo - print information messages - * @fmt: - * @args: - */ -#define usbip_uinfo(fmt, args...) \ - do { \ - printk(KERN_INFO "usbip: " fmt , ## args); \ - } while (0) - /* * USB/IP request headers. * Currently, we define 4 request types: diff --git a/drivers/staging/usbip/usbip_event.c b/drivers/staging/usbip/usbip_event.c index da6074d..ecd1862 100644 --- a/drivers/staging/usbip/usbip_event.c +++ b/drivers/staging/usbip/usbip_event.c @@ -84,8 +84,7 @@ int usbip_start_eh(struct usbip_device *ud) ud->eh = kthread_run(event_handler_loop, ud, "usbip_eh"); if (IS_ERR(ud->eh)) { - printk(KERN_WARNING - "Unable to start control thread\n"); + pr_warning("Unable to start control thread\n"); return PTR_ERR(ud->eh); } diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c index 0864b27..a76e8fa 100644 --- a/drivers/staging/usbip/vhci_hcd.c +++ b/drivers/staging/usbip/vhci_hcd.c @@ -96,12 +96,12 @@ static void dump_port_status(u32 status) { int i = 0; - printk(KERN_DEBUG "status %08x:", status); + pr_debug("status %08x:", status); for (i = 0; i < 32; i++) { if (status & (1 << i)) - printk(KERN_DEBUG " %s", bit_desc[i]); + pr_debug(" %s", bit_desc[i]); } - printk(KERN_DEBUG "\n"); + pr_debug("\n"); } void rh_port_connect(int rhport, enum usb_device_speed speed) @@ -216,7 +216,7 @@ static int vhci_hub_status(struct usb_hcd *hcd, char *buf) } } - usbip_uinfo("changed %d\n", changed); + pr_info("changed %d\n", changed); if (hcd->state == HC_STATE_SUSPENDED) usb_hcd_resume_root_hub(hcd); @@ -264,8 +264,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 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); + pr_err("invalid port number %d\n", wIndex); rhport = ((__u8)(wIndex & 0x00ff)) - 1; dum = hcd_to_vhci(hcd); @@ -334,8 +333,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, case GetPortStatus: 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); + pr_err("invalid port number %d\n", wIndex); retval = -EPIPE; } @@ -345,7 +343,6 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, * complete it!! * */ if (dum->resuming && time_after(jiffies, dum->re_timeout)) { - printk(KERN_ERR "%s: not yet\n", __func__); dum->port_status[rhport] |= (1 << USB_PORT_FEAT_C_SUSPEND); dum->port_status[rhport] &= @@ -415,7 +412,6 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, case USB_PORT_FEAT_SUSPEND: usbip_dbg_vhci_rh(" SetPortFeature: " "USB_PORT_FEAT_SUSPEND\n"); - printk(KERN_ERR "%s: not yet\n", __func__); #if 0 dum->port_status[rhport] |= (1 << USB_PORT_FEAT_SUSPEND); @@ -457,7 +453,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, break; default: - printk(KERN_ERR "%s: default: no such request\n", __func__); + pr_err("default: no such request\n"); /* dev_dbg (hardware, * "hub control req%04x v%04x i%04x l%d\n", * typeReq, wValue, wIndex, wLength); */ @@ -467,7 +463,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, } if (usbip_dbg_flag_vhci_rh) { - printk(KERN_DEBUG "port %d\n", rhport); + pr_debug("port %d\n", rhport); dump_port_status(prev_port_status[rhport]); dump_port_status(dum->port_status[rhport]); } @@ -499,7 +495,7 @@ static void vhci_tx_urb(struct urb *urb) unsigned long flag; if (!vdev) { - err("could not get virtual device"); + pr_err("could not get virtual device"); /* BUG(); */ return; } @@ -517,7 +513,7 @@ static void vhci_tx_urb(struct urb *urb) priv->seqnum = atomic_inc_return(&the_controller->seqnum); if (priv->seqnum == 0xffff) - usbip_uinfo("seqnum max\n"); + dev_info(&urb->dev->dev, "seqnum max\n"); priv->vdev = vdev; priv->urb = urb; @@ -558,7 +554,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, spin_lock(&vdev->ud.lock); if (vdev->ud.status == VDEV_ST_NULL || vdev->ud.status == VDEV_ST_ERROR) { - usbip_uerr("enqueue for inactive port %d\n", vdev->rhport); + dev_err(dev, "enqueue for inactive port %d\n", vdev->rhport); spin_unlock(&vdev->ud.lock); spin_unlock_irqrestore(&the_controller->lock, flags); return -ENODEV; @@ -701,7 +697,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) struct vhci_priv *priv; struct vhci_device *vdev; - usbip_uinfo("vhci_hcd: dequeue a urb %p\n", urb); + pr_info("dequeue a urb %p\n", urb); spin_lock_irqsave(&the_controller->lock, flags); @@ -731,8 +727,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) spin_lock_irqsave(&vdev->priv_lock, flags2); - usbip_uinfo("vhci_hcd: device %p seems to be disconnected\n", - vdev); + pr_info("device %p seems to be disconnected\n", vdev); list_del(&priv->list); kfree(priv); urb->hcpriv = NULL; @@ -744,8 +739,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) * 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); + pr_info("gives back urb %p\n", urb); usb_hcd_unlink_urb_from_ep(hcd, urb); @@ -764,7 +758,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) { - usbip_uerr("malloc vhci_unlink\n"); + pr_err("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); @@ -773,12 +767,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) - usbip_uinfo("seqnum max\n"); + pr_info("seqnum max\n"); unlink->unlink_seqnum = priv->seqnum; - usbip_uinfo("vhci_hcd: device %p seems to be still connected\n", - vdev); + pr_info("device %p seems to be still connected\n", vdev); /* send cmd_unlink and try to cancel the pending URB in the * peer */ @@ -801,7 +794,7 @@ static void vhci_device_unlink_cleanup(struct vhci_device *vdev) spin_lock(&vdev->priv_lock); list_for_each_entry_safe(unlink, tmp, &vdev->unlink_tx, list) { - usbip_uinfo("unlink cleanup tx %lu\n", unlink->unlink_seqnum); + pr_info("unlink cleanup tx %lu\n", unlink->unlink_seqnum); list_del(&unlink->list); kfree(unlink); } @@ -810,12 +803,12 @@ static void vhci_device_unlink_cleanup(struct vhci_device *vdev) struct urb *urb; /* give back URB of unanswered unlink request */ - usbip_uinfo("unlink cleanup rx %lu\n", unlink->unlink_seqnum); + pr_info("unlink cleanup rx %lu\n", unlink->unlink_seqnum); urb = pickup_urb_and_free_priv(vdev, unlink->unlink_seqnum); if (!urb) { - usbip_uinfo("the urb (seqnum %lu) was already given " - "back\n", unlink->unlink_seqnum); + pr_info("the urb (seqnum %lu) was already given back\n", + unlink->unlink_seqnum); list_del(&unlink->list); kfree(unlink); continue; @@ -848,7 +841,7 @@ static void vhci_shutdown_connection(struct usbip_device *ud) /* need this? see stub_dev.c */ if (ud->tcp_socket) { - usbip_udbg("shutdown tcp_socket %p\n", ud->tcp_socket); + pr_debug("shutdown tcp_socket %p\n", ud->tcp_socket); kernel_sock_shutdown(ud->tcp_socket, SHUT_RDWR); } @@ -858,14 +851,14 @@ static void vhci_shutdown_connection(struct usbip_device *ud) if (vdev->ud.tcp_tx) kthread_stop(vdev->ud.tcp_tx); - usbip_uinfo("stop threads\n"); + pr_info("stop threads\n"); /* active connection is closed */ if (vdev->ud.tcp_socket != NULL) { sock_release(vdev->ud.tcp_socket); vdev->ud.tcp_socket = NULL; } - usbip_uinfo("release socket\n"); + pr_info("release socket\n"); vhci_device_unlink_cleanup(vdev); @@ -891,7 +884,7 @@ static void vhci_shutdown_connection(struct usbip_device *ud) */ rh_port_disconnect(vdev->rhport); - usbip_uinfo("disconnect device\n"); + pr_info("disconnect device\n"); } @@ -972,7 +965,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) { - usbip_uerr("create sysfs files\n"); + pr_err("create sysfs files\n"); return err; } @@ -996,13 +989,11 @@ static void vhci_stop(struct usb_hcd *hcd) usbip_event_add(&vdev->ud, VDEV_EVENT_REMOVED); usbip_stop_eh(&vdev->ud); } - - usbip_uinfo("vhci_stop done\n"); } static int vhci_get_frame_number(struct usb_hcd *hcd) { - usbip_uerr("Not yet implemented\n"); + pr_err("Not yet implemented\n"); return 0; } @@ -1079,8 +1070,6 @@ static int vhci_hcd_probe(struct platform_device *pdev) struct usb_hcd *hcd; int ret; - usbip_uinfo("proving...\n"); - usbip_dbg_vhci_hc("name %s id %d\n", pdev->name, pdev->id); /* will be removed */ @@ -1095,7 +1084,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) { - usbip_uerr("create hcd failed\n"); + pr_err("create hcd failed\n"); return -ENOMEM; } hcd->has_tt = 1; @@ -1109,7 +1098,7 @@ static int vhci_hcd_probe(struct platform_device *pdev) */ ret = usb_add_hcd(hcd, 0, 0); if (ret != 0) { - usbip_uerr("usb_add_hcd failed %d\n", ret); + pr_err("usb_add_hcd failed %d\n", ret); usb_put_hcd(hcd); the_controller = NULL; return ret; @@ -1149,8 +1138,6 @@ static int vhci_hcd_suspend(struct platform_device *pdev, pm_message_t state) int connected = 0; int ret = 0; - dev_dbg(&pdev->dev, "%s\n", __func__); - hcd = platform_get_drvdata(pdev); spin_lock(&the_controller->lock); @@ -1163,11 +1150,11 @@ static int vhci_hcd_suspend(struct platform_device *pdev, pm_message_t state) spin_unlock(&the_controller->lock); if (connected > 0) { - usbip_uinfo("We have %d active connection%s. Do not suspend.\n", - connected, (connected == 1 ? "" : "s")); + dev_info(&pdev->dev, "We have %d active connection%s. Do not " + "suspend.\n", connected, (connected == 1 ? "" : "s")); ret = -EBUSY; } else { - usbip_uinfo("suspend vhci_hcd"); + dev_info(&pdev->dev, "suspend vhci_hcd"); clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); } @@ -1229,13 +1216,9 @@ static int __init vhci_init(void) { int ret; - usbip_dbg_vhci_hc("enter\n"); if (usb_disabled()) return -ENODEV; - printk(KERN_INFO KBUILD_MODNAME ": %s, %s\n", driver_name, - USBIP_VERSION); - ret = platform_driver_register(&vhci_driver); if (ret < 0) goto err_driver_register; @@ -1244,25 +1227,19 @@ static int __init vhci_init(void) if (ret < 0) goto err_platform_device_register; - usbip_dbg_vhci_hc("bye\n"); + pr_info(DRIVER_DESC " v" USBIP_VERSION "\n"); return ret; - /* error occurred */ err_platform_device_register: platform_driver_unregister(&vhci_driver); err_driver_register: - usbip_dbg_vhci_hc("bye\n"); return ret; } static void __exit vhci_cleanup(void) { - usbip_dbg_vhci_hc("enter\n"); - platform_device_unregister(&the_pdev); platform_driver_unregister(&vhci_driver); - - usbip_dbg_vhci_hc("bye\n"); } module_init(vhci_init); diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c index 2fe6cbf..e42ce9d 100644 --- a/drivers/staging/usbip/vhci_rx.c +++ b/drivers/staging/usbip/vhci_rx.c @@ -74,10 +74,9 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev, spin_unlock(&vdev->priv_lock); if (!urb) { - usbip_uerr("cannot find a urb of seqnum %u\n", - pdu->base.seqnum); - usbip_uinfo("max seqnum %d\n", - atomic_read(&the_controller->seqnum)); + pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum); + pr_info("max seqnum %d\n", + atomic_read(&the_controller->seqnum)); usbip_event_add(ud, VDEV_EVENT_ERROR_TCP); return; } @@ -121,7 +120,7 @@ static struct vhci_unlink *dequeue_pending_unlink(struct vhci_device *vdev, spin_lock(&vdev->priv_lock); list_for_each_entry_safe(unlink, tmp, &vdev->unlink_rx, list) { - usbip_uinfo("unlink->seqnum %lu\n", unlink->seqnum); + pr_info("unlink->seqnum %lu\n", unlink->seqnum); if (unlink->seqnum == pdu->base.seqnum) { usbip_dbg_vhci_rx("found pending unlink, %lu\n", unlink->seqnum); @@ -147,8 +146,8 @@ static void vhci_recv_ret_unlink(struct vhci_device *vdev, unlink = dequeue_pending_unlink(vdev, pdu); if (!unlink) { - usbip_uinfo("cannot find the pending unlink %u\n", - pdu->base.seqnum); + pr_info("cannot find the pending unlink %u\n", + pdu->base.seqnum); return; } @@ -162,14 +161,14 @@ static void vhci_recv_ret_unlink(struct vhci_device *vdev, * already received the result of its submit result and gave * back the URB. */ - usbip_uinfo("the urb (seqnum %d) was already given backed\n", - pdu->base.seqnum); + pr_info("the urb (seqnum %d) was already given backed\n", + pdu->base.seqnum); } else { usbip_dbg_vhci_rx("now giveback urb %p\n", urb); /* If unlink is succeed, status is -ECONNRESET */ urb->status = pdu->u.ret_unlink.status; - usbip_uinfo("%d\n", urb->status); + pr_info("urb->status %d\n", urb->status); spin_lock(&the_controller->lock); usb_hcd_unlink_urb_from_ep(vhci_to_hcd(the_controller), urb); @@ -210,26 +209,26 @@ static void vhci_rx_pdu(struct usbip_device *ud) ret = usbip_xmit(0, ud->tcp_socket, (char *) &pdu, sizeof(pdu), 0); if (ret < 0) { if (ret == -ECONNRESET) - usbip_uinfo("connection reset by peer\n"); + pr_info("connection reset by peer\n"); else if (ret == -EAGAIN) { /* ignore if connection was idle */ if (vhci_priv_tx_empty(vdev)) return; - usbip_uinfo("connection timed out with pending urbs\n"); + pr_info("connection timed out with pending urbs\n"); } else if (ret != -ERESTARTSYS) - usbip_uinfo("xmit failed %d\n", ret); + pr_info("xmit failed %d\n", ret); usbip_event_add(ud, VDEV_EVENT_ERROR_TCP); return; } if (ret == 0) { - usbip_uinfo("connection closed"); + pr_info("connection closed"); usbip_event_add(ud, VDEV_EVENT_DOWN); return; } if (ret != sizeof(pdu)) { - usbip_uerr("received pdu size is %d, should be %d\n", - ret, (unsigned int)sizeof(pdu)); + pr_err("received pdu size is %d, should be %d\n", ret, + (unsigned int)sizeof(pdu)); usbip_event_add(ud, VDEV_EVENT_ERROR_TCP); return; } @@ -248,7 +247,7 @@ static void vhci_rx_pdu(struct usbip_device *ud) break; default: /* NOT REACHED */ - usbip_uerr("unknown pdu %u\n", pdu.base.command); + pr_err("unknown pdu %u\n", pdu.base.command); usbip_dump_header(&pdu); usbip_event_add(ud, VDEV_EVENT_ERROR_TCP); break; diff --git a/drivers/staging/usbip/vhci_sysfs.c b/drivers/staging/usbip/vhci_sysfs.c index 83f61ed..d9736f9 100644 --- a/drivers/staging/usbip/vhci_sysfs.c +++ b/drivers/staging/usbip/vhci_sysfs.c @@ -89,7 +89,7 @@ static int vhci_port_disconnect(__u32 rhport) spin_lock(&vdev->ud.lock); if (vdev->ud.status == VDEV_ST_NULL) { - usbip_uerr("not connected %d\n", vdev->ud.status); + pr_err("not connected %d\n", vdev->ud.status); /* unlock */ spin_unlock(&vdev->ud.lock); @@ -117,7 +117,7 @@ static ssize_t store_detach(struct device *dev, struct device_attribute *attr, /* check rhport */ if (rhport >= VHCI_NPORTS) { - usbip_uerr("invalid port %u\n", rhport); + dev_err(dev, "invalid port %u\n", rhport); return -EINVAL; } @@ -136,7 +136,7 @@ static int valid_args(__u32 rhport, enum usb_device_speed speed) { /* check rhport */ if ((rhport < 0) || (rhport >= VHCI_NPORTS)) { - usbip_uerr("port %u\n", rhport); + pr_err("port %u\n", rhport); return -EINVAL; } @@ -148,7 +148,7 @@ static int valid_args(__u32 rhport, enum usb_device_speed speed) case USB_SPEED_WIRELESS: break; default: - usbip_uerr("speed %d\n", speed); + pr_err("speed %d\n", speed); return -EINVAL; } @@ -206,12 +206,12 @@ static ssize_t store_attach(struct device *dev, struct device_attribute *attr, spin_unlock(&vdev->ud.lock); spin_unlock(&the_controller->lock); - usbip_uerr("port %d already used\n", rhport); + dev_err(dev, "port %d already used\n", rhport); return -EINVAL; } - usbip_uinfo("rhport(%u) sockfd(%d) devid(%u) speed(%u)\n", - rhport, sockfd, devid, speed); + dev_info(dev, "rhport(%u) sockfd(%d) devid(%u) speed(%u)\n", + rhport, sockfd, devid, speed); vdev->devid = devid; vdev->speed = speed; diff --git a/drivers/staging/usbip/vhci_tx.c b/drivers/staging/usbip/vhci_tx.c index c1aa03b..9b437e7 100644 --- a/drivers/staging/usbip/vhci_tx.c +++ b/drivers/staging/usbip/vhci_tx.c @@ -118,8 +118,8 @@ static int vhci_send_cmd_submit(struct vhci_device *vdev) ret = kernel_sendmsg(vdev->ud.tcp_socket, &msg, iov, 3, txsize); if (ret != txsize) { - usbip_uerr("sendmsg failed!, retval %d for %zd\n", ret, - txsize); + pr_err("sendmsg failed!, ret=%d for %zd\n", ret, + txsize); kfree(iso_buffer); usbip_event_add(&vdev->ud, VDEV_EVENT_ERROR_TCP); return -1; @@ -188,8 +188,8 @@ static int vhci_send_cmd_unlink(struct vhci_device *vdev) ret = kernel_sendmsg(vdev->ud.tcp_socket, &msg, iov, 1, txsize); if (ret != txsize) { - usbip_uerr("sendmsg failed!, retval %d for %zd\n", ret, - txsize); + pr_err("sendmsg failed!, ret=%d for %zd\n", ret, + txsize); usbip_event_add(&vdev->ud, VDEV_EVENT_ERROR_TCP); return -1; } -- 1.7.5.1 ^ permalink raw reply related [flat|nested] 42+ messages in thread
* [PATCH 01/12] staging: usbip: replace usbip_u{dbg,err,info} and printk with dev_ and pr_ @ 2011-05-20 4:36 ` matt mooney 0 siblings, 0 replies; 42+ messages in thread From: matt mooney @ 2011-05-20 4:36 UTC (permalink / raw) To: Greg Kroah-Hartman; +Cc: linux-kernel, kernel-janitors This switches all of the usbip_u{dbg,err,info} and printk statements to dev_<level>, if possible, or pr_<level> macros. And removes a few unnecessary debug statements. Signed-off-by: matt mooney <mfm@muteddisk.com> --- drivers/staging/usbip/stub_dev.c | 44 +++---- drivers/staging/usbip/stub_main.c | 19 ++-- drivers/staging/usbip/stub_rx.c | 23 ++-- drivers/staging/usbip/stub_tx.c | 17 ++-- drivers/staging/usbip/usbip_common.c | 230 +++++++++++++++------------------ drivers/staging/usbip/usbip_common.h | 46 +------ drivers/staging/usbip/usbip_event.c | 3 +- drivers/staging/usbip/vhci_hcd.c | 89 +++++-------- drivers/staging/usbip/vhci_rx.c | 33 +++--- drivers/staging/usbip/vhci_sysfs.c | 14 +- drivers/staging/usbip/vhci_tx.c | 8 +- 11 files changed, 220 insertions(+), 306 deletions(-) diff --git a/drivers/staging/usbip/stub_dev.c b/drivers/staging/usbip/stub_dev.c index c71d0a3..6e99ec8 100644 --- a/drivers/staging/usbip/stub_dev.c +++ b/drivers/staging/usbip/stub_dev.c @@ -196,7 +196,8 @@ static void stub_shutdown_connection(struct usbip_device *ud) * step 1? */ if (ud->tcp_socket) { - usbip_udbg("shutdown tcp_socket %p\n", ud->tcp_socket); + dev_dbg(&sdev->udev->dev, "shutdown tcp_socket %p\n", + ud->tcp_socket); kernel_sock_shutdown(ud->tcp_socket, SHUT_RDWR); } @@ -244,12 +245,11 @@ static void stub_device_reset(struct usbip_device *ud) struct usb_device *udev = sdev->udev; int ret; - usbip_udbg("device reset"); + dev_dbg(&udev->dev, "device reset"); ret = usb_lock_device_for_reset(udev, sdev->interface); if (ret < 0) { dev_err(&udev->dev, "lock for reset\n"); - spin_lock(&ud->lock); ud->status = SDEV_ST_ERROR; spin_unlock(&ud->lock); @@ -336,7 +336,8 @@ static struct stub_device *stub_device_alloc(struct usb_device *udev, usbip_start_eh(&sdev->ud); - usbip_udbg("register new interface\n"); + dev_dbg(&interface->dev, "register new interface\n"); + return sdev; } @@ -346,7 +347,7 @@ static int stub_device_free(struct stub_device *sdev) return -EINVAL; kfree(sdev); - usbip_udbg("kfree udev ok\n"); + pr_debug("kfree udev ok\n"); return 0; } @@ -376,9 +377,8 @@ static int stub_probe(struct usb_interface *interface, busid_priv = get_busid_priv(udev_busid); if (!busid_priv || (busid_priv->status = STUB_BUSID_REMOV) || (busid_priv->status = STUB_BUSID_OTHER)) { - dev_info(&interface->dev, - "this device %s is not in match_busid table. skip!\n", - udev_busid); + dev_info(&interface->dev, "%s is not in match_busid table... " + "skip!\n", udev_busid); /* * Return value should be ENODEV or ENOXIO to continue trying @@ -388,15 +388,15 @@ static int stub_probe(struct usb_interface *interface, return -ENODEV; } - if (udev->descriptor.bDeviceClass = USB_CLASS_HUB) { - usbip_udbg("this device %s is a usb hub device. skip!\n", - udev_busid); + if (udev->descriptor.bDeviceClass = USB_CLASS_HUB) { + dev_dbg(&udev->dev, "%s is a usb hub device... skip!\n", + udev_busid); return -ENODEV; } if (!strcmp(udev->bus->bus_name, "vhci_hcd")) { - usbip_udbg("this device %s is attached on vhci_hcd. skip!\n", - udev_busid); + dev_dbg(&udev->dev, "%s is attached on vhci_hcd... skip!\n", + udev_busid); return -ENODEV; } @@ -406,8 +406,7 @@ static int stub_probe(struct usb_interface *interface, return -ENODEV; busid_priv->interf_count++; - dev_info(&interface->dev, - "USB/IP Stub: register a new interface " + dev_info(&interface->dev, "usbip-host: register new interface " "(bus %u dev %u ifn %u)\n", udev->bus->busnum, udev->devnum, interface->cur_altsetting->desc.bInterfaceNumber); @@ -417,7 +416,7 @@ static int stub_probe(struct usb_interface *interface, err = stub_add_files(&interface->dev); if (err) { - dev_err(&interface->dev, "create sysfs files for %s\n", + dev_err(&interface->dev, "stub_add_files for %s\n", udev_busid); usb_set_intfdata(interface, NULL); busid_priv->interf_count--; @@ -434,7 +433,7 @@ static int stub_probe(struct usb_interface *interface, if (!sdev) return -ENOMEM; - dev_info(&interface->dev, "USB/IP Stub: register a new device " + dev_info(&interface->dev, "usbip-host: register new device " "(bus %u dev %u ifn %u)\n", udev->bus->busnum, udev->devnum, interface->cur_altsetting->desc.bInterfaceNumber); @@ -449,8 +448,7 @@ static int stub_probe(struct usb_interface *interface, err = stub_add_files(&interface->dev); if (err) { - dev_err(&interface->dev, "create sysfs files for %s\n", - udev_busid); + dev_err(&interface->dev, "stub_add_files for %s\n", udev_busid); usb_set_intfdata(interface, NULL); usb_put_intf(interface); @@ -486,10 +484,9 @@ static void stub_disconnect(struct usb_interface *interface) const char *udev_busid = dev_name(interface->dev.parent); struct bus_id_priv *busid_priv; - busid_priv = get_busid_priv(udev_busid); - - usbip_udbg("Enter\n"); + dev_dbg(&interface->dev, "Enter\n"); + busid_priv = get_busid_priv(udev_busid); if (!busid_priv) { BUG(); return; @@ -499,7 +496,7 @@ static void stub_disconnect(struct usb_interface *interface) /* get stub_device */ if (!sdev) { - err(" could not get device from inteface data"); + dev_err(&interface->dev, "could not get device"); /* BUG(); */ return; } @@ -543,5 +540,4 @@ static void stub_disconnect(struct usb_interface *interface) busid_priv->status = STUB_BUSID_OTHER; del_match_busid((char *)udev_busid); } - usbip_udbg("bye\n"); } diff --git a/drivers/staging/usbip/stub_main.c b/drivers/staging/usbip/stub_main.c index 5568110..e9085d6 100644 --- a/drivers/staging/usbip/stub_main.c +++ b/drivers/staging/usbip/stub_main.c @@ -178,14 +178,14 @@ static ssize_t store_match_busid(struct device_driver *dev, const char *buf, if (add_match_busid(busid) < 0) return -ENOMEM; else { - usbip_udbg("add busid %s\n", busid); + pr_debug("add busid %s\n", busid); return count; } } else if (!strncmp(buf, "del ", 4)) { if (del_match_busid(busid) < 0) return -ENODEV; else { - usbip_udbg("del busid %s\n", busid); + pr_debug("del busid %s\n", busid); return count; } } else @@ -239,12 +239,12 @@ void stub_device_cleanup_urbs(struct stub_device *sdev) { struct stub_priv *priv; - usbip_udbg("free sdev %p\n", sdev); + dev_dbg(&sdev->udev->dev, "free sdev %p\n", sdev); while ((priv = stub_priv_pop(sdev))) { struct urb *urb = priv->urb; - usbip_udbg(" free urb %p\n", urb); + dev_dbg(&sdev->udev->dev, "free urb %p\n", urb); usb_kill_urb(urb); kmem_cache_free(stub_priv_cache, priv); @@ -265,20 +265,17 @@ static int __init usb_stub_init(void) SLAB_HWCACHE_ALIGN, NULL); if (!stub_priv_cache) { - printk(KERN_ERR KBUILD_MODNAME - ": create stub_priv_cache error\n"); + pr_err("create stub_priv_cache error\n"); return -ENOMEM; } ret = usb_register(&stub_driver); if (ret) { - printk(KERN_ERR KBUILD_MODNAME ": usb_register failed %d\n", - ret); + pr_err("usb_register failed %d\n", ret); goto error_usb_register; } - printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_DESC " " USBIP_VERSION - "\n"); + pr_info(DRIVER_DESC " " USBIP_VERSION "\n"); init_busid_table(); @@ -286,7 +283,7 @@ static int __init usb_stub_init(void) &driver_attr_match_busid); if (ret) { - printk(KERN_ERR KBUILD_MODNAME ": create driver sysfs\n"); + pr_err("create driver sysfs\n"); goto error_create_file; } diff --git a/drivers/staging/usbip/stub_rx.c b/drivers/staging/usbip/stub_rx.c index e245609..a5c1fa1 100644 --- a/drivers/staging/usbip/stub_rx.c +++ b/drivers/staging/usbip/stub_rx.c @@ -102,11 +102,11 @@ static int tweak_clear_halt_cmd(struct urb *urb) ret = usb_clear_halt(urb->dev, target_pipe); if (ret < 0) - usbip_uinfo("clear_halt error: devnum %d endp %d, %d\n", - urb->dev->devnum, target_endp, ret); + dev_err(&urb->dev->dev, "usb_clear_halt error: devnum %d endp " + "%d ret %d\n", urb->dev->devnum, target_endp, ret); else - usbip_uinfo("clear_halt done: devnum %d endp %d\n", - urb->dev->devnum, target_endp); + dev_info(&urb->dev->dev, "usb_clear_halt done: devnum %d endp " + "%d\n", urb->dev->devnum, target_endp); return ret; } @@ -127,11 +127,11 @@ static int tweak_set_interface_cmd(struct urb *urb) ret = usb_set_interface(urb->dev, interface, alternate); if (ret < 0) - usbip_uinfo("set_interface error: inf %u alt %u, %d\n", - interface, alternate, ret); + dev_err(&urb->dev->dev, "usb_set_interface error: inf %u alt " + "%u ret %d\n", interface, alternate, ret); else - usbip_uinfo("set_interface done: inf %u alt %u\n", - interface, alternate); + dev_info(&urb->dev->dev, "usb_set_interface done: inf %u alt " + "%u\n", interface, alternate); return ret; } @@ -160,9 +160,8 @@ static int tweak_set_configuration_cmd(struct urb *urb) * A user may need to set a special configuration value before * exporting the device. */ - usbip_uinfo("set_configuration %d to %s\n", - config, dev_name(&urb->dev->dev)); - usbip_uinfo("but, skip!\n"); + dev_info(&urb->dev->dev, "usb_set_configuration %d to %s... skip!\n", + config, dev_name(&urb->dev->dev)); return 0; /* return usb_driver_set_configuration(urb->dev, config); */ @@ -173,7 +172,7 @@ static int tweak_reset_device_cmd(struct urb *urb) struct stub_priv *priv = (struct stub_priv *) urb->context; struct stub_device *sdev = priv->sdev; - usbip_uinfo("reset_device %s\n", dev_name(&urb->dev->dev)); + dev_info(&urb->dev->dev, "usb_queue_reset_device\n"); /* * usb_lock_device_for_reset caused a deadlock: it causes the driver diff --git a/drivers/staging/usbip/stub_tx.c b/drivers/staging/usbip/stub_tx.c index 3c332c2..fda2bc9 100644 --- a/drivers/staging/usbip/stub_tx.c +++ b/drivers/staging/usbip/stub_tx.c @@ -75,22 +75,23 @@ void stub_complete(struct urb *urb) /* OK */ break; case -ENOENT: - usbip_uinfo("stopped by a call of usb_kill_urb() because of" - "cleaning up a virtual connection\n"); + dev_info(&urb->dev->dev, "stopped by a call to usb_kill_urb() " + "because of cleaning up a virtual connection\n"); return; case -ECONNRESET: - usbip_uinfo("unlinked by a call of usb_unlink_urb()\n"); + dev_info(&urb->dev->dev, "unlinked by a call to " + "usb_unlink_urb()\n"); break; case -EPIPE: - usbip_uinfo("endpoint %d is stalled\n", - usb_pipeendpoint(urb->pipe)); + dev_info(&urb->dev->dev, "endpoint %d is stalled\n", + usb_pipeendpoint(urb->pipe)); break; case -ESHUTDOWN: - usbip_uinfo("device removed?\n"); + dev_info(&urb->dev->dev, "device removed?\n"); break; default: - usbip_uinfo("urb completion with non-zero status %d\n", - urb->status); + dev_info(&urb->dev->dev, "urb completion with non-zero status " + "%d\n", urb->status); break; } diff --git a/drivers/staging/usbip/usbip_common.c b/drivers/staging/usbip/usbip_common.c index 68f5106..433a3b6 100644 --- a/drivers/staging/usbip/usbip_common.c +++ b/drivers/staging/usbip/usbip_common.c @@ -56,7 +56,7 @@ DEVICE_ATTR(usbip_debug, (S_IRUGO | S_IWUSR), show_flag, store_flag); static void usbip_dump_buffer(char *buff, int bufflen) { - print_hex_dump(KERN_DEBUG, "usb-ip", DUMP_PREFIX_OFFSET, 16, 4, + print_hex_dump(KERN_DEBUG, "usbip-core", DUMP_PREFIX_OFFSET, 16, 4, buff, bufflen, false); } @@ -67,30 +67,25 @@ static void usbip_dump_pipe(unsigned int p) unsigned char dev = usb_pipedevice(p); unsigned char dir = usb_pipein(p); - printk(KERN_DEBUG "dev(%d) ", dev); - printk(KERN_DEBUG "ep(%d) ", ep); - printk(KERN_DEBUG "%s ", dir ? "IN" : "OUT"); + pr_debug("dev(%d) ep(%d) [%s] ", dev, ep, dir ? "IN" : "OUT"); switch (type) { case PIPE_ISOCHRONOUS: - printk(KERN_DEBUG "%s ", "ISO"); + pr_debug("ISO\n"); break; case PIPE_INTERRUPT: - printk(KERN_DEBUG "%s ", "INT"); + pr_debug("INT\n"); break; case PIPE_CONTROL: - printk(KERN_DEBUG "%s ", "CTL"); + pr_debug("CTRL\n"); break; case PIPE_BULK: - printk(KERN_DEBUG "%s ", "BLK"); + pr_debug("BULK\n"); break; default: - printk(KERN_DEBUG "ERR"); + pr_debug("ERR\n"); break; } - - printk(KERN_DEBUG "\n"); - } static void usbip_dump_usb_device(struct usb_device *udev) @@ -98,61 +93,59 @@ static void usbip_dump_usb_device(struct usb_device *udev) struct device *dev = &udev->dev; int i; - dev_dbg(dev, " devnum(%d) devpath(%s)", + dev_dbg(dev, " devnum(%d) devpath(%s) ", udev->devnum, udev->devpath); switch (udev->speed) { case USB_SPEED_HIGH: - printk(KERN_DEBUG " SPD_HIGH"); + pr_debug("SPD_HIGH "); break; case USB_SPEED_FULL: - printk(KERN_DEBUG " SPD_FULL"); + pr_debug("SPD_FULL "); break; case USB_SPEED_LOW: - printk(KERN_DEBUG " SPD_LOW"); + pr_debug("SPD_LOW "); break; case USB_SPEED_UNKNOWN: - printk(KERN_DEBUG " SPD_UNKNOWN"); + pr_debug("SPD_UNKNOWN "); break; default: - printk(KERN_DEBUG " SPD_ERROR"); + pr_debug("SPD_ERROR "); break; } - printk(KERN_DEBUG " tt %p, ttport %d", udev->tt, udev->ttport); - printk(KERN_DEBUG "\n"); + pr_debug("tt %p, ttport %d\n", udev->tt, udev->ttport); dev_dbg(dev, " "); for (i = 0; i < 16; i++) - printk(KERN_DEBUG " %2u", i); - printk(KERN_DEBUG "\n"); + pr_debug(" %2u", i); + pr_debug("\n"); dev_dbg(dev, " toggle0(IN) :"); for (i = 0; i < 16; i++) - printk(KERN_DEBUG " %2u", (udev->toggle[0] & (1 << i)) ? 1 : 0); - printk(KERN_DEBUG "\n"); + pr_debug(" %2u", (udev->toggle[0] & (1 << i)) ? 1 : 0); + pr_debug("\n"); dev_dbg(dev, " toggle1(OUT):"); for (i = 0; i < 16; i++) - printk(KERN_DEBUG " %2u", (udev->toggle[1] & (1 << i)) ? 1 : 0); - printk(KERN_DEBUG "\n"); - + pr_debug(" %2u", (udev->toggle[1] & (1 << i)) ? 1 : 0); + pr_debug("\n"); dev_dbg(dev, " epmaxp_in :"); for (i = 0; i < 16; i++) { if (udev->ep_in[i]) - printk(KERN_DEBUG " %2u", - le16_to_cpu(udev->ep_in[i]->desc.wMaxPacketSize)); + pr_debug(" %2u", + le16_to_cpu(udev->ep_in[i]->desc.wMaxPacketSize)); } - printk(KERN_DEBUG "\n"); + pr_debug("\n"); dev_dbg(dev, " epmaxp_out :"); for (i = 0; i < 16; i++) { if (udev->ep_out[i]) - printk(KERN_DEBUG " %2u", - le16_to_cpu(udev->ep_out[i]->desc.wMaxPacketSize)); + pr_debug(" %2u", + le16_to_cpu(udev->ep_out[i]->desc.wMaxPacketSize)); } - printk(KERN_DEBUG "\n"); + pr_debug("\n"); dev_dbg(dev, "parent %p, bus %p\n", udev->parent, udev->bus); @@ -171,19 +164,19 @@ static void usbip_dump_request_type(__u8 rt) { switch (rt & USB_RECIP_MASK) { case USB_RECIP_DEVICE: - printk(KERN_DEBUG "DEVICE"); + pr_debug("DEVICE"); break; case USB_RECIP_INTERFACE: - printk(KERN_DEBUG "INTERF"); + pr_debug("INTERF"); break; case USB_RECIP_ENDPOINT: - printk(KERN_DEBUG "ENDPOI"); + pr_debug("ENDPOI"); break; case USB_RECIP_OTHER: - printk(KERN_DEBUG "OTHER "); + pr_debug("OTHER "); break; default: - printk(KERN_DEBUG "------"); + pr_debug("------"); break; } } @@ -191,73 +184,64 @@ static void usbip_dump_request_type(__u8 rt) static void usbip_dump_usb_ctrlrequest(struct usb_ctrlrequest *cmd) { if (!cmd) { - printk(KERN_DEBUG " %s : null pointer\n", __func__); + pr_debug(" : null pointer\n"); return; } - printk(KERN_DEBUG " "); - printk(KERN_DEBUG "bRequestType(%02X) ", cmd->bRequestType); - printk(KERN_DEBUG "bRequest(%02X) " , cmd->bRequest); - printk(KERN_DEBUG "wValue(%04X) ", cmd->wValue); - printk(KERN_DEBUG "wIndex(%04X) ", cmd->wIndex); - printk(KERN_DEBUG "wLength(%04X) ", cmd->wLength); - - printk(KERN_DEBUG "\n "); + pr_debug(" "); + pr_debug("bRequestType(%02X) bRequest(%02X) wValue(%04X) wIndex(%04X) " + "wLength(%04X) ", cmd->bRequestType, cmd->bRequest, + cmd->wValue, cmd->wIndex, cmd->wLength); + pr_debug("\n "); if ((cmd->bRequestType & USB_TYPE_MASK) = USB_TYPE_STANDARD) { - printk(KERN_DEBUG "STANDARD "); + pr_debug("STANDARD "); switch (cmd->bRequest) { case USB_REQ_GET_STATUS: - printk(KERN_DEBUG "GET_STATUS"); + pr_debug("GET_STATUS\n"); break; case USB_REQ_CLEAR_FEATURE: - printk(KERN_DEBUG "CLEAR_FEAT"); + pr_debug("CLEAR_FEAT\n"); break; case USB_REQ_SET_FEATURE: - printk(KERN_DEBUG "SET_FEAT "); + pr_debug("SET_FEAT \n"); break; case USB_REQ_SET_ADDRESS: - printk(KERN_DEBUG "SET_ADDRRS"); + pr_debug("SET_ADDRRS\n"); break; case USB_REQ_GET_DESCRIPTOR: - printk(KERN_DEBUG "GET_DESCRI"); + pr_debug("GET_DESCRI\n"); break; case USB_REQ_SET_DESCRIPTOR: - printk(KERN_DEBUG "SET_DESCRI"); + pr_debug("SET_DESCRI\n"); break; case USB_REQ_GET_CONFIGURATION: - printk(KERN_DEBUG "GET_CONFIG"); + pr_debug("GET_CONFIG\n"); break; case USB_REQ_SET_CONFIGURATION: - printk(KERN_DEBUG "SET_CONFIG"); + pr_debug("SET_CONFIG\n"); break; case USB_REQ_GET_INTERFACE: - printk(KERN_DEBUG "GET_INTERF"); + pr_debug("GET_INTERF\n"); break; case USB_REQ_SET_INTERFACE: - printk(KERN_DEBUG "SET_INTERF"); + pr_debug("SET_INTERF\n"); break; case USB_REQ_SYNCH_FRAME: - printk(KERN_DEBUG "SYNC_FRAME"); + pr_debug("SYNC_FRAME\n"); break; default: - printk(KERN_DEBUG "REQ(%02X) ", cmd->bRequest); + pr_debug("REQ(%02X) \n", cmd->bRequest); break; } - - printk(KERN_DEBUG " "); usbip_dump_request_type(cmd->bRequestType); - - } else if ((cmd->bRequestType & USB_TYPE_MASK) = USB_TYPE_CLASS) - printk(KERN_DEBUG "CLASS "); - - else if ((cmd->bRequestType & USB_TYPE_MASK) = USB_TYPE_VENDOR) - printk(KERN_DEBUG "VENDOR "); - - else if ((cmd->bRequestType & USB_TYPE_MASK) = USB_TYPE_RESERVED) - printk(KERN_DEBUG "RESERVED"); - - printk(KERN_DEBUG "\n"); + } else if ((cmd->bRequestType & USB_TYPE_MASK) = USB_TYPE_CLASS) { + pr_debug("CLASS \n"); + } else if ((cmd->bRequestType & USB_TYPE_MASK) = USB_TYPE_VENDOR) { + pr_debug("VENDOR \n"); + } else if ((cmd->bRequestType & USB_TYPE_MASK) = USB_TYPE_RESERVED) { + pr_debug("RESERVED\n"); + } } void usbip_dump_urb(struct urb *urb) @@ -265,16 +249,15 @@ void usbip_dump_urb(struct urb *urb) struct device *dev; if (!urb) { - printk(KERN_DEBUG KBUILD_MODNAME - ":%s: urb: null pointer!!\n", __func__); + pr_debug("urb: null pointer!!\n"); return; } if (!urb->dev) { - printk(KERN_DEBUG KBUILD_MODNAME - ":%s: urb->dev: null pointer!!\n", __func__); + pr_debug("urb->dev: null pointer!!\n"); return; } + dev = &urb->dev->dev; dev_dbg(dev, " urb :%p\n", urb); @@ -309,39 +292,42 @@ EXPORT_SYMBOL_GPL(usbip_dump_urb); void usbip_dump_header(struct usbip_header *pdu) { - usbip_udbg("BASE: cmd %u seq %u devid %u dir %u ep %u\n", - pdu->base.command, - pdu->base.seqnum, - pdu->base.devid, - pdu->base.direction, - pdu->base.ep); + pr_debug("BASE: cmd %u seq %u devid %u dir %u ep %u\n", + pdu->base.command, + pdu->base.seqnum, + pdu->base.devid, + pdu->base.direction, + pdu->base.ep); switch (pdu->base.command) { case USBIP_CMD_SUBMIT: - usbip_udbg("CMD_SUBMIT: " - "x_flags %u x_len %u sf %u #p %u iv %u\n", - pdu->u.cmd_submit.transfer_flags, - pdu->u.cmd_submit.transfer_buffer_length, - pdu->u.cmd_submit.start_frame, - pdu->u.cmd_submit.number_of_packets, - pdu->u.cmd_submit.interval); + pr_debug("USBIP_CMD_SUBMIT: " + "x_flags %u x_len %u sf %u #p %d iv %d\n", + pdu->u.cmd_submit.transfer_flags, + pdu->u.cmd_submit.transfer_buffer_length, + pdu->u.cmd_submit.start_frame, + pdu->u.cmd_submit.number_of_packets, + pdu->u.cmd_submit.interval); break; case USBIP_CMD_UNLINK: - usbip_udbg("CMD_UNLINK: seq %u\n", pdu->u.cmd_unlink.seqnum); + pr_debug("USBIP_CMD_UNLINK: seq %u\n", + pdu->u.cmd_unlink.seqnum); break; case USBIP_RET_SUBMIT: - usbip_udbg("RET_SUBMIT: st %d al %u sf %d #p %d ec %d\n", - pdu->u.ret_submit.status, - pdu->u.ret_submit.actual_length, - pdu->u.ret_submit.start_frame, - pdu->u.ret_submit.number_of_packets, - pdu->u.ret_submit.error_count); + pr_debug("USBIP_RET_SUBMIT: st %d al %u sf %d #p %d ec %d\n", + pdu->u.ret_submit.status, + pdu->u.ret_submit.actual_length, + pdu->u.ret_submit.start_frame, + pdu->u.ret_submit.number_of_packets, + pdu->u.ret_submit.error_count); + break; case USBIP_RET_UNLINK: - usbip_udbg("RET_UNLINK: status %d\n", pdu->u.ret_unlink.status); + pr_debug("USBIP_RET_UNLINK: status %d\n", + pdu->u.ret_unlink.status); break; default: /* NOT REACHED */ - usbip_udbg("unknown command\n"); + pr_err("unknown command\n"); break; } } @@ -363,21 +349,20 @@ int usbip_xmit(int send, struct socket *sock, char *buf, usbip_dbg_xmit("enter\n"); if (!sock || !buf || !size) { - printk(KERN_ERR "%s: invalid arg, sock %p buff %p size %d\n", - __func__, sock, buf, size); + pr_err("invalid arg, sock %p buff %p size %d\n", sock, buf, + size); return -EINVAL; } if (usbip_dbg_flag_xmit) { if (send) { if (!in_interrupt()) - printk(KERN_DEBUG "%-10s:", current->comm); + pr_debug("%-10s:", current->comm); else - printk(KERN_DEBUG "interrupt :"); + pr_debug("interrupt :"); - printk(KERN_DEBUG "%s: sending... , sock %p, buf %p, " - "size %d, msg_flags %d\n", __func__, - sock, buf, size, msg_flags); + pr_debug("sending... , sock %p, buf %p, size %d, " + "msg_flags %d\n", sock, buf, size, msg_flags); usbip_dump_buffer(buf, size); } } @@ -400,9 +385,9 @@ int usbip_xmit(int send, struct socket *sock, char *buf, MSG_WAITALL); if (result <= 0) { - usbip_udbg("usbip_xmit: %s sock %p buf %p size %u ret " - "%d total %d\n", send ? "send" : "receive", - sock, buf, size, result, total); + pr_debug("%s sock %p buf %p size %u ret %d total %d\n", + send ? "send" : "receive", sock, buf, size, + result, total); goto err; } @@ -415,20 +400,18 @@ int usbip_xmit(int send, struct socket *sock, char *buf, if (usbip_dbg_flag_xmit) { if (!send) { if (!in_interrupt()) - printk(KERN_DEBUG "%-10s:", current->comm); + pr_debug("%-10s:", current->comm); else - printk(KERN_DEBUG "interrupt :"); + pr_debug("interrupt :"); - printk(KERN_DEBUG "usbip_xmit: receiving....\n"); + pr_debug("receiving....\n"); usbip_dump_buffer(bp, osize); - printk(KERN_DEBUG "usbip_xmit: received, osize %d ret " - "%d size %d total %d\n", osize, result, size, - total); + pr_debug("received, osize %d ret %d size %d total %d\n", + osize, result, size, total); } if (send) - printk(KERN_DEBUG "usbip_xmit: send, total %d\n", - total); + pr_debug("send, total %d\n", total); } return total; @@ -446,7 +429,7 @@ struct socket *sockfd_to_socket(unsigned int sockfd) file = fget(sockfd); if (!file) { - printk(KERN_ERR "%s: invalid sockfd\n", __func__); + pr_err("invalid sockfd\n"); return NULL; } @@ -532,8 +515,7 @@ void usbip_pack_pdu(struct usbip_header *pdu, struct urb *urb, int cmd, break; default: /* NOT REACHED */ - err("unknown command"); - /* BUG(); */ + pr_err("unknown command\n"); break; } } @@ -639,8 +621,7 @@ void usbip_header_correct_endian(struct usbip_header *pdu, int send) break; default: /* NOT REACHED */ - err("unknown command in pdu header: %d", cmd); - /* BUG(); */ + pr_err("unknown command\n"); break; } } @@ -722,7 +703,7 @@ int usbip_recv_iso(struct usbip_device *ud, struct urb *urb) /* my Bluetooth dongle gets ISO URBs which are np = 0 */ if (np = 0) { - /* usbip_uinfo("iso np = 0\n"); */ + /* pr_info("iso np = 0\n"); */ /* usbip_dump_urb(urb); */ return 0; } @@ -860,8 +841,7 @@ EXPORT_SYMBOL_GPL(usbip_recv_xbuff); static int __init usbip_common_init(void) { - printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_DESC " " USBIP_VERSION - "\n"); + pr_info(DRIVER_DESC " v" USBIP_VERSION "\n"); return 0; } diff --git a/drivers/staging/usbip/usbip_common.h b/drivers/staging/usbip/usbip_common.h index fd84ab2..4a641c5 100644 --- a/drivers/staging/usbip/usbip_common.h +++ b/drivers/staging/usbip/usbip_common.h @@ -32,25 +32,13 @@ #define USBIP_VERSION "1.0.0" -/** - * usbip_udbg - print debug messages if CONFIG_USB_IP_DEBUG is defined - * @fmt: - * @args: - */ -#ifdef CONFIG_USB_IP_DEBUG - -#define usbip_udbg(fmt, args...) \ - do { \ - printk(KERN_DEBUG "%-10s:(%s,%d) %s: " fmt, \ - (in_interrupt() ? "interrupt" : (current)->comm),\ - __FILE__, __LINE__, __func__, ##args); \ - } while (0) +#undef pr_fmt +#ifdef DEBUG +#define pr_fmt(fmt) KBUILD_MODNAME ": %s:%d: " fmt, __func__, __LINE__ #else - -#define usbip_udbg(fmt, args...) do { } while (0) - -#endif /* CONFIG_USB_IP_DEBUG */ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#endif enum { usbip_debug_xmit = (1 << 0), @@ -85,7 +73,7 @@ extern struct device_attribute dev_attr_usbip_debug; #define usbip_dbg_with_flag(flag, fmt, args...) \ do { \ if (flag & usbip_debug_flag) \ - usbip_udbg(fmt , ##args); \ + pr_debug(fmt, ##args); \ } while (0) #define usbip_dbg_sysfs(fmt, args...) \ @@ -115,28 +103,6 @@ extern struct device_attribute dev_attr_usbip_debug; #define usbip_dbg_stub_tx(fmt, args...) \ usbip_dbg_with_flag(usbip_debug_stub_tx, fmt , ##args) -/** - * usbip_uerr - print error messages - * @fmt: - * @args: - */ -#define usbip_uerr(fmt, args...) \ - do { \ - printk(KERN_ERR "%-10s: ***ERROR*** (%s,%d) %s: " fmt, \ - (in_interrupt() ? "interrupt" : (current)->comm),\ - __FILE__, __LINE__, __func__, ##args); \ - } while (0) - -/** - * usbip_uinfo - print information messages - * @fmt: - * @args: - */ -#define usbip_uinfo(fmt, args...) \ - do { \ - printk(KERN_INFO "usbip: " fmt , ## args); \ - } while (0) - /* * USB/IP request headers. * Currently, we define 4 request types: diff --git a/drivers/staging/usbip/usbip_event.c b/drivers/staging/usbip/usbip_event.c index da6074d..ecd1862 100644 --- a/drivers/staging/usbip/usbip_event.c +++ b/drivers/staging/usbip/usbip_event.c @@ -84,8 +84,7 @@ int usbip_start_eh(struct usbip_device *ud) ud->eh = kthread_run(event_handler_loop, ud, "usbip_eh"); if (IS_ERR(ud->eh)) { - printk(KERN_WARNING - "Unable to start control thread\n"); + pr_warning("Unable to start control thread\n"); return PTR_ERR(ud->eh); } diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c index 0864b27..a76e8fa 100644 --- a/drivers/staging/usbip/vhci_hcd.c +++ b/drivers/staging/usbip/vhci_hcd.c @@ -96,12 +96,12 @@ static void dump_port_status(u32 status) { int i = 0; - printk(KERN_DEBUG "status %08x:", status); + pr_debug("status %08x:", status); for (i = 0; i < 32; i++) { if (status & (1 << i)) - printk(KERN_DEBUG " %s", bit_desc[i]); + pr_debug(" %s", bit_desc[i]); } - printk(KERN_DEBUG "\n"); + pr_debug("\n"); } void rh_port_connect(int rhport, enum usb_device_speed speed) @@ -216,7 +216,7 @@ static int vhci_hub_status(struct usb_hcd *hcd, char *buf) } } - usbip_uinfo("changed %d\n", changed); + pr_info("changed %d\n", changed); if (hcd->state = HC_STATE_SUSPENDED) usb_hcd_resume_root_hub(hcd); @@ -264,8 +264,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 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); + pr_err("invalid port number %d\n", wIndex); rhport = ((__u8)(wIndex & 0x00ff)) - 1; dum = hcd_to_vhci(hcd); @@ -334,8 +333,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, case GetPortStatus: 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); + pr_err("invalid port number %d\n", wIndex); retval = -EPIPE; } @@ -345,7 +343,6 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, * complete it!! * */ if (dum->resuming && time_after(jiffies, dum->re_timeout)) { - printk(KERN_ERR "%s: not yet\n", __func__); dum->port_status[rhport] | (1 << USB_PORT_FEAT_C_SUSPEND); dum->port_status[rhport] &@@ -415,7 +412,6 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, case USB_PORT_FEAT_SUSPEND: usbip_dbg_vhci_rh(" SetPortFeature: " "USB_PORT_FEAT_SUSPEND\n"); - printk(KERN_ERR "%s: not yet\n", __func__); #if 0 dum->port_status[rhport] | (1 << USB_PORT_FEAT_SUSPEND); @@ -457,7 +453,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, break; default: - printk(KERN_ERR "%s: default: no such request\n", __func__); + pr_err("default: no such request\n"); /* dev_dbg (hardware, * "hub control req%04x v%04x i%04x l%d\n", * typeReq, wValue, wIndex, wLength); */ @@ -467,7 +463,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, } if (usbip_dbg_flag_vhci_rh) { - printk(KERN_DEBUG "port %d\n", rhport); + pr_debug("port %d\n", rhport); dump_port_status(prev_port_status[rhport]); dump_port_status(dum->port_status[rhport]); } @@ -499,7 +495,7 @@ static void vhci_tx_urb(struct urb *urb) unsigned long flag; if (!vdev) { - err("could not get virtual device"); + pr_err("could not get virtual device"); /* BUG(); */ return; } @@ -517,7 +513,7 @@ static void vhci_tx_urb(struct urb *urb) priv->seqnum = atomic_inc_return(&the_controller->seqnum); if (priv->seqnum = 0xffff) - usbip_uinfo("seqnum max\n"); + dev_info(&urb->dev->dev, "seqnum max\n"); priv->vdev = vdev; priv->urb = urb; @@ -558,7 +554,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, spin_lock(&vdev->ud.lock); if (vdev->ud.status = VDEV_ST_NULL || vdev->ud.status = VDEV_ST_ERROR) { - usbip_uerr("enqueue for inactive port %d\n", vdev->rhport); + dev_err(dev, "enqueue for inactive port %d\n", vdev->rhport); spin_unlock(&vdev->ud.lock); spin_unlock_irqrestore(&the_controller->lock, flags); return -ENODEV; @@ -701,7 +697,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) struct vhci_priv *priv; struct vhci_device *vdev; - usbip_uinfo("vhci_hcd: dequeue a urb %p\n", urb); + pr_info("dequeue a urb %p\n", urb); spin_lock_irqsave(&the_controller->lock, flags); @@ -731,8 +727,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) spin_lock_irqsave(&vdev->priv_lock, flags2); - usbip_uinfo("vhci_hcd: device %p seems to be disconnected\n", - vdev); + pr_info("device %p seems to be disconnected\n", vdev); list_del(&priv->list); kfree(priv); urb->hcpriv = NULL; @@ -744,8 +739,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) * 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); + pr_info("gives back urb %p\n", urb); usb_hcd_unlink_urb_from_ep(hcd, urb); @@ -764,7 +758,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) { - usbip_uerr("malloc vhci_unlink\n"); + pr_err("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); @@ -773,12 +767,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) - usbip_uinfo("seqnum max\n"); + pr_info("seqnum max\n"); unlink->unlink_seqnum = priv->seqnum; - usbip_uinfo("vhci_hcd: device %p seems to be still connected\n", - vdev); + pr_info("device %p seems to be still connected\n", vdev); /* send cmd_unlink and try to cancel the pending URB in the * peer */ @@ -801,7 +794,7 @@ static void vhci_device_unlink_cleanup(struct vhci_device *vdev) spin_lock(&vdev->priv_lock); list_for_each_entry_safe(unlink, tmp, &vdev->unlink_tx, list) { - usbip_uinfo("unlink cleanup tx %lu\n", unlink->unlink_seqnum); + pr_info("unlink cleanup tx %lu\n", unlink->unlink_seqnum); list_del(&unlink->list); kfree(unlink); } @@ -810,12 +803,12 @@ static void vhci_device_unlink_cleanup(struct vhci_device *vdev) struct urb *urb; /* give back URB of unanswered unlink request */ - usbip_uinfo("unlink cleanup rx %lu\n", unlink->unlink_seqnum); + pr_info("unlink cleanup rx %lu\n", unlink->unlink_seqnum); urb = pickup_urb_and_free_priv(vdev, unlink->unlink_seqnum); if (!urb) { - usbip_uinfo("the urb (seqnum %lu) was already given " - "back\n", unlink->unlink_seqnum); + pr_info("the urb (seqnum %lu) was already given back\n", + unlink->unlink_seqnum); list_del(&unlink->list); kfree(unlink); continue; @@ -848,7 +841,7 @@ static void vhci_shutdown_connection(struct usbip_device *ud) /* need this? see stub_dev.c */ if (ud->tcp_socket) { - usbip_udbg("shutdown tcp_socket %p\n", ud->tcp_socket); + pr_debug("shutdown tcp_socket %p\n", ud->tcp_socket); kernel_sock_shutdown(ud->tcp_socket, SHUT_RDWR); } @@ -858,14 +851,14 @@ static void vhci_shutdown_connection(struct usbip_device *ud) if (vdev->ud.tcp_tx) kthread_stop(vdev->ud.tcp_tx); - usbip_uinfo("stop threads\n"); + pr_info("stop threads\n"); /* active connection is closed */ if (vdev->ud.tcp_socket != NULL) { sock_release(vdev->ud.tcp_socket); vdev->ud.tcp_socket = NULL; } - usbip_uinfo("release socket\n"); + pr_info("release socket\n"); vhci_device_unlink_cleanup(vdev); @@ -891,7 +884,7 @@ static void vhci_shutdown_connection(struct usbip_device *ud) */ rh_port_disconnect(vdev->rhport); - usbip_uinfo("disconnect device\n"); + pr_info("disconnect device\n"); } @@ -972,7 +965,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) { - usbip_uerr("create sysfs files\n"); + pr_err("create sysfs files\n"); return err; } @@ -996,13 +989,11 @@ static void vhci_stop(struct usb_hcd *hcd) usbip_event_add(&vdev->ud, VDEV_EVENT_REMOVED); usbip_stop_eh(&vdev->ud); } - - usbip_uinfo("vhci_stop done\n"); } static int vhci_get_frame_number(struct usb_hcd *hcd) { - usbip_uerr("Not yet implemented\n"); + pr_err("Not yet implemented\n"); return 0; } @@ -1079,8 +1070,6 @@ static int vhci_hcd_probe(struct platform_device *pdev) struct usb_hcd *hcd; int ret; - usbip_uinfo("proving...\n"); - usbip_dbg_vhci_hc("name %s id %d\n", pdev->name, pdev->id); /* will be removed */ @@ -1095,7 +1084,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) { - usbip_uerr("create hcd failed\n"); + pr_err("create hcd failed\n"); return -ENOMEM; } hcd->has_tt = 1; @@ -1109,7 +1098,7 @@ static int vhci_hcd_probe(struct platform_device *pdev) */ ret = usb_add_hcd(hcd, 0, 0); if (ret != 0) { - usbip_uerr("usb_add_hcd failed %d\n", ret); + pr_err("usb_add_hcd failed %d\n", ret); usb_put_hcd(hcd); the_controller = NULL; return ret; @@ -1149,8 +1138,6 @@ static int vhci_hcd_suspend(struct platform_device *pdev, pm_message_t state) int connected = 0; int ret = 0; - dev_dbg(&pdev->dev, "%s\n", __func__); - hcd = platform_get_drvdata(pdev); spin_lock(&the_controller->lock); @@ -1163,11 +1150,11 @@ static int vhci_hcd_suspend(struct platform_device *pdev, pm_message_t state) spin_unlock(&the_controller->lock); if (connected > 0) { - usbip_uinfo("We have %d active connection%s. Do not suspend.\n", - connected, (connected = 1 ? "" : "s")); + dev_info(&pdev->dev, "We have %d active connection%s. Do not " + "suspend.\n", connected, (connected = 1 ? "" : "s")); ret = -EBUSY; } else { - usbip_uinfo("suspend vhci_hcd"); + dev_info(&pdev->dev, "suspend vhci_hcd"); clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); } @@ -1229,13 +1216,9 @@ static int __init vhci_init(void) { int ret; - usbip_dbg_vhci_hc("enter\n"); if (usb_disabled()) return -ENODEV; - printk(KERN_INFO KBUILD_MODNAME ": %s, %s\n", driver_name, - USBIP_VERSION); - ret = platform_driver_register(&vhci_driver); if (ret < 0) goto err_driver_register; @@ -1244,25 +1227,19 @@ static int __init vhci_init(void) if (ret < 0) goto err_platform_device_register; - usbip_dbg_vhci_hc("bye\n"); + pr_info(DRIVER_DESC " v" USBIP_VERSION "\n"); return ret; - /* error occurred */ err_platform_device_register: platform_driver_unregister(&vhci_driver); err_driver_register: - usbip_dbg_vhci_hc("bye\n"); return ret; } static void __exit vhci_cleanup(void) { - usbip_dbg_vhci_hc("enter\n"); - platform_device_unregister(&the_pdev); platform_driver_unregister(&vhci_driver); - - usbip_dbg_vhci_hc("bye\n"); } module_init(vhci_init); diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c index 2fe6cbf..e42ce9d 100644 --- a/drivers/staging/usbip/vhci_rx.c +++ b/drivers/staging/usbip/vhci_rx.c @@ -74,10 +74,9 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev, spin_unlock(&vdev->priv_lock); if (!urb) { - usbip_uerr("cannot find a urb of seqnum %u\n", - pdu->base.seqnum); - usbip_uinfo("max seqnum %d\n", - atomic_read(&the_controller->seqnum)); + pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum); + pr_info("max seqnum %d\n", + atomic_read(&the_controller->seqnum)); usbip_event_add(ud, VDEV_EVENT_ERROR_TCP); return; } @@ -121,7 +120,7 @@ static struct vhci_unlink *dequeue_pending_unlink(struct vhci_device *vdev, spin_lock(&vdev->priv_lock); list_for_each_entry_safe(unlink, tmp, &vdev->unlink_rx, list) { - usbip_uinfo("unlink->seqnum %lu\n", unlink->seqnum); + pr_info("unlink->seqnum %lu\n", unlink->seqnum); if (unlink->seqnum = pdu->base.seqnum) { usbip_dbg_vhci_rx("found pending unlink, %lu\n", unlink->seqnum); @@ -147,8 +146,8 @@ static void vhci_recv_ret_unlink(struct vhci_device *vdev, unlink = dequeue_pending_unlink(vdev, pdu); if (!unlink) { - usbip_uinfo("cannot find the pending unlink %u\n", - pdu->base.seqnum); + pr_info("cannot find the pending unlink %u\n", + pdu->base.seqnum); return; } @@ -162,14 +161,14 @@ static void vhci_recv_ret_unlink(struct vhci_device *vdev, * already received the result of its submit result and gave * back the URB. */ - usbip_uinfo("the urb (seqnum %d) was already given backed\n", - pdu->base.seqnum); + pr_info("the urb (seqnum %d) was already given backed\n", + pdu->base.seqnum); } else { usbip_dbg_vhci_rx("now giveback urb %p\n", urb); /* If unlink is succeed, status is -ECONNRESET */ urb->status = pdu->u.ret_unlink.status; - usbip_uinfo("%d\n", urb->status); + pr_info("urb->status %d\n", urb->status); spin_lock(&the_controller->lock); usb_hcd_unlink_urb_from_ep(vhci_to_hcd(the_controller), urb); @@ -210,26 +209,26 @@ static void vhci_rx_pdu(struct usbip_device *ud) ret = usbip_xmit(0, ud->tcp_socket, (char *) &pdu, sizeof(pdu), 0); if (ret < 0) { if (ret = -ECONNRESET) - usbip_uinfo("connection reset by peer\n"); + pr_info("connection reset by peer\n"); else if (ret = -EAGAIN) { /* ignore if connection was idle */ if (vhci_priv_tx_empty(vdev)) return; - usbip_uinfo("connection timed out with pending urbs\n"); + pr_info("connection timed out with pending urbs\n"); } else if (ret != -ERESTARTSYS) - usbip_uinfo("xmit failed %d\n", ret); + pr_info("xmit failed %d\n", ret); usbip_event_add(ud, VDEV_EVENT_ERROR_TCP); return; } if (ret = 0) { - usbip_uinfo("connection closed"); + pr_info("connection closed"); usbip_event_add(ud, VDEV_EVENT_DOWN); return; } if (ret != sizeof(pdu)) { - usbip_uerr("received pdu size is %d, should be %d\n", - ret, (unsigned int)sizeof(pdu)); + pr_err("received pdu size is %d, should be %d\n", ret, + (unsigned int)sizeof(pdu)); usbip_event_add(ud, VDEV_EVENT_ERROR_TCP); return; } @@ -248,7 +247,7 @@ static void vhci_rx_pdu(struct usbip_device *ud) break; default: /* NOT REACHED */ - usbip_uerr("unknown pdu %u\n", pdu.base.command); + pr_err("unknown pdu %u\n", pdu.base.command); usbip_dump_header(&pdu); usbip_event_add(ud, VDEV_EVENT_ERROR_TCP); break; diff --git a/drivers/staging/usbip/vhci_sysfs.c b/drivers/staging/usbip/vhci_sysfs.c index 83f61ed..d9736f9 100644 --- a/drivers/staging/usbip/vhci_sysfs.c +++ b/drivers/staging/usbip/vhci_sysfs.c @@ -89,7 +89,7 @@ static int vhci_port_disconnect(__u32 rhport) spin_lock(&vdev->ud.lock); if (vdev->ud.status = VDEV_ST_NULL) { - usbip_uerr("not connected %d\n", vdev->ud.status); + pr_err("not connected %d\n", vdev->ud.status); /* unlock */ spin_unlock(&vdev->ud.lock); @@ -117,7 +117,7 @@ static ssize_t store_detach(struct device *dev, struct device_attribute *attr, /* check rhport */ if (rhport >= VHCI_NPORTS) { - usbip_uerr("invalid port %u\n", rhport); + dev_err(dev, "invalid port %u\n", rhport); return -EINVAL; } @@ -136,7 +136,7 @@ static int valid_args(__u32 rhport, enum usb_device_speed speed) { /* check rhport */ if ((rhport < 0) || (rhport >= VHCI_NPORTS)) { - usbip_uerr("port %u\n", rhport); + pr_err("port %u\n", rhport); return -EINVAL; } @@ -148,7 +148,7 @@ static int valid_args(__u32 rhport, enum usb_device_speed speed) case USB_SPEED_WIRELESS: break; default: - usbip_uerr("speed %d\n", speed); + pr_err("speed %d\n", speed); return -EINVAL; } @@ -206,12 +206,12 @@ static ssize_t store_attach(struct device *dev, struct device_attribute *attr, spin_unlock(&vdev->ud.lock); spin_unlock(&the_controller->lock); - usbip_uerr("port %d already used\n", rhport); + dev_err(dev, "port %d already used\n", rhport); return -EINVAL; } - usbip_uinfo("rhport(%u) sockfd(%d) devid(%u) speed(%u)\n", - rhport, sockfd, devid, speed); + dev_info(dev, "rhport(%u) sockfd(%d) devid(%u) speed(%u)\n", + rhport, sockfd, devid, speed); vdev->devid = devid; vdev->speed = speed; diff --git a/drivers/staging/usbip/vhci_tx.c b/drivers/staging/usbip/vhci_tx.c index c1aa03b..9b437e7 100644 --- a/drivers/staging/usbip/vhci_tx.c +++ b/drivers/staging/usbip/vhci_tx.c @@ -118,8 +118,8 @@ static int vhci_send_cmd_submit(struct vhci_device *vdev) ret = kernel_sendmsg(vdev->ud.tcp_socket, &msg, iov, 3, txsize); if (ret != txsize) { - usbip_uerr("sendmsg failed!, retval %d for %zd\n", ret, - txsize); + pr_err("sendmsg failed!, ret=%d for %zd\n", ret, + txsize); kfree(iso_buffer); usbip_event_add(&vdev->ud, VDEV_EVENT_ERROR_TCP); return -1; @@ -188,8 +188,8 @@ static int vhci_send_cmd_unlink(struct vhci_device *vdev) ret = kernel_sendmsg(vdev->ud.tcp_socket, &msg, iov, 1, txsize); if (ret != txsize) { - usbip_uerr("sendmsg failed!, retval %d for %zd\n", ret, - txsize); + pr_err("sendmsg failed!, ret=%d for %zd\n", ret, + txsize); usbip_event_add(&vdev->ud, VDEV_EVENT_ERROR_TCP); return -1; } -- 1.7.5.1 ^ permalink raw reply related [flat|nested] 42+ messages in thread
* Re: [PATCH 01/12] staging: usbip: replace usbip_u{dbg,err,info} and 2011-05-20 4:36 ` matt mooney @ 2011-05-20 5:01 ` Greg KH -1 siblings, 0 replies; 42+ messages in thread From: Greg KH @ 2011-05-20 4:59 UTC (permalink / raw) To: matt mooney; +Cc: linux-kernel, kernel-janitors On Thu, May 19, 2011 at 09:36:55PM -0700, matt mooney wrote: > This switches all of the usbip_u{dbg,err,info} and printk statements to > dev_<level>, if possible, or pr_<level> macros. And removes a few > unnecessary debug statements. > > Signed-off-by: matt mooney <mfm@muteddisk.com> I've already applied this one, right? greg k-h ^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [PATCH 01/12] staging: usbip: replace usbip_u{dbg,err,info} and printk with dev_ and pr_ @ 2011-05-20 5:01 ` Greg KH 0 siblings, 0 replies; 42+ messages in thread From: Greg KH @ 2011-05-20 5:01 UTC (permalink / raw) To: matt mooney; +Cc: linux-kernel, kernel-janitors On Thu, May 19, 2011 at 09:36:55PM -0700, matt mooney wrote: > This switches all of the usbip_u{dbg,err,info} and printk statements to > dev_<level>, if possible, or pr_<level> macros. And removes a few > unnecessary debug statements. > > Signed-off-by: matt mooney <mfm@muteddisk.com> I've already applied this one, right? greg k-h ^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [PATCH 01/12] staging: usbip: replace usbip_u{dbg,err,info} and printk with dev_ and pr_ 2011-05-20 5:01 ` [PATCH 01/12] staging: usbip: replace usbip_u{dbg,err,info} and printk with dev_ and pr_ Greg KH @ 2011-05-20 5:25 ` matt mooney -1 siblings, 0 replies; 42+ messages in thread From: matt mooney @ 2011-05-20 5:25 UTC (permalink / raw) To: Greg KH; +Cc: matt mooney, linux-kernel, kernel-janitors On Thu, May 19, 2011 at 10:01 PM, Greg KH <greg@kroah.com> wrote: > On Thu, May 19, 2011 at 09:36:55PM -0700, matt mooney wrote: >> This switches all of the usbip_u{dbg,err,info} and printk statements to >> dev_<level>, if possible, or pr_<level> macros. And removes a few >> unnecessary debug statements. >> >> Signed-off-by: matt mooney <mfm@muteddisk.com> > > I've already applied this one, right? I don't think so. I never received a notification from your email bot ;) -- GPG-Key: 9AFE00EA ^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [PATCH 01/12] staging: usbip: replace usbip_u{dbg,err,info} and @ 2011-05-20 5:25 ` matt mooney 0 siblings, 0 replies; 42+ messages in thread From: matt mooney @ 2011-05-20 5:25 UTC (permalink / raw) To: Greg KH; +Cc: matt mooney, linux-kernel, kernel-janitors On Thu, May 19, 2011 at 10:01 PM, Greg KH <greg@kroah.com> wrote: > On Thu, May 19, 2011 at 09:36:55PM -0700, matt mooney wrote: >> This switches all of the usbip_u{dbg,err,info} and printk statements to >> dev_<level>, if possible, or pr_<level> macros. And removes a few >> unnecessary debug statements. >> >> Signed-off-by: matt mooney <mfm@muteddisk.com> > > I've already applied this one, right? I don't think so. I never received a notification from your email bot ;) -- GPG-Key: 9AFE00EA ^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [PATCH 01/12] staging: usbip: replace usbip_u{dbg,err,info} and printk with dev_ and pr_ 2011-05-20 5:25 ` [PATCH 01/12] staging: usbip: replace usbip_u{dbg,err,info} and matt mooney @ 2011-05-20 12:53 ` Greg KH -1 siblings, 0 replies; 42+ messages in thread From: Greg KH @ 2011-05-20 12:53 UTC (permalink / raw) To: matt mooney; +Cc: matt mooney, linux-kernel, kernel-janitors On Thu, May 19, 2011 at 10:25:25PM -0700, matt mooney wrote: > On Thu, May 19, 2011 at 10:01 PM, Greg KH <greg@kroah.com> wrote: > > On Thu, May 19, 2011 at 09:36:55PM -0700, matt mooney wrote: > >> This switches all of the usbip_u{dbg,err,info} and printk statements to > >> dev_<level>, if possible, or pr_<level> macros. And removes a few > >> unnecessary debug statements. > >> > >> Signed-off-by: matt mooney <mfm@muteddisk.com> > > > > I've already applied this one, right? > > I don't think so. I never received a notification from your email bot ;) Sorry, my bot went to sleep, you should have received it now. If not, please let me know and I'll see what happened. thanks, greg k-h ^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [PATCH 01/12] staging: usbip: replace usbip_u{dbg,err,info} and @ 2011-05-20 12:53 ` Greg KH 0 siblings, 0 replies; 42+ messages in thread From: Greg KH @ 2011-05-20 12:53 UTC (permalink / raw) To: matt mooney; +Cc: matt mooney, linux-kernel, kernel-janitors On Thu, May 19, 2011 at 10:25:25PM -0700, matt mooney wrote: > On Thu, May 19, 2011 at 10:01 PM, Greg KH <greg@kroah.com> wrote: > > On Thu, May 19, 2011 at 09:36:55PM -0700, matt mooney wrote: > >> This switches all of the usbip_u{dbg,err,info} and printk statements to > >> dev_<level>, if possible, or pr_<level> macros. And removes a few > >> unnecessary debug statements. > >> > >> Signed-off-by: matt mooney <mfm@muteddisk.com> > > > > I've already applied this one, right? > > I don't think so. I never received a notification from your email bot ;) Sorry, my bot went to sleep, you should have received it now. If not, please let me know and I'll see what happened. thanks, greg k-h ^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [PATCH 01/12] staging: usbip: replace usbip_u{dbg,err,info} and printk with dev_ and pr_ 2011-05-20 12:53 ` [PATCH 01/12] staging: usbip: replace usbip_u{dbg,err,info} and Greg KH @ 2011-05-20 18:51 ` matt mooney -1 siblings, 0 replies; 42+ messages in thread From: matt mooney @ 2011-05-20 18:51 UTC (permalink / raw) To: Greg KH; +Cc: matt mooney, linux-kernel, kernel-janitors On 05:53 Fri 20 May , Greg KH wrote: > On Thu, May 19, 2011 at 10:25:25PM -0700, matt mooney wrote: > > On Thu, May 19, 2011 at 10:01 PM, Greg KH <greg@kroah.com> wrote: > > > On Thu, May 19, 2011 at 09:36:55PM -0700, matt mooney wrote: > > >> This switches all of the usbip_u{dbg,err,info} and printk statements to > > >> dev_<level>, if possible, or pr_<level> macros. And removes a few > > >> unnecessary debug statements. > > >> > > >> Signed-off-by: matt mooney <mfm@muteddisk.com> > > > > > > I've already applied this one, right? > > > > I don't think so. I never received a notification from your email bot ;) > > Sorry, my bot went to sleep, you should have received it now. If not, > please let me know and I'll see what happened. Your bot must still be asleep! The patch is in your tree, but I never received an email; it could have been a problem on my end I. -matt ^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [PATCH 01/12] staging: usbip: replace usbip_u{dbg,err,info} and printk with dev_ and pr_ @ 2011-05-20 18:51 ` matt mooney 0 siblings, 0 replies; 42+ messages in thread From: matt mooney @ 2011-05-20 18:51 UTC (permalink / raw) To: Greg KH; +Cc: matt mooney, linux-kernel, kernel-janitors On 05:53 Fri 20 May , Greg KH wrote: > On Thu, May 19, 2011 at 10:25:25PM -0700, matt mooney wrote: > > On Thu, May 19, 2011 at 10:01 PM, Greg KH <greg@kroah.com> wrote: > > > On Thu, May 19, 2011 at 09:36:55PM -0700, matt mooney wrote: > > >> This switches all of the usbip_u{dbg,err,info} and printk statements to > > >> dev_<level>, if possible, or pr_<level> macros. And removes a few > > >> unnecessary debug statements. > > >> > > >> Signed-off-by: matt mooney <mfm@muteddisk.com> > > > > > > I've already applied this one, right? > > > > I don't think so. I never received a notification from your email bot ;) > > Sorry, my bot went to sleep, you should have received it now. If not, > please let me know and I'll see what happened. Your bot must still be asleep! The patch is in your tree, but I never received an email; it could have been a problem on my end I. -matt ^ permalink raw reply [flat|nested] 42+ messages in thread
* [PATCH 02/12] staging: usbip: remove unnecessary lines and extra return statements 2011-05-20 4:36 ` matt mooney @ 2011-05-20 4:36 ` matt mooney -1 siblings, 0 replies; 42+ messages in thread From: matt mooney @ 2011-05-20 4:36 UTC (permalink / raw) To: Greg Kroah-Hartman; +Cc: linux-kernel, kernel-janitors Also, fix a few alignment issues that were originally missed. Signed-off-by: matt mooney <mfm@muteddisk.com> --- drivers/staging/usbip/stub.h | 1 + drivers/staging/usbip/stub_dev.c | 21 +++++++-------------- drivers/staging/usbip/stub_main.c | 13 ------------- drivers/staging/usbip/stub_tx.c | 13 ++++++------- drivers/staging/usbip/usbip_common.c | 13 ++++++------- drivers/staging/usbip/usbip_common.h | 2 +- drivers/staging/usbip/vhci_hcd.c | 9 +++------ drivers/staging/usbip/vhci_rx.c | 2 -- 8 files changed, 24 insertions(+), 50 deletions(-) diff --git a/drivers/staging/usbip/stub.h b/drivers/staging/usbip/stub.h index 6592aa2..2cc596e 100644 --- a/drivers/staging/usbip/stub.h +++ b/drivers/staging/usbip/stub.h @@ -77,6 +77,7 @@ struct stub_unlink { }; #define BUSID_SIZE 20 + struct bus_id_priv { char name[BUSID_SIZE]; char status; diff --git a/drivers/staging/usbip/stub_dev.c b/drivers/staging/usbip/stub_dev.c index 6e99ec8..e35d62c 100644 --- a/drivers/staging/usbip/stub_dev.c +++ b/drivers/staging/usbip/stub_dev.c @@ -207,10 +207,11 @@ static void stub_shutdown_connection(struct usbip_device *ud) if (ud->tcp_tx && !task_is_dead(ud->tcp_tx)) kthread_stop(ud->tcp_tx); - /* 2. close the socket */ /* - * tcp_socket is freed after threads are killed. - * So usbip_xmit do not touch NULL socket. + * 2. close the socket + * + * tcp_socket is freed after threads are killed so that usbip_xmit does + * not touch NULL socket. */ if (ud->tcp_socket) { sock_release(ud->tcp_socket); @@ -230,8 +231,8 @@ static void stub_shutdown_connection(struct usbip_device *ud) list_del(&unlink->list); kfree(unlink); } - list_for_each_entry_safe(unlink, tmp, - &sdev->unlink_free, list) { + list_for_each_entry_safe(unlink, tmp, &sdev->unlink_free, + list) { list_del(&unlink->list); kfree(unlink); } @@ -258,22 +259,17 @@ static void stub_device_reset(struct usbip_device *ud) /* try to reset the device */ ret = usb_reset_device(udev); - usb_unlock_device(udev); spin_lock(&ud->lock); if (ret) { dev_err(&udev->dev, "device reset\n"); ud->status = SDEV_ST_ERROR; - } else { dev_info(&udev->dev, "device reset\n"); ud->status = SDEV_ST_AVAILABLE; - } spin_unlock(&ud->lock); - - return; } static void stub_device_unusable(struct usbip_device *ud) @@ -375,7 +371,7 @@ static int stub_probe(struct usb_interface *interface, /* check we should claim or not by busid_table */ busid_priv = get_busid_priv(udev_busid); - if (!busid_priv || (busid_priv->status == STUB_BUSID_REMOV) || + if (!busid_priv || (busid_priv->status == STUB_BUSID_REMOV) || (busid_priv->status == STUB_BUSID_OTHER)) { dev_info(&interface->dev, "%s is not in match_busid table... " "skip!\n", udev_busid); @@ -420,7 +416,6 @@ static int stub_probe(struct usb_interface *interface, udev_busid); usb_set_intfdata(interface, NULL); busid_priv->interf_count--; - return err; } @@ -443,7 +438,6 @@ static int stub_probe(struct usb_interface *interface, /* set private data to usb_interface */ usb_set_intfdata(interface, sdev); busid_priv->interf_count++; - busid_priv->sdev = sdev; err = stub_add_files(&interface->dev); @@ -453,7 +447,6 @@ static int stub_probe(struct usb_interface *interface, usb_put_intf(interface); busid_priv->interf_count = 0; - busid_priv->sdev = NULL; stub_device_free(sdev); return err; diff --git a/drivers/staging/usbip/stub_main.c b/drivers/staging/usbip/stub_main.c index e9085d6..44671ee 100644 --- a/drivers/staging/usbip/stub_main.c +++ b/drivers/staging/usbip/stub_main.c @@ -25,9 +25,7 @@ #define DRIVER_AUTHOR "Takahiro Hirofuchi" #define DRIVER_DESC "USB/IP Host Driver" -/* stub_priv is allocated from stub_priv_cache */ struct kmem_cache *stub_priv_cache; - /* * busid_tables defines matching busids that usbip can grab. A user can change * dynamically what device is locally used and what device is exported to a @@ -42,7 +40,6 @@ int match_busid(const char *busid) int i; spin_lock(&busid_table_lock); - for (i = 0; i < MAX_BUSID; i++) if (busid_table[i].name[0]) if (!strncmp(busid_table[i].name, busid, BUSID_SIZE)) { @@ -50,7 +47,6 @@ int match_busid(const char *busid) spin_unlock(&busid_table_lock); return 0; } - spin_unlock(&busid_table_lock); return 1; @@ -61,7 +57,6 @@ struct bus_id_priv *get_busid_priv(const char *busid) int i; spin_lock(&busid_table_lock); - for (i = 0; i < MAX_BUSID; i++) if (busid_table[i].name[0]) if (!strncmp(busid_table[i].name, busid, BUSID_SIZE)) { @@ -69,7 +64,6 @@ struct bus_id_priv *get_busid_priv(const char *busid) spin_unlock(&busid_table_lock); return &(busid_table[i]); } - spin_unlock(&busid_table_lock); return NULL; @@ -81,15 +75,12 @@ static ssize_t show_match_busid(struct device_driver *drv, char *buf) char *out = buf; spin_lock(&busid_table_lock); - for (i = 0; i < MAX_BUSID; i++) if (busid_table[i].name[0]) out += sprintf(out, "%s ", busid_table[i].name); - spin_unlock(&busid_table_lock); out += sprintf(out, "\n"); - return out - buf; } @@ -101,7 +92,6 @@ static int add_match_busid(char *busid) return 0; spin_lock(&busid_table_lock); - for (i = 0; i < MAX_BUSID; i++) if (!busid_table[i].name[0]) { strncpy(busid_table[i].name, busid, BUSID_SIZE); @@ -111,7 +101,6 @@ static int add_match_busid(char *busid) spin_unlock(&busid_table_lock); return 0; } - spin_unlock(&busid_table_lock); return -1; @@ -122,7 +111,6 @@ int del_match_busid(char *busid) int i; spin_lock(&busid_table_lock); - for (i = 0; i < MAX_BUSID; i++) if (!strncmp(busid_table[i].name, busid, BUSID_SIZE)) { /* found */ @@ -135,7 +123,6 @@ int del_match_busid(char *busid) spin_unlock(&busid_table_lock); return 0; } - spin_unlock(&busid_table_lock); return -1; diff --git a/drivers/staging/usbip/stub_tx.c b/drivers/staging/usbip/stub_tx.c index fda2bc9..1cbae44 100644 --- a/drivers/staging/usbip/stub_tx.c +++ b/drivers/staging/usbip/stub_tx.c @@ -97,13 +97,12 @@ void stub_complete(struct urb *urb) /* link a urb to the queue of tx. */ spin_lock_irqsave(&sdev->priv_lock, flags); - if (priv->unlinking) { stub_enqueue_ret_unlink(sdev, priv->seqnum, urb->status); stub_free_priv_and_urb(priv); - } else + } else { list_move_tail(&priv->list, &sdev->priv_tx); - + } spin_unlock_irqrestore(&sdev->priv_lock, flags); /* wake up tx_thread */ @@ -113,10 +112,10 @@ void stub_complete(struct urb *urb) static inline void setup_base_pdu(struct usbip_header_basic *base, __u32 command, __u32 seqnum) { - base->command = command; - base->seqnum = seqnum; - base->devid = 0; - base->ep = 0; + base->command = command; + base->seqnum = seqnum; + base->devid = 0; + base->ep = 0; base->direction = 0; } diff --git a/drivers/staging/usbip/usbip_common.c b/drivers/staging/usbip/usbip_common.c index 433a3b6..954d90d 100644 --- a/drivers/staging/usbip/usbip_common.c +++ b/drivers/staging/usbip/usbip_common.c @@ -63,9 +63,9 @@ static void usbip_dump_buffer(char *buff, int bufflen) static void usbip_dump_pipe(unsigned int p) { unsigned char type = usb_pipetype(p); - unsigned char ep = usb_pipeendpoint(p); - unsigned char dev = usb_pipedevice(p); - unsigned char dir = usb_pipein(p); + unsigned char ep = usb_pipeendpoint(p); + unsigned char dev = usb_pipedevice(p); + unsigned char dir = usb_pipein(p); pr_debug("dev(%d) ep(%d) [%s] ", dev, ep, dir ? "IN" : "OUT"); @@ -334,8 +334,8 @@ void usbip_dump_header(struct usbip_header *pdu) EXPORT_SYMBOL_GPL(usbip_dump_header); /* Send/receive messages over TCP/IP. I refer drivers/block/nbd.c */ -int usbip_xmit(int send, struct socket *sock, char *buf, - int size, int msg_flags) +int usbip_xmit(int send, struct socket *sock, char *buf, int size, + int msg_flags) { int result; struct msghdr msg; @@ -628,8 +628,7 @@ void usbip_header_correct_endian(struct usbip_header *pdu, int send) EXPORT_SYMBOL_GPL(usbip_header_correct_endian); static void usbip_iso_pakcet_correct_endian( - struct usbip_iso_packet_descriptor *iso, - int send) + struct usbip_iso_packet_descriptor *iso, int send) { /* does not need all members. but copy all simply. */ if (send) { diff --git a/drivers/staging/usbip/usbip_common.h b/drivers/staging/usbip/usbip_common.h index 4a641c5..83f8c1e 100644 --- a/drivers/staging/usbip/usbip_common.h +++ b/drivers/staging/usbip/usbip_common.h @@ -65,7 +65,7 @@ enum { #define usbip_dbg_flag_vhci_tx (usbip_debug_flag & usbip_debug_vhci_tx) #define usbip_dbg_flag_stub_rx (usbip_debug_flag & usbip_debug_stub_rx) #define usbip_dbg_flag_stub_tx (usbip_debug_flag & usbip_debug_stub_tx) -#define usbip_dbg_flag_vhci_sysfs (usbip_debug_flag & usbip_debug_vhci_sysfs) +#define usbip_dbg_flag_vhci_sysfs (usbip_debug_flag & usbip_debug_vhci_sysfs) extern unsigned long usbip_debug_flag; extern struct device_attribute dev_attr_usbip_debug; diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c index a76e8fa..5b94b80 100644 --- a/drivers/staging/usbip/vhci_hcd.c +++ b/drivers/staging/usbip/vhci_hcd.c @@ -344,9 +344,9 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, * */ if (dum->resuming && time_after(jiffies, dum->re_timeout)) { dum->port_status[rhport] |= - (1 << USB_PORT_FEAT_C_SUSPEND); + (1 << USB_PORT_FEAT_C_SUSPEND); dum->port_status[rhport] &= - ~(1 << USB_PORT_FEAT_SUSPEND); + ~(1 << USB_PORT_FEAT_SUSPEND); dum->resuming = 0; dum->re_timeout = 0; /* if (dum->driver && dum->driver->resume) { @@ -639,9 +639,7 @@ no_need_xmit: usb_hcd_unlink_urb_from_ep(hcd, urb); no_need_unlink: spin_unlock_irqrestore(&the_controller->lock, flags); - usb_hcd_giveback_urb(vhci_to_hcd(the_controller), urb, urb->status); - return ret; } @@ -1033,9 +1031,8 @@ static int vhci_bus_resume(struct usb_hcd *hcd) hcd->state = HC_STATE_RUNNING; } spin_unlock_irq(&vhci->lock); - return rc; - return 0; + return rc; } #else diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c index e42ce9d..09c44ab 100644 --- a/drivers/staging/usbip/vhci_rx.c +++ b/drivers/staging/usbip/vhci_rx.c @@ -179,8 +179,6 @@ static void vhci_recv_ret_unlink(struct vhci_device *vdev, } kfree(unlink); - - return; } static int vhci_priv_tx_empty(struct vhci_device *vdev) -- 1.7.5.1 ^ permalink raw reply related [flat|nested] 42+ messages in thread
* [PATCH 02/12] staging: usbip: remove unnecessary lines and extra return statements @ 2011-05-20 4:36 ` matt mooney 0 siblings, 0 replies; 42+ messages in thread From: matt mooney @ 2011-05-20 4:36 UTC (permalink / raw) To: Greg Kroah-Hartman; +Cc: linux-kernel, kernel-janitors Also, fix a few alignment issues that were originally missed. Signed-off-by: matt mooney <mfm@muteddisk.com> --- drivers/staging/usbip/stub.h | 1 + drivers/staging/usbip/stub_dev.c | 21 +++++++-------------- drivers/staging/usbip/stub_main.c | 13 ------------- drivers/staging/usbip/stub_tx.c | 13 ++++++------- drivers/staging/usbip/usbip_common.c | 13 ++++++------- drivers/staging/usbip/usbip_common.h | 2 +- drivers/staging/usbip/vhci_hcd.c | 9 +++------ drivers/staging/usbip/vhci_rx.c | 2 -- 8 files changed, 24 insertions(+), 50 deletions(-) diff --git a/drivers/staging/usbip/stub.h b/drivers/staging/usbip/stub.h index 6592aa2..2cc596e 100644 --- a/drivers/staging/usbip/stub.h +++ b/drivers/staging/usbip/stub.h @@ -77,6 +77,7 @@ struct stub_unlink { }; #define BUSID_SIZE 20 + struct bus_id_priv { char name[BUSID_SIZE]; char status; diff --git a/drivers/staging/usbip/stub_dev.c b/drivers/staging/usbip/stub_dev.c index 6e99ec8..e35d62c 100644 --- a/drivers/staging/usbip/stub_dev.c +++ b/drivers/staging/usbip/stub_dev.c @@ -207,10 +207,11 @@ static void stub_shutdown_connection(struct usbip_device *ud) if (ud->tcp_tx && !task_is_dead(ud->tcp_tx)) kthread_stop(ud->tcp_tx); - /* 2. close the socket */ /* - * tcp_socket is freed after threads are killed. - * So usbip_xmit do not touch NULL socket. + * 2. close the socket + * + * tcp_socket is freed after threads are killed so that usbip_xmit does + * not touch NULL socket. */ if (ud->tcp_socket) { sock_release(ud->tcp_socket); @@ -230,8 +231,8 @@ static void stub_shutdown_connection(struct usbip_device *ud) list_del(&unlink->list); kfree(unlink); } - list_for_each_entry_safe(unlink, tmp, - &sdev->unlink_free, list) { + list_for_each_entry_safe(unlink, tmp, &sdev->unlink_free, + list) { list_del(&unlink->list); kfree(unlink); } @@ -258,22 +259,17 @@ static void stub_device_reset(struct usbip_device *ud) /* try to reset the device */ ret = usb_reset_device(udev); - usb_unlock_device(udev); spin_lock(&ud->lock); if (ret) { dev_err(&udev->dev, "device reset\n"); ud->status = SDEV_ST_ERROR; - } else { dev_info(&udev->dev, "device reset\n"); ud->status = SDEV_ST_AVAILABLE; - } spin_unlock(&ud->lock); - - return; } static void stub_device_unusable(struct usbip_device *ud) @@ -375,7 +371,7 @@ static int stub_probe(struct usb_interface *interface, /* check we should claim or not by busid_table */ busid_priv = get_busid_priv(udev_busid); - if (!busid_priv || (busid_priv->status = STUB_BUSID_REMOV) || + if (!busid_priv || (busid_priv->status = STUB_BUSID_REMOV) || (busid_priv->status = STUB_BUSID_OTHER)) { dev_info(&interface->dev, "%s is not in match_busid table... " "skip!\n", udev_busid); @@ -420,7 +416,6 @@ static int stub_probe(struct usb_interface *interface, udev_busid); usb_set_intfdata(interface, NULL); busid_priv->interf_count--; - return err; } @@ -443,7 +438,6 @@ static int stub_probe(struct usb_interface *interface, /* set private data to usb_interface */ usb_set_intfdata(interface, sdev); busid_priv->interf_count++; - busid_priv->sdev = sdev; err = stub_add_files(&interface->dev); @@ -453,7 +447,6 @@ static int stub_probe(struct usb_interface *interface, usb_put_intf(interface); busid_priv->interf_count = 0; - busid_priv->sdev = NULL; stub_device_free(sdev); return err; diff --git a/drivers/staging/usbip/stub_main.c b/drivers/staging/usbip/stub_main.c index e9085d6..44671ee 100644 --- a/drivers/staging/usbip/stub_main.c +++ b/drivers/staging/usbip/stub_main.c @@ -25,9 +25,7 @@ #define DRIVER_AUTHOR "Takahiro Hirofuchi" #define DRIVER_DESC "USB/IP Host Driver" -/* stub_priv is allocated from stub_priv_cache */ struct kmem_cache *stub_priv_cache; - /* * busid_tables defines matching busids that usbip can grab. A user can change * dynamically what device is locally used and what device is exported to a @@ -42,7 +40,6 @@ int match_busid(const char *busid) int i; spin_lock(&busid_table_lock); - for (i = 0; i < MAX_BUSID; i++) if (busid_table[i].name[0]) if (!strncmp(busid_table[i].name, busid, BUSID_SIZE)) { @@ -50,7 +47,6 @@ int match_busid(const char *busid) spin_unlock(&busid_table_lock); return 0; } - spin_unlock(&busid_table_lock); return 1; @@ -61,7 +57,6 @@ struct bus_id_priv *get_busid_priv(const char *busid) int i; spin_lock(&busid_table_lock); - for (i = 0; i < MAX_BUSID; i++) if (busid_table[i].name[0]) if (!strncmp(busid_table[i].name, busid, BUSID_SIZE)) { @@ -69,7 +64,6 @@ struct bus_id_priv *get_busid_priv(const char *busid) spin_unlock(&busid_table_lock); return &(busid_table[i]); } - spin_unlock(&busid_table_lock); return NULL; @@ -81,15 +75,12 @@ static ssize_t show_match_busid(struct device_driver *drv, char *buf) char *out = buf; spin_lock(&busid_table_lock); - for (i = 0; i < MAX_BUSID; i++) if (busid_table[i].name[0]) out += sprintf(out, "%s ", busid_table[i].name); - spin_unlock(&busid_table_lock); out += sprintf(out, "\n"); - return out - buf; } @@ -101,7 +92,6 @@ static int add_match_busid(char *busid) return 0; spin_lock(&busid_table_lock); - for (i = 0; i < MAX_BUSID; i++) if (!busid_table[i].name[0]) { strncpy(busid_table[i].name, busid, BUSID_SIZE); @@ -111,7 +101,6 @@ static int add_match_busid(char *busid) spin_unlock(&busid_table_lock); return 0; } - spin_unlock(&busid_table_lock); return -1; @@ -122,7 +111,6 @@ int del_match_busid(char *busid) int i; spin_lock(&busid_table_lock); - for (i = 0; i < MAX_BUSID; i++) if (!strncmp(busid_table[i].name, busid, BUSID_SIZE)) { /* found */ @@ -135,7 +123,6 @@ int del_match_busid(char *busid) spin_unlock(&busid_table_lock); return 0; } - spin_unlock(&busid_table_lock); return -1; diff --git a/drivers/staging/usbip/stub_tx.c b/drivers/staging/usbip/stub_tx.c index fda2bc9..1cbae44 100644 --- a/drivers/staging/usbip/stub_tx.c +++ b/drivers/staging/usbip/stub_tx.c @@ -97,13 +97,12 @@ void stub_complete(struct urb *urb) /* link a urb to the queue of tx. */ spin_lock_irqsave(&sdev->priv_lock, flags); - if (priv->unlinking) { stub_enqueue_ret_unlink(sdev, priv->seqnum, urb->status); stub_free_priv_and_urb(priv); - } else + } else { list_move_tail(&priv->list, &sdev->priv_tx); - + } spin_unlock_irqrestore(&sdev->priv_lock, flags); /* wake up tx_thread */ @@ -113,10 +112,10 @@ void stub_complete(struct urb *urb) static inline void setup_base_pdu(struct usbip_header_basic *base, __u32 command, __u32 seqnum) { - base->command = command; - base->seqnum = seqnum; - base->devid = 0; - base->ep = 0; + base->command = command; + base->seqnum = seqnum; + base->devid = 0; + base->ep = 0; base->direction = 0; } diff --git a/drivers/staging/usbip/usbip_common.c b/drivers/staging/usbip/usbip_common.c index 433a3b6..954d90d 100644 --- a/drivers/staging/usbip/usbip_common.c +++ b/drivers/staging/usbip/usbip_common.c @@ -63,9 +63,9 @@ static void usbip_dump_buffer(char *buff, int bufflen) static void usbip_dump_pipe(unsigned int p) { unsigned char type = usb_pipetype(p); - unsigned char ep = usb_pipeendpoint(p); - unsigned char dev = usb_pipedevice(p); - unsigned char dir = usb_pipein(p); + unsigned char ep = usb_pipeendpoint(p); + unsigned char dev = usb_pipedevice(p); + unsigned char dir = usb_pipein(p); pr_debug("dev(%d) ep(%d) [%s] ", dev, ep, dir ? "IN" : "OUT"); @@ -334,8 +334,8 @@ void usbip_dump_header(struct usbip_header *pdu) EXPORT_SYMBOL_GPL(usbip_dump_header); /* Send/receive messages over TCP/IP. I refer drivers/block/nbd.c */ -int usbip_xmit(int send, struct socket *sock, char *buf, - int size, int msg_flags) +int usbip_xmit(int send, struct socket *sock, char *buf, int size, + int msg_flags) { int result; struct msghdr msg; @@ -628,8 +628,7 @@ void usbip_header_correct_endian(struct usbip_header *pdu, int send) EXPORT_SYMBOL_GPL(usbip_header_correct_endian); static void usbip_iso_pakcet_correct_endian( - struct usbip_iso_packet_descriptor *iso, - int send) + struct usbip_iso_packet_descriptor *iso, int send) { /* does not need all members. but copy all simply. */ if (send) { diff --git a/drivers/staging/usbip/usbip_common.h b/drivers/staging/usbip/usbip_common.h index 4a641c5..83f8c1e 100644 --- a/drivers/staging/usbip/usbip_common.h +++ b/drivers/staging/usbip/usbip_common.h @@ -65,7 +65,7 @@ enum { #define usbip_dbg_flag_vhci_tx (usbip_debug_flag & usbip_debug_vhci_tx) #define usbip_dbg_flag_stub_rx (usbip_debug_flag & usbip_debug_stub_rx) #define usbip_dbg_flag_stub_tx (usbip_debug_flag & usbip_debug_stub_tx) -#define usbip_dbg_flag_vhci_sysfs (usbip_debug_flag & usbip_debug_vhci_sysfs) +#define usbip_dbg_flag_vhci_sysfs (usbip_debug_flag & usbip_debug_vhci_sysfs) extern unsigned long usbip_debug_flag; extern struct device_attribute dev_attr_usbip_debug; diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c index a76e8fa..5b94b80 100644 --- a/drivers/staging/usbip/vhci_hcd.c +++ b/drivers/staging/usbip/vhci_hcd.c @@ -344,9 +344,9 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, * */ if (dum->resuming && time_after(jiffies, dum->re_timeout)) { dum->port_status[rhport] |- (1 << USB_PORT_FEAT_C_SUSPEND); + (1 << USB_PORT_FEAT_C_SUSPEND); dum->port_status[rhport] &- ~(1 << USB_PORT_FEAT_SUSPEND); + ~(1 << USB_PORT_FEAT_SUSPEND); dum->resuming = 0; dum->re_timeout = 0; /* if (dum->driver && dum->driver->resume) { @@ -639,9 +639,7 @@ no_need_xmit: usb_hcd_unlink_urb_from_ep(hcd, urb); no_need_unlink: spin_unlock_irqrestore(&the_controller->lock, flags); - usb_hcd_giveback_urb(vhci_to_hcd(the_controller), urb, urb->status); - return ret; } @@ -1033,9 +1031,8 @@ static int vhci_bus_resume(struct usb_hcd *hcd) hcd->state = HC_STATE_RUNNING; } spin_unlock_irq(&vhci->lock); - return rc; - return 0; + return rc; } #else diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c index e42ce9d..09c44ab 100644 --- a/drivers/staging/usbip/vhci_rx.c +++ b/drivers/staging/usbip/vhci_rx.c @@ -179,8 +179,6 @@ static void vhci_recv_ret_unlink(struct vhci_device *vdev, } kfree(unlink); - - return; } static int vhci_priv_tx_empty(struct vhci_device *vdev) -- 1.7.5.1 ^ permalink raw reply related [flat|nested] 42+ messages in thread
* [PATCH 03/12] staging: usbip: stub_main.c: reorder functions 2011-05-20 4:36 ` matt mooney @ 2011-05-20 4:36 ` matt mooney -1 siblings, 0 replies; 42+ messages in thread From: matt mooney @ 2011-05-20 4:36 UTC (permalink / raw) To: Greg Kroah-Hartman; +Cc: linux-kernel, kernel-janitors Reorder functions so sysfs_ops, show() and store(), are adjacent, and init_busid_table() is at the beginning of the file. Signed-off-by: matt mooney <mfm@muteddisk.com> --- drivers/staging/usbip/stub_main.c | 48 ++++++++++++++++++------------------ 1 files changed, 24 insertions(+), 24 deletions(-) diff --git a/drivers/staging/usbip/stub_main.c b/drivers/staging/usbip/stub_main.c index 44671ee..0ca1462 100644 --- a/drivers/staging/usbip/stub_main.c +++ b/drivers/staging/usbip/stub_main.c @@ -35,6 +35,21 @@ struct kmem_cache *stub_priv_cache; static struct bus_id_priv busid_table[MAX_BUSID]; static spinlock_t busid_table_lock; +static void init_busid_table(void) +{ + int i; + + for (i = 0; i < MAX_BUSID; i++) { + memset(busid_table[i].name, 0, BUSID_SIZE); + busid_table[i].status = STUB_BUSID_OTHER; + busid_table[i].interf_count = 0; + busid_table[i].sdev = NULL; + busid_table[i].shutdown_busid = 0; + } + + spin_lock_init(&busid_table_lock); +} + int match_busid(const char *busid) { int i; @@ -69,21 +84,6 @@ struct bus_id_priv *get_busid_priv(const char *busid) return NULL; } -static ssize_t show_match_busid(struct device_driver *drv, char *buf) -{ - int i; - char *out = buf; - - spin_lock(&busid_table_lock); - for (i = 0; i < MAX_BUSID; i++) - if (busid_table[i].name[0]) - out += sprintf(out, "%s ", busid_table[i].name); - spin_unlock(&busid_table_lock); - - out += sprintf(out, "\n"); - return out - buf; -} - static int add_match_busid(char *busid) { int i; @@ -128,19 +128,19 @@ int del_match_busid(char *busid) return -1; } -static void init_busid_table(void) +static ssize_t show_match_busid(struct device_driver *drv, char *buf) { int i; + char *out = buf; - for (i = 0; i < MAX_BUSID; i++) { - memset(busid_table[i].name, 0, BUSID_SIZE); - busid_table[i].status = STUB_BUSID_OTHER; - busid_table[i].interf_count = 0; - busid_table[i].sdev = NULL; - busid_table[i].shutdown_busid = 0; - } + spin_lock(&busid_table_lock); + for (i = 0; i < MAX_BUSID; i++) + if (busid_table[i].name[0]) + out += sprintf(out, "%s ", busid_table[i].name); + spin_unlock(&busid_table_lock); - spin_lock_init(&busid_table_lock); + out += sprintf(out, "\n"); + return out - buf; } static ssize_t store_match_busid(struct device_driver *dev, const char *buf, -- 1.7.5.1 ^ permalink raw reply related [flat|nested] 42+ messages in thread
* [PATCH 03/12] staging: usbip: stub_main.c: reorder functions @ 2011-05-20 4:36 ` matt mooney 0 siblings, 0 replies; 42+ messages in thread From: matt mooney @ 2011-05-20 4:36 UTC (permalink / raw) To: Greg Kroah-Hartman; +Cc: linux-kernel, kernel-janitors Reorder functions so sysfs_ops, show() and store(), are adjacent, and init_busid_table() is at the beginning of the file. Signed-off-by: matt mooney <mfm@muteddisk.com> --- drivers/staging/usbip/stub_main.c | 48 ++++++++++++++++++------------------ 1 files changed, 24 insertions(+), 24 deletions(-) diff --git a/drivers/staging/usbip/stub_main.c b/drivers/staging/usbip/stub_main.c index 44671ee..0ca1462 100644 --- a/drivers/staging/usbip/stub_main.c +++ b/drivers/staging/usbip/stub_main.c @@ -35,6 +35,21 @@ struct kmem_cache *stub_priv_cache; static struct bus_id_priv busid_table[MAX_BUSID]; static spinlock_t busid_table_lock; +static void init_busid_table(void) +{ + int i; + + for (i = 0; i < MAX_BUSID; i++) { + memset(busid_table[i].name, 0, BUSID_SIZE); + busid_table[i].status = STUB_BUSID_OTHER; + busid_table[i].interf_count = 0; + busid_table[i].sdev = NULL; + busid_table[i].shutdown_busid = 0; + } + + spin_lock_init(&busid_table_lock); +} + int match_busid(const char *busid) { int i; @@ -69,21 +84,6 @@ struct bus_id_priv *get_busid_priv(const char *busid) return NULL; } -static ssize_t show_match_busid(struct device_driver *drv, char *buf) -{ - int i; - char *out = buf; - - spin_lock(&busid_table_lock); - for (i = 0; i < MAX_BUSID; i++) - if (busid_table[i].name[0]) - out += sprintf(out, "%s ", busid_table[i].name); - spin_unlock(&busid_table_lock); - - out += sprintf(out, "\n"); - return out - buf; -} - static int add_match_busid(char *busid) { int i; @@ -128,19 +128,19 @@ int del_match_busid(char *busid) return -1; } -static void init_busid_table(void) +static ssize_t show_match_busid(struct device_driver *drv, char *buf) { int i; + char *out = buf; - for (i = 0; i < MAX_BUSID; i++) { - memset(busid_table[i].name, 0, BUSID_SIZE); - busid_table[i].status = STUB_BUSID_OTHER; - busid_table[i].interf_count = 0; - busid_table[i].sdev = NULL; - busid_table[i].shutdown_busid = 0; - } + spin_lock(&busid_table_lock); + for (i = 0; i < MAX_BUSID; i++) + if (busid_table[i].name[0]) + out += sprintf(out, "%s ", busid_table[i].name); + spin_unlock(&busid_table_lock); - spin_lock_init(&busid_table_lock); + out += sprintf(out, "\n"); + return out - buf; } static ssize_t store_match_busid(struct device_driver *dev, const char *buf, -- 1.7.5.1 ^ permalink raw reply related [flat|nested] 42+ messages in thread
* Re: [PATCH 03/12] staging: usbip: stub_main.c: reorder functions 2011-05-20 4:36 ` matt mooney (?) @ 2011-05-20 8:37 ` walter harms -1 siblings, 0 replies; 42+ messages in thread From: walter harms @ 2011-05-20 8:37 UTC (permalink / raw) To: kernel-janitors Am 20.05.2011 06:36, schrieb matt mooney: > Reorder functions so sysfs_ops, show() and store(), are adjacent, and > init_busid_table() is at the beginning of the file. > > Signed-off-by: matt mooney <mfm@muteddisk.com> > --- > drivers/staging/usbip/stub_main.c | 48 ++++++++++++++++++------------------ > 1 files changed, 24 insertions(+), 24 deletions(-) > > diff --git a/drivers/staging/usbip/stub_main.c b/drivers/staging/usbip/stub_main.c > index 44671ee..0ca1462 100644 > --- a/drivers/staging/usbip/stub_main.c > +++ b/drivers/staging/usbip/stub_main.c > @@ -35,6 +35,21 @@ struct kmem_cache *stub_priv_cache; > static struct bus_id_priv busid_table[MAX_BUSID]; > static spinlock_t busid_table_lock; > > +static void init_busid_table(void) > +{ > + int i; > + > + for (i = 0; i < MAX_BUSID; i++) { > + memset(busid_table[i].name, 0, BUSID_SIZE); > + busid_table[i].status = STUB_BUSID_OTHER; > + busid_table[i].interf_count = 0; > + busid_table[i].sdev = NULL; > + busid_table[i].shutdown_busid = 0; > + } > + > + spin_lock_init(&busid_table_lock); > +} > + Is it possible to have something like: busid_table=kcalloc(MAX_BUSID,sizeof(*busid_table); /* not sure please check first */ that would have the advantage that everything is 0 (including padding) so you need to set busid_table[i].status = STUB_BUSID_OTHER; only. A more simple version would be: for() memset(busid_table[i], 0, sizeof(*busid_table)); busid_table[i].status = STUB_BUSID_OTHER; just my two cents > int match_busid(const char *busid) > { > int i; > @@ -69,21 +84,6 @@ struct bus_id_priv *get_busid_priv(const char *busid) > return NULL; > } > > -static ssize_t show_match_busid(struct device_driver *drv, char *buf) > -{ > - int i; > - char *out = buf; > - > - spin_lock(&busid_table_lock); > - for (i = 0; i < MAX_BUSID; i++) > - if (busid_table[i].name[0]) > - out += sprintf(out, "%s ", busid_table[i].name); > - spin_unlock(&busid_table_lock); > - > - out += sprintf(out, "\n"); > - return out - buf; > -} > - > static int add_match_busid(char *busid) > { > int i; > @@ -128,19 +128,19 @@ int del_match_busid(char *busid) > return -1; > } > > -static void init_busid_table(void) > +static ssize_t show_match_busid(struct device_driver *drv, char *buf) > { > int i; > + char *out = buf; > > - for (i = 0; i < MAX_BUSID; i++) { > - memset(busid_table[i].name, 0, BUSID_SIZE); > - busid_table[i].status = STUB_BUSID_OTHER; > - busid_table[i].interf_count = 0; > - busid_table[i].sdev = NULL; > - busid_table[i].shutdown_busid = 0; > - } > + spin_lock(&busid_table_lock); > + for (i = 0; i < MAX_BUSID; i++) > + if (busid_table[i].name[0]) > + out += sprintf(out, "%s ", busid_table[i].name); > + spin_unlock(&busid_table_lock); > > - spin_lock_init(&busid_table_lock); > + out += sprintf(out, "\n"); > + return out - buf; > } > > static ssize_t store_match_busid(struct device_driver *dev, const char *buf, ^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [PATCH 03/12] staging: usbip: stub_main.c: reorder functions 2011-05-20 4:36 ` matt mooney (?) (?) @ 2011-05-20 18:42 ` matt mooney -1 siblings, 0 replies; 42+ messages in thread From: matt mooney @ 2011-05-20 18:42 UTC (permalink / raw) To: kernel-janitors On 10:37 Fri 20 May , walter harms wrote: > > > Am 20.05.2011 06:36, schrieb matt mooney: > > Reorder functions so sysfs_ops, show() and store(), are adjacent, and > > init_busid_table() is at the beginning of the file. > > > > Signed-off-by: matt mooney <mfm@muteddisk.com> > > --- > > drivers/staging/usbip/stub_main.c | 48 ++++++++++++++++++------------------ > > 1 files changed, 24 insertions(+), 24 deletions(-) > > > > diff --git a/drivers/staging/usbip/stub_main.c b/drivers/staging/usbip/stub_main.c > > index 44671ee..0ca1462 100644 > > --- a/drivers/staging/usbip/stub_main.c > > +++ b/drivers/staging/usbip/stub_main.c > > @@ -35,6 +35,21 @@ struct kmem_cache *stub_priv_cache; > > static struct bus_id_priv busid_table[MAX_BUSID]; > > static spinlock_t busid_table_lock; > > > > +static void init_busid_table(void) > > +{ > > + int i; > > + > > + for (i = 0; i < MAX_BUSID; i++) { > > + memset(busid_table[i].name, 0, BUSID_SIZE); > > + busid_table[i].status = STUB_BUSID_OTHER; > > + busid_table[i].interf_count = 0; > > + busid_table[i].sdev = NULL; > > + busid_table[i].shutdown_busid = 0; > > + } > > + > > + spin_lock_init(&busid_table_lock); > > +} > > + > > > > Is it possible to have something like: > busid_table=kcalloc(MAX_BUSID,sizeof(*busid_table); /* not sure please check first */ > that would have the advantage that everything is 0 (including padding) > so you need to set > busid_table[i].status = STUB_BUSID_OTHER; > only. Hi Walter, Using kcalloc would definitely work, but since the size is static, I think it is simpler to not use it so that a check for NULL and a call to kfree are not needed. > A more simple version would be: > > for() > memset(busid_table[i], 0, sizeof(*busid_table)); > busid_table[i].status = STUB_BUSID_OTHER; You are right! I almost did this earlier, and now that you suggest it I will go ahead and make the change (without the * of course). Thanks, matt > > just my two cents > > > int match_busid(const char *busid) > > { > > int i; > > @@ -69,21 +84,6 @@ struct bus_id_priv *get_busid_priv(const char *busid) > > return NULL; > > } > > > > -static ssize_t show_match_busid(struct device_driver *drv, char *buf) > > -{ > > - int i; > > - char *out = buf; > > - > > - spin_lock(&busid_table_lock); > > - for (i = 0; i < MAX_BUSID; i++) > > - if (busid_table[i].name[0]) > > - out += sprintf(out, "%s ", busid_table[i].name); > > - spin_unlock(&busid_table_lock); > > - > > - out += sprintf(out, "\n"); > > - return out - buf; > > -} > > - > > static int add_match_busid(char *busid) > > { > > int i; > > @@ -128,19 +128,19 @@ int del_match_busid(char *busid) > > return -1; > > } > > > > -static void init_busid_table(void) > > +static ssize_t show_match_busid(struct device_driver *drv, char *buf) > > { > > int i; > > + char *out = buf; > > > > - for (i = 0; i < MAX_BUSID; i++) { > > - memset(busid_table[i].name, 0, BUSID_SIZE); > > - busid_table[i].status = STUB_BUSID_OTHER; > > - busid_table[i].interf_count = 0; > > - busid_table[i].sdev = NULL; > > - busid_table[i].shutdown_busid = 0; > > - } > > + spin_lock(&busid_table_lock); > > + for (i = 0; i < MAX_BUSID; i++) > > + if (busid_table[i].name[0]) > > + out += sprintf(out, "%s ", busid_table[i].name); > > + spin_unlock(&busid_table_lock); > > > > - spin_lock_init(&busid_table_lock); > > + out += sprintf(out, "\n"); > > + return out - buf; > > } > > > > static ssize_t store_match_busid(struct device_driver *dev, const char *buf, > ^ permalink raw reply [flat|nested] 42+ messages in thread
* [PATCH 04/12] staging: usbip: stub_main.c: code cleanup 2011-05-20 4:36 ` matt mooney @ 2011-05-20 4:36 ` matt mooney -1 siblings, 0 replies; 42+ messages in thread From: matt mooney @ 2011-05-20 4:36 UTC (permalink / raw) To: Greg Kroah-Hartman; +Cc: linux-kernel, kernel-janitors Remove match_find() and replace with get_busid_idx(); change get_busid_priv(), add_match_busid(), and del_match_busid() to use get_busid_idx(); and cleanup code in the other functions. Signed-off-by: matt mooney <mfm@muteddisk.com> --- drivers/staging/usbip/stub_main.c | 147 ++++++++++++++++++------------------- 1 files changed, 73 insertions(+), 74 deletions(-) diff --git a/drivers/staging/usbip/stub_main.c b/drivers/staging/usbip/stub_main.c index 0ca1462..00398a6 100644 --- a/drivers/staging/usbip/stub_main.c +++ b/drivers/staging/usbip/stub_main.c @@ -50,82 +50,90 @@ static void init_busid_table(void) spin_lock_init(&busid_table_lock); } -int match_busid(const char *busid) +/* + * Find the index of the busid by name. + * Must be called with busid_table_lock held. + */ +static int get_busid_idx(const char *busid) { int i; + int idx = -1; - spin_lock(&busid_table_lock); for (i = 0; i < MAX_BUSID; i++) if (busid_table[i].name[0]) if (!strncmp(busid_table[i].name, busid, BUSID_SIZE)) { - /* already registerd */ - spin_unlock(&busid_table_lock); - return 0; + idx = i; + break; } - spin_unlock(&busid_table_lock); - - return 1; + return idx; } struct bus_id_priv *get_busid_priv(const char *busid) { - int i; + int idx; + struct bus_id_priv *bid = NULL; spin_lock(&busid_table_lock); - for (i = 0; i < MAX_BUSID; i++) - if (busid_table[i].name[0]) - if (!strncmp(busid_table[i].name, busid, BUSID_SIZE)) { - /* already registerd */ - spin_unlock(&busid_table_lock); - return &(busid_table[i]); - } + idx = get_busid_idx(busid); + if (idx >= 0) + bid = &(busid_table[idx]); spin_unlock(&busid_table_lock); - return NULL; + return bid; } static int add_match_busid(char *busid) { int i; - - if (!match_busid(busid)) - return 0; + int ret = -1; spin_lock(&busid_table_lock); + /* already registered? */ + if (get_busid_idx(busid) >= 0) { + ret = 0; + goto out; + } + for (i = 0; i < MAX_BUSID; i++) if (!busid_table[i].name[0]) { strncpy(busid_table[i].name, busid, BUSID_SIZE); if ((busid_table[i].status != STUB_BUSID_ALLOC) && (busid_table[i].status != STUB_BUSID_REMOV)) busid_table[i].status = STUB_BUSID_ADDED; - spin_unlock(&busid_table_lock); - return 0; + ret = 0; + break; } + +out: spin_unlock(&busid_table_lock); - return -1; + return ret; } int del_match_busid(char *busid) { - int i; + int idx; + int ret = -1; spin_lock(&busid_table_lock); - for (i = 0; i < MAX_BUSID; i++) - if (!strncmp(busid_table[i].name, busid, BUSID_SIZE)) { - /* found */ - if (busid_table[i].status == STUB_BUSID_OTHER) - memset(busid_table[i].name, 0, BUSID_SIZE); - if ((busid_table[i].status != STUB_BUSID_OTHER) && - (busid_table[i].status != STUB_BUSID_ADDED)) { - busid_table[i].status = STUB_BUSID_REMOV; - } - spin_unlock(&busid_table_lock); - return 0; - } + idx = get_busid_idx(busid); + if (idx < 0) + goto out; + + /* found */ + ret = 0; + + if (busid_table[idx].status == STUB_BUSID_OTHER) + memset(busid_table[idx].name, 0, BUSID_SIZE); + + if ((busid_table[idx].status != STUB_BUSID_OTHER) && + (busid_table[idx].status != STUB_BUSID_ADDED)) + busid_table[idx].status = STUB_BUSID_REMOV; + +out: spin_unlock(&busid_table_lock); - return -1; + return ret; } static ssize_t show_match_busid(struct device_driver *drv, char *buf) @@ -138,8 +146,8 @@ static ssize_t show_match_busid(struct device_driver *drv, char *buf) if (busid_table[i].name[0]) out += sprintf(out, "%s ", busid_table[i].name); spin_unlock(&busid_table_lock); - out += sprintf(out, "\n"); + return out - buf; } @@ -162,23 +170,24 @@ static ssize_t store_match_busid(struct device_driver *dev, const char *buf, strncpy(busid, buf + 4, BUSID_SIZE); if (!strncmp(buf, "add ", 4)) { - if (add_match_busid(busid) < 0) + if (add_match_busid(busid) < 0) { return -ENOMEM; - else { + } else { pr_debug("add busid %s\n", busid); return count; } } else if (!strncmp(buf, "del ", 4)) { - if (del_match_busid(busid) < 0) + if (del_match_busid(busid) < 0) { return -ENODEV; - else { + } else { pr_debug("del busid %s\n", busid); return count; } - } else + } else { return -EINVAL; + } } -static DRIVER_ATTR(match_busid, S_IRUSR|S_IWUSR, show_match_busid, +static DRIVER_ATTR(match_busid, S_IRUSR | S_IWUSR, show_match_busid, store_match_busid); static struct stub_priv *stub_priv_pop_from_listhead(struct list_head *listhead) @@ -201,36 +210,30 @@ static struct stub_priv *stub_priv_pop(struct stub_device *sdev) spin_lock_irqsave(&sdev->priv_lock, flags); priv = stub_priv_pop_from_listhead(&sdev->priv_init); - if (priv) { - spin_unlock_irqrestore(&sdev->priv_lock, flags); - return priv; - } + if (priv) + goto done; priv = stub_priv_pop_from_listhead(&sdev->priv_tx); - if (priv) { - spin_unlock_irqrestore(&sdev->priv_lock, flags); - return priv; - } + if (priv) + goto done; priv = stub_priv_pop_from_listhead(&sdev->priv_free); - if (priv) { - spin_unlock_irqrestore(&sdev->priv_lock, flags); - return priv; - } +done: spin_unlock_irqrestore(&sdev->priv_lock, flags); - return NULL; + + return priv; } void stub_device_cleanup_urbs(struct stub_device *sdev) { struct stub_priv *priv; + struct urb *urb; dev_dbg(&sdev->udev->dev, "free sdev %p\n", sdev); while ((priv = stub_priv_pop(sdev))) { - struct urb *urb = priv->urb; - + urb = priv->urb; dev_dbg(&sdev->udev->dev, "free urb %p\n", urb); usb_kill_urb(urb); @@ -238,7 +241,6 @@ void stub_device_cleanup_urbs(struct stub_device *sdev) kfree(urb->transfer_buffer); kfree(urb->setup_packet); - usb_free_urb(urb); } } @@ -250,34 +252,31 @@ static int __init usb_stub_init(void) stub_priv_cache = kmem_cache_create("stub_priv", sizeof(struct stub_priv), 0, SLAB_HWCACHE_ALIGN, NULL); - if (!stub_priv_cache) { - pr_err("create stub_priv_cache error\n"); + pr_err("kmem_cache_create failed\n"); return -ENOMEM; } ret = usb_register(&stub_driver); - if (ret) { + if (ret < 0) { pr_err("usb_register failed %d\n", ret); - goto error_usb_register; + goto err_usb_register; } - pr_info(DRIVER_DESC " " USBIP_VERSION "\n"); - - init_busid_table(); - ret = driver_create_file(&stub_driver.drvwrap.driver, &driver_attr_match_busid); - - if (ret) { - pr_err("create driver sysfs\n"); - goto error_create_file; + if (ret < 0) { + pr_err("driver_create_file failed\n"); + goto err_create_file; } + init_busid_table(); + pr_info(DRIVER_DESC " v" USBIP_VERSION "\n"); return ret; -error_create_file: + +err_create_file: usb_deregister(&stub_driver); -error_usb_register: +err_usb_register: kmem_cache_destroy(stub_priv_cache); return ret; } -- 1.7.5.1 ^ permalink raw reply related [flat|nested] 42+ messages in thread
* [PATCH 04/12] staging: usbip: stub_main.c: code cleanup @ 2011-05-20 4:36 ` matt mooney 0 siblings, 0 replies; 42+ messages in thread From: matt mooney @ 2011-05-20 4:36 UTC (permalink / raw) To: Greg Kroah-Hartman; +Cc: linux-kernel, kernel-janitors Remove match_find() and replace with get_busid_idx(); change get_busid_priv(), add_match_busid(), and del_match_busid() to use get_busid_idx(); and cleanup code in the other functions. Signed-off-by: matt mooney <mfm@muteddisk.com> --- drivers/staging/usbip/stub_main.c | 147 ++++++++++++++++++------------------- 1 files changed, 73 insertions(+), 74 deletions(-) diff --git a/drivers/staging/usbip/stub_main.c b/drivers/staging/usbip/stub_main.c index 0ca1462..00398a6 100644 --- a/drivers/staging/usbip/stub_main.c +++ b/drivers/staging/usbip/stub_main.c @@ -50,82 +50,90 @@ static void init_busid_table(void) spin_lock_init(&busid_table_lock); } -int match_busid(const char *busid) +/* + * Find the index of the busid by name. + * Must be called with busid_table_lock held. + */ +static int get_busid_idx(const char *busid) { int i; + int idx = -1; - spin_lock(&busid_table_lock); for (i = 0; i < MAX_BUSID; i++) if (busid_table[i].name[0]) if (!strncmp(busid_table[i].name, busid, BUSID_SIZE)) { - /* already registerd */ - spin_unlock(&busid_table_lock); - return 0; + idx = i; + break; } - spin_unlock(&busid_table_lock); - - return 1; + return idx; } struct bus_id_priv *get_busid_priv(const char *busid) { - int i; + int idx; + struct bus_id_priv *bid = NULL; spin_lock(&busid_table_lock); - for (i = 0; i < MAX_BUSID; i++) - if (busid_table[i].name[0]) - if (!strncmp(busid_table[i].name, busid, BUSID_SIZE)) { - /* already registerd */ - spin_unlock(&busid_table_lock); - return &(busid_table[i]); - } + idx = get_busid_idx(busid); + if (idx >= 0) + bid = &(busid_table[idx]); spin_unlock(&busid_table_lock); - return NULL; + return bid; } static int add_match_busid(char *busid) { int i; - - if (!match_busid(busid)) - return 0; + int ret = -1; spin_lock(&busid_table_lock); + /* already registered? */ + if (get_busid_idx(busid) >= 0) { + ret = 0; + goto out; + } + for (i = 0; i < MAX_BUSID; i++) if (!busid_table[i].name[0]) { strncpy(busid_table[i].name, busid, BUSID_SIZE); if ((busid_table[i].status != STUB_BUSID_ALLOC) && (busid_table[i].status != STUB_BUSID_REMOV)) busid_table[i].status = STUB_BUSID_ADDED; - spin_unlock(&busid_table_lock); - return 0; + ret = 0; + break; } + +out: spin_unlock(&busid_table_lock); - return -1; + return ret; } int del_match_busid(char *busid) { - int i; + int idx; + int ret = -1; spin_lock(&busid_table_lock); - for (i = 0; i < MAX_BUSID; i++) - if (!strncmp(busid_table[i].name, busid, BUSID_SIZE)) { - /* found */ - if (busid_table[i].status = STUB_BUSID_OTHER) - memset(busid_table[i].name, 0, BUSID_SIZE); - if ((busid_table[i].status != STUB_BUSID_OTHER) && - (busid_table[i].status != STUB_BUSID_ADDED)) { - busid_table[i].status = STUB_BUSID_REMOV; - } - spin_unlock(&busid_table_lock); - return 0; - } + idx = get_busid_idx(busid); + if (idx < 0) + goto out; + + /* found */ + ret = 0; + + if (busid_table[idx].status = STUB_BUSID_OTHER) + memset(busid_table[idx].name, 0, BUSID_SIZE); + + if ((busid_table[idx].status != STUB_BUSID_OTHER) && + (busid_table[idx].status != STUB_BUSID_ADDED)) + busid_table[idx].status = STUB_BUSID_REMOV; + +out: spin_unlock(&busid_table_lock); - return -1; + return ret; } static ssize_t show_match_busid(struct device_driver *drv, char *buf) @@ -138,8 +146,8 @@ static ssize_t show_match_busid(struct device_driver *drv, char *buf) if (busid_table[i].name[0]) out += sprintf(out, "%s ", busid_table[i].name); spin_unlock(&busid_table_lock); - out += sprintf(out, "\n"); + return out - buf; } @@ -162,23 +170,24 @@ static ssize_t store_match_busid(struct device_driver *dev, const char *buf, strncpy(busid, buf + 4, BUSID_SIZE); if (!strncmp(buf, "add ", 4)) { - if (add_match_busid(busid) < 0) + if (add_match_busid(busid) < 0) { return -ENOMEM; - else { + } else { pr_debug("add busid %s\n", busid); return count; } } else if (!strncmp(buf, "del ", 4)) { - if (del_match_busid(busid) < 0) + if (del_match_busid(busid) < 0) { return -ENODEV; - else { + } else { pr_debug("del busid %s\n", busid); return count; } - } else + } else { return -EINVAL; + } } -static DRIVER_ATTR(match_busid, S_IRUSR|S_IWUSR, show_match_busid, +static DRIVER_ATTR(match_busid, S_IRUSR | S_IWUSR, show_match_busid, store_match_busid); static struct stub_priv *stub_priv_pop_from_listhead(struct list_head *listhead) @@ -201,36 +210,30 @@ static struct stub_priv *stub_priv_pop(struct stub_device *sdev) spin_lock_irqsave(&sdev->priv_lock, flags); priv = stub_priv_pop_from_listhead(&sdev->priv_init); - if (priv) { - spin_unlock_irqrestore(&sdev->priv_lock, flags); - return priv; - } + if (priv) + goto done; priv = stub_priv_pop_from_listhead(&sdev->priv_tx); - if (priv) { - spin_unlock_irqrestore(&sdev->priv_lock, flags); - return priv; - } + if (priv) + goto done; priv = stub_priv_pop_from_listhead(&sdev->priv_free); - if (priv) { - spin_unlock_irqrestore(&sdev->priv_lock, flags); - return priv; - } +done: spin_unlock_irqrestore(&sdev->priv_lock, flags); - return NULL; + + return priv; } void stub_device_cleanup_urbs(struct stub_device *sdev) { struct stub_priv *priv; + struct urb *urb; dev_dbg(&sdev->udev->dev, "free sdev %p\n", sdev); while ((priv = stub_priv_pop(sdev))) { - struct urb *urb = priv->urb; - + urb = priv->urb; dev_dbg(&sdev->udev->dev, "free urb %p\n", urb); usb_kill_urb(urb); @@ -238,7 +241,6 @@ void stub_device_cleanup_urbs(struct stub_device *sdev) kfree(urb->transfer_buffer); kfree(urb->setup_packet); - usb_free_urb(urb); } } @@ -250,34 +252,31 @@ static int __init usb_stub_init(void) stub_priv_cache = kmem_cache_create("stub_priv", sizeof(struct stub_priv), 0, SLAB_HWCACHE_ALIGN, NULL); - if (!stub_priv_cache) { - pr_err("create stub_priv_cache error\n"); + pr_err("kmem_cache_create failed\n"); return -ENOMEM; } ret = usb_register(&stub_driver); - if (ret) { + if (ret < 0) { pr_err("usb_register failed %d\n", ret); - goto error_usb_register; + goto err_usb_register; } - pr_info(DRIVER_DESC " " USBIP_VERSION "\n"); - - init_busid_table(); - ret = driver_create_file(&stub_driver.drvwrap.driver, &driver_attr_match_busid); - - if (ret) { - pr_err("create driver sysfs\n"); - goto error_create_file; + if (ret < 0) { + pr_err("driver_create_file failed\n"); + goto err_create_file; } + init_busid_table(); + pr_info(DRIVER_DESC " v" USBIP_VERSION "\n"); return ret; -error_create_file: + +err_create_file: usb_deregister(&stub_driver); -error_usb_register: +err_usb_register: kmem_cache_destroy(stub_priv_cache); return ret; } -- 1.7.5.1 ^ permalink raw reply related [flat|nested] 42+ messages in thread
* Re: [PATCH 04/12] staging: usbip: stub_main.c: code cleanup 2011-05-20 4:36 ` matt mooney @ 2011-05-20 9:08 ` walter harms -1 siblings, 0 replies; 42+ messages in thread From: walter harms @ 2011-05-20 9:08 UTC (permalink / raw) To: matt mooney; +Cc: Greg Kroah-Hartman, linux-kernel, kernel-janitors Am 20.05.2011 06:36, schrieb matt mooney: > Remove match_find() and replace with get_busid_idx(); change > get_busid_priv(), add_match_busid(), and del_match_busid() to use > get_busid_idx(); and cleanup code in the other functions. > > Signed-off-by: matt mooney <mfm@muteddisk.com> > --- > drivers/staging/usbip/stub_main.c | 147 ++++++++++++++++++------------------- > 1 files changed, 73 insertions(+), 74 deletions(-) > > diff --git a/drivers/staging/usbip/stub_main.c b/drivers/staging/usbip/stub_main.c > index 0ca1462..00398a6 100644 > --- a/drivers/staging/usbip/stub_main.c > +++ b/drivers/staging/usbip/stub_main.c > @@ -50,82 +50,90 @@ static void init_busid_table(void) > spin_lock_init(&busid_table_lock); > } > > -int match_busid(const char *busid) > +/* > + * Find the index of the busid by name. > + * Must be called with busid_table_lock held. > + */ > +static int get_busid_idx(const char *busid) > { > int i; > + int idx = -1; > > - spin_lock(&busid_table_lock); > for (i = 0; i < MAX_BUSID; i++) > if (busid_table[i].name[0]) > if (!strncmp(busid_table[i].name, busid, BUSID_SIZE)) { > - /* already registerd */ > - spin_unlock(&busid_table_lock); > - return 0; > + idx = i; > + break; > } > - spin_unlock(&busid_table_lock); > - > - return 1; > + return idx; > } > > struct bus_id_priv *get_busid_priv(const char *busid) > { > - int i; > + int idx; > + struct bus_id_priv *bid = NULL; > > spin_lock(&busid_table_lock); > - for (i = 0; i < MAX_BUSID; i++) > - if (busid_table[i].name[0]) > - if (!strncmp(busid_table[i].name, busid, BUSID_SIZE)) { > - /* already registerd */ > - spin_unlock(&busid_table_lock); > - return &(busid_table[i]); > - } > + idx = get_busid_idx(busid); > + if (idx >= 0) > + bid = &(busid_table[idx]); > spin_unlock(&busid_table_lock); > > - return NULL; > + return bid; > } > > static int add_match_busid(char *busid) > { > int i; > - > - if (!match_busid(busid)) > - return 0; > + int ret = -1; > > spin_lock(&busid_table_lock); > + /* already registered? */ > + if (get_busid_idx(busid) >= 0) { > + ret = 0; > + goto out; > + } > + > for (i = 0; i < MAX_BUSID; i++) > if (!busid_table[i].name[0]) { > strncpy(busid_table[i].name, busid, BUSID_SIZE); i am missing an if() here ?? > if ((busid_table[i].status != STUB_BUSID_ALLOC) && > (busid_table[i].status != STUB_BUSID_REMOV)) > busid_table[i].status = STUB_BUSID_ADDED; > - spin_unlock(&busid_table_lock); > - return 0; > + ret = 0; > + break; > } > + > +out: > spin_unlock(&busid_table_lock); > > - return -1; > + return ret; > } > > int del_match_busid(char *busid) > { > - int i; > + int idx; > + int ret = -1; > > spin_lock(&busid_table_lock); > - for (i = 0; i < MAX_BUSID; i++) > - if (!strncmp(busid_table[i].name, busid, BUSID_SIZE)) { > - /* found */ > - if (busid_table[i].status == STUB_BUSID_OTHER) > - memset(busid_table[i].name, 0, BUSID_SIZE); > - if ((busid_table[i].status != STUB_BUSID_OTHER) && > - (busid_table[i].status != STUB_BUSID_ADDED)) { > - busid_table[i].status = STUB_BUSID_REMOV; > - } > - spin_unlock(&busid_table_lock); > - return 0; > - } > + idx = get_busid_idx(busid); > + if (idx < 0) > + goto out; > + > + /* found */ > + ret = 0; > + > + if (busid_table[idx].status == STUB_BUSID_OTHER) > + memset(busid_table[idx].name, 0, BUSID_SIZE); > + > + if ((busid_table[idx].status != STUB_BUSID_OTHER) && > + (busid_table[idx].status != STUB_BUSID_ADDED)) > + busid_table[idx].status = STUB_BUSID_REMOV; > + > +out: > spin_unlock(&busid_table_lock); > > - return -1; > + return ret; > } > > static ssize_t show_match_busid(struct device_driver *drv, char *buf) > @@ -138,8 +146,8 @@ static ssize_t show_match_busid(struct device_driver *drv, char *buf) > if (busid_table[i].name[0]) > out += sprintf(out, "%s ", busid_table[i].name); > spin_unlock(&busid_table_lock); > - > out += sprintf(out, "\n"); > + > return out - buf; > } > > @@ -162,23 +170,24 @@ static ssize_t store_match_busid(struct device_driver *dev, const char *buf, > strncpy(busid, buf + 4, BUSID_SIZE); > > if (!strncmp(buf, "add ", 4)) { > - if (add_match_busid(busid) < 0) > + if (add_match_busid(busid) < 0) { > return -ENOMEM; > - else { > + } else { > pr_debug("add busid %s\n", busid); > return count; > } > } else if (!strncmp(buf, "del ", 4)) { > - if (del_match_busid(busid) < 0) > + if (del_match_busid(busid) < 0) { > return -ENODEV; > - else { > + } else { > pr_debug("del busid %s\n", busid); > return count; > } > - } else > + } else { > return -EINVAL; > + } > } > -static DRIVER_ATTR(match_busid, S_IRUSR|S_IWUSR, show_match_busid, > +static DRIVER_ATTR(match_busid, S_IRUSR | S_IWUSR, show_match_busid, > store_match_busid); > > static struct stub_priv *stub_priv_pop_from_listhead(struct list_head *listhead) > @@ -201,36 +210,30 @@ static struct stub_priv *stub_priv_pop(struct stub_device *sdev) > spin_lock_irqsave(&sdev->priv_lock, flags); > > priv = stub_priv_pop_from_listhead(&sdev->priv_init); > - if (priv) { > - spin_unlock_irqrestore(&sdev->priv_lock, flags); > - return priv; > - } > + if (priv) > + goto done; > > priv = stub_priv_pop_from_listhead(&sdev->priv_tx); > - if (priv) { > - spin_unlock_irqrestore(&sdev->priv_lock, flags); > - return priv; > - } > + if (priv) > + goto done; > > priv = stub_priv_pop_from_listhead(&sdev->priv_free); > - if (priv) { > - spin_unlock_irqrestore(&sdev->priv_lock, flags); > - return priv; > - } > > +done: > spin_unlock_irqrestore(&sdev->priv_lock, flags); > - return NULL; > + > + return priv; > } > > void stub_device_cleanup_urbs(struct stub_device *sdev) > { > struct stub_priv *priv; > + struct urb *urb; > > dev_dbg(&sdev->udev->dev, "free sdev %p\n", sdev); > > while ((priv = stub_priv_pop(sdev))) { > - struct urb *urb = priv->urb; > - > + urb = priv->urb; > dev_dbg(&sdev->udev->dev, "free urb %p\n", urb); > usb_kill_urb(urb); > > @@ -238,7 +241,6 @@ void stub_device_cleanup_urbs(struct stub_device *sdev) > > kfree(urb->transfer_buffer); > kfree(urb->setup_packet); > - > usb_free_urb(urb); > } > } > @@ -250,34 +252,31 @@ static int __init usb_stub_init(void) > stub_priv_cache = kmem_cache_create("stub_priv", > sizeof(struct stub_priv), 0, > SLAB_HWCACHE_ALIGN, NULL); > - > if (!stub_priv_cache) { > - pr_err("create stub_priv_cache error\n"); > + pr_err("kmem_cache_create failed\n"); > return -ENOMEM; > } > > ret = usb_register(&stub_driver); > - if (ret) { > + if (ret < 0) { > pr_err("usb_register failed %d\n", ret); > - goto error_usb_register; > + goto err_usb_register; > } > > - pr_info(DRIVER_DESC " " USBIP_VERSION "\n"); > - > - init_busid_table(); > - > ret = driver_create_file(&stub_driver.drvwrap.driver, > &driver_attr_match_busid); > - > - if (ret) { > - pr_err("create driver sysfs\n"); > - goto error_create_file; > + if (ret < 0) { > + pr_err("driver_create_file failed\n"); > + goto err_create_file; > } > > + init_busid_table(); > + pr_info(DRIVER_DESC " v" USBIP_VERSION "\n"); > return ret; > -error_create_file: > + > +err_create_file: > usb_deregister(&stub_driver); > -error_usb_register: > +err_usb_register: > kmem_cache_destroy(stub_priv_cache); > return ret; > } ^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [PATCH 04/12] staging: usbip: stub_main.c: code cleanup @ 2011-05-20 9:08 ` walter harms 0 siblings, 0 replies; 42+ messages in thread From: walter harms @ 2011-05-20 9:08 UTC (permalink / raw) To: matt mooney; +Cc: Greg Kroah-Hartman, linux-kernel, kernel-janitors Am 20.05.2011 06:36, schrieb matt mooney: > Remove match_find() and replace with get_busid_idx(); change > get_busid_priv(), add_match_busid(), and del_match_busid() to use > get_busid_idx(); and cleanup code in the other functions. > > Signed-off-by: matt mooney <mfm@muteddisk.com> > --- > drivers/staging/usbip/stub_main.c | 147 ++++++++++++++++++------------------- > 1 files changed, 73 insertions(+), 74 deletions(-) > > diff --git a/drivers/staging/usbip/stub_main.c b/drivers/staging/usbip/stub_main.c > index 0ca1462..00398a6 100644 > --- a/drivers/staging/usbip/stub_main.c > +++ b/drivers/staging/usbip/stub_main.c > @@ -50,82 +50,90 @@ static void init_busid_table(void) > spin_lock_init(&busid_table_lock); > } > > -int match_busid(const char *busid) > +/* > + * Find the index of the busid by name. > + * Must be called with busid_table_lock held. > + */ > +static int get_busid_idx(const char *busid) > { > int i; > + int idx = -1; > > - spin_lock(&busid_table_lock); > for (i = 0; i < MAX_BUSID; i++) > if (busid_table[i].name[0]) > if (!strncmp(busid_table[i].name, busid, BUSID_SIZE)) { > - /* already registerd */ > - spin_unlock(&busid_table_lock); > - return 0; > + idx = i; > + break; > } > - spin_unlock(&busid_table_lock); > - > - return 1; > + return idx; > } > > struct bus_id_priv *get_busid_priv(const char *busid) > { > - int i; > + int idx; > + struct bus_id_priv *bid = NULL; > > spin_lock(&busid_table_lock); > - for (i = 0; i < MAX_BUSID; i++) > - if (busid_table[i].name[0]) > - if (!strncmp(busid_table[i].name, busid, BUSID_SIZE)) { > - /* already registerd */ > - spin_unlock(&busid_table_lock); > - return &(busid_table[i]); > - } > + idx = get_busid_idx(busid); > + if (idx >= 0) > + bid = &(busid_table[idx]); > spin_unlock(&busid_table_lock); > > - return NULL; > + return bid; > } > > static int add_match_busid(char *busid) > { > int i; > - > - if (!match_busid(busid)) > - return 0; > + int ret = -1; > > spin_lock(&busid_table_lock); > + /* already registered? */ > + if (get_busid_idx(busid) >= 0) { > + ret = 0; > + goto out; > + } > + > for (i = 0; i < MAX_BUSID; i++) > if (!busid_table[i].name[0]) { > strncpy(busid_table[i].name, busid, BUSID_SIZE); i am missing an if() here ?? > if ((busid_table[i].status != STUB_BUSID_ALLOC) && > (busid_table[i].status != STUB_BUSID_REMOV)) > busid_table[i].status = STUB_BUSID_ADDED; > - spin_unlock(&busid_table_lock); > - return 0; > + ret = 0; > + break; > } > + > +out: > spin_unlock(&busid_table_lock); > > - return -1; > + return ret; > } > > int del_match_busid(char *busid) > { > - int i; > + int idx; > + int ret = -1; > > spin_lock(&busid_table_lock); > - for (i = 0; i < MAX_BUSID; i++) > - if (!strncmp(busid_table[i].name, busid, BUSID_SIZE)) { > - /* found */ > - if (busid_table[i].status = STUB_BUSID_OTHER) > - memset(busid_table[i].name, 0, BUSID_SIZE); > - if ((busid_table[i].status != STUB_BUSID_OTHER) && > - (busid_table[i].status != STUB_BUSID_ADDED)) { > - busid_table[i].status = STUB_BUSID_REMOV; > - } > - spin_unlock(&busid_table_lock); > - return 0; > - } > + idx = get_busid_idx(busid); > + if (idx < 0) > + goto out; > + > + /* found */ > + ret = 0; > + > + if (busid_table[idx].status = STUB_BUSID_OTHER) > + memset(busid_table[idx].name, 0, BUSID_SIZE); > + > + if ((busid_table[idx].status != STUB_BUSID_OTHER) && > + (busid_table[idx].status != STUB_BUSID_ADDED)) > + busid_table[idx].status = STUB_BUSID_REMOV; > + > +out: > spin_unlock(&busid_table_lock); > > - return -1; > + return ret; > } > > static ssize_t show_match_busid(struct device_driver *drv, char *buf) > @@ -138,8 +146,8 @@ static ssize_t show_match_busid(struct device_driver *drv, char *buf) > if (busid_table[i].name[0]) > out += sprintf(out, "%s ", busid_table[i].name); > spin_unlock(&busid_table_lock); > - > out += sprintf(out, "\n"); > + > return out - buf; > } > > @@ -162,23 +170,24 @@ static ssize_t store_match_busid(struct device_driver *dev, const char *buf, > strncpy(busid, buf + 4, BUSID_SIZE); > > if (!strncmp(buf, "add ", 4)) { > - if (add_match_busid(busid) < 0) > + if (add_match_busid(busid) < 0) { > return -ENOMEM; > - else { > + } else { > pr_debug("add busid %s\n", busid); > return count; > } > } else if (!strncmp(buf, "del ", 4)) { > - if (del_match_busid(busid) < 0) > + if (del_match_busid(busid) < 0) { > return -ENODEV; > - else { > + } else { > pr_debug("del busid %s\n", busid); > return count; > } > - } else > + } else { > return -EINVAL; > + } > } > -static DRIVER_ATTR(match_busid, S_IRUSR|S_IWUSR, show_match_busid, > +static DRIVER_ATTR(match_busid, S_IRUSR | S_IWUSR, show_match_busid, > store_match_busid); > > static struct stub_priv *stub_priv_pop_from_listhead(struct list_head *listhead) > @@ -201,36 +210,30 @@ static struct stub_priv *stub_priv_pop(struct stub_device *sdev) > spin_lock_irqsave(&sdev->priv_lock, flags); > > priv = stub_priv_pop_from_listhead(&sdev->priv_init); > - if (priv) { > - spin_unlock_irqrestore(&sdev->priv_lock, flags); > - return priv; > - } > + if (priv) > + goto done; > > priv = stub_priv_pop_from_listhead(&sdev->priv_tx); > - if (priv) { > - spin_unlock_irqrestore(&sdev->priv_lock, flags); > - return priv; > - } > + if (priv) > + goto done; > > priv = stub_priv_pop_from_listhead(&sdev->priv_free); > - if (priv) { > - spin_unlock_irqrestore(&sdev->priv_lock, flags); > - return priv; > - } > > +done: > spin_unlock_irqrestore(&sdev->priv_lock, flags); > - return NULL; > + > + return priv; > } > > void stub_device_cleanup_urbs(struct stub_device *sdev) > { > struct stub_priv *priv; > + struct urb *urb; > > dev_dbg(&sdev->udev->dev, "free sdev %p\n", sdev); > > while ((priv = stub_priv_pop(sdev))) { > - struct urb *urb = priv->urb; > - > + urb = priv->urb; > dev_dbg(&sdev->udev->dev, "free urb %p\n", urb); > usb_kill_urb(urb); > > @@ -238,7 +241,6 @@ void stub_device_cleanup_urbs(struct stub_device *sdev) > > kfree(urb->transfer_buffer); > kfree(urb->setup_packet); > - > usb_free_urb(urb); > } > } > @@ -250,34 +252,31 @@ static int __init usb_stub_init(void) > stub_priv_cache = kmem_cache_create("stub_priv", > sizeof(struct stub_priv), 0, > SLAB_HWCACHE_ALIGN, NULL); > - > if (!stub_priv_cache) { > - pr_err("create stub_priv_cache error\n"); > + pr_err("kmem_cache_create failed\n"); > return -ENOMEM; > } > > ret = usb_register(&stub_driver); > - if (ret) { > + if (ret < 0) { > pr_err("usb_register failed %d\n", ret); > - goto error_usb_register; > + goto err_usb_register; > } > > - pr_info(DRIVER_DESC " " USBIP_VERSION "\n"); > - > - init_busid_table(); > - > ret = driver_create_file(&stub_driver.drvwrap.driver, > &driver_attr_match_busid); > - > - if (ret) { > - pr_err("create driver sysfs\n"); > - goto error_create_file; > + if (ret < 0) { > + pr_err("driver_create_file failed\n"); > + goto err_create_file; > } > > + init_busid_table(); > + pr_info(DRIVER_DESC " v" USBIP_VERSION "\n"); > return ret; > -error_create_file: > + > +err_create_file: > usb_deregister(&stub_driver); > -error_usb_register: > +err_usb_register: > kmem_cache_destroy(stub_priv_cache); > return ret; > } ^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [PATCH 04/12] staging: usbip: stub_main.c: code cleanup 2011-05-20 9:08 ` walter harms @ 2011-05-20 18:45 ` matt mooney -1 siblings, 0 replies; 42+ messages in thread From: matt mooney @ 2011-05-20 18:45 UTC (permalink / raw) To: walter harms; +Cc: Greg Kroah-Hartman, linux-kernel, kernel-janitors On 11:08 Fri 20 May , walter harms wrote: > > > Am 20.05.2011 06:36, schrieb matt mooney: > > Remove match_find() and replace with get_busid_idx(); change > > get_busid_priv(), add_match_busid(), and del_match_busid() to use > > get_busid_idx(); and cleanup code in the other functions. > > > > Signed-off-by: matt mooney <mfm@muteddisk.com> > > --- > > drivers/staging/usbip/stub_main.c | 147 ++++++++++++++++++------------------- > > 1 files changed, 73 insertions(+), 74 deletions(-) > > > > diff --git a/drivers/staging/usbip/stub_main.c b/drivers/staging/usbip/stub_main.c > > index 0ca1462..00398a6 100644 > > --- a/drivers/staging/usbip/stub_main.c > > +++ b/drivers/staging/usbip/stub_main.c > > @@ -50,82 +50,90 @@ static void init_busid_table(void) > > spin_lock_init(&busid_table_lock); > > } > > > > -int match_busid(const char *busid) > > +/* > > + * Find the index of the busid by name. > > + * Must be called with busid_table_lock held. > > + */ > > +static int get_busid_idx(const char *busid) > > { > > int i; > > + int idx = -1; > > > > - spin_lock(&busid_table_lock); > > for (i = 0; i < MAX_BUSID; i++) > > if (busid_table[i].name[0]) > > if (!strncmp(busid_table[i].name, busid, BUSID_SIZE)) { > > - /* already registerd */ > > - spin_unlock(&busid_table_lock); > > - return 0; > > + idx = i; > > + break; > > } > > - spin_unlock(&busid_table_lock); > > - > > - return 1; > > + return idx; > > } > > > > struct bus_id_priv *get_busid_priv(const char *busid) > > { > > - int i; > > + int idx; > > + struct bus_id_priv *bid = NULL; > > > > spin_lock(&busid_table_lock); > > - for (i = 0; i < MAX_BUSID; i++) > > - if (busid_table[i].name[0]) > > - if (!strncmp(busid_table[i].name, busid, BUSID_SIZE)) { > > - /* already registerd */ > > - spin_unlock(&busid_table_lock); > > - return &(busid_table[i]); > > - } > > + idx = get_busid_idx(busid); > > + if (idx >= 0) > > + bid = &(busid_table[idx]); > > spin_unlock(&busid_table_lock); > > > > - return NULL; > > + return bid; > > } > > > > static int add_match_busid(char *busid) > > { > > int i; > > - > > - if (!match_busid(busid)) > > - return 0; > > + int ret = -1; > > > > spin_lock(&busid_table_lock); > > + /* already registered? */ > > + if (get_busid_idx(busid) >= 0) { > > + ret = 0; > > + goto out; > > + } > > + > > for (i = 0; i < MAX_BUSID; i++) > > if (!busid_table[i].name[0]) { > > strncpy(busid_table[i].name, busid, BUSID_SIZE); > > i am missing an if() here ?? I am not sure what you mean. It should be correct. > > > if ((busid_table[i].status != STUB_BUSID_ALLOC) && > > (busid_table[i].status != STUB_BUSID_REMOV)) > > busid_table[i].status = STUB_BUSID_ADDED; > > - spin_unlock(&busid_table_lock); > > - return 0; > > + ret = 0; > > + break; > > } > > + > > > > > > > +out: > > spin_unlock(&busid_table_lock); > > > > - return -1; > > + return ret; > > } > > > > int del_match_busid(char *busid) > > { > > - int i; > > + int idx; > > + int ret = -1; > > > > spin_lock(&busid_table_lock); > > - for (i = 0; i < MAX_BUSID; i++) > > - if (!strncmp(busid_table[i].name, busid, BUSID_SIZE)) { > > - /* found */ > > - if (busid_table[i].status == STUB_BUSID_OTHER) > > - memset(busid_table[i].name, 0, BUSID_SIZE); > > - if ((busid_table[i].status != STUB_BUSID_OTHER) && > > - (busid_table[i].status != STUB_BUSID_ADDED)) { > > - busid_table[i].status = STUB_BUSID_REMOV; > > - } > > - spin_unlock(&busid_table_lock); > > - return 0; > > - } > > + idx = get_busid_idx(busid); > > + if (idx < 0) > > + goto out; > > + > > + /* found */ > > + ret = 0; > > + > > + if (busid_table[idx].status == STUB_BUSID_OTHER) > > + memset(busid_table[idx].name, 0, BUSID_SIZE); > > + > > + if ((busid_table[idx].status != STUB_BUSID_OTHER) && > > + (busid_table[idx].status != STUB_BUSID_ADDED)) > > + busid_table[idx].status = STUB_BUSID_REMOV; > > + > > +out: > > spin_unlock(&busid_table_lock); > > > > - return -1; > > + return ret; > > } > > > > static ssize_t show_match_busid(struct device_driver *drv, char *buf) > > @@ -138,8 +146,8 @@ static ssize_t show_match_busid(struct device_driver *drv, char *buf) > > if (busid_table[i].name[0]) > > out += sprintf(out, "%s ", busid_table[i].name); > > spin_unlock(&busid_table_lock); > > - > > out += sprintf(out, "\n"); > > + > > return out - buf; > > } > > > > @@ -162,23 +170,24 @@ static ssize_t store_match_busid(struct device_driver *dev, const char *buf, > > strncpy(busid, buf + 4, BUSID_SIZE); > > > > if (!strncmp(buf, "add ", 4)) { > > - if (add_match_busid(busid) < 0) > > + if (add_match_busid(busid) < 0) { > > return -ENOMEM; > > - else { > > + } else { > > pr_debug("add busid %s\n", busid); > > return count; > > } > > } else if (!strncmp(buf, "del ", 4)) { > > - if (del_match_busid(busid) < 0) > > + if (del_match_busid(busid) < 0) { > > return -ENODEV; > > - else { > > + } else { > > pr_debug("del busid %s\n", busid); > > return count; > > } > > - } else > > + } else { > > return -EINVAL; > > + } > > } > > -static DRIVER_ATTR(match_busid, S_IRUSR|S_IWUSR, show_match_busid, > > +static DRIVER_ATTR(match_busid, S_IRUSR | S_IWUSR, show_match_busid, > > store_match_busid); > > > > static struct stub_priv *stub_priv_pop_from_listhead(struct list_head *listhead) > > @@ -201,36 +210,30 @@ static struct stub_priv *stub_priv_pop(struct stub_device *sdev) > > spin_lock_irqsave(&sdev->priv_lock, flags); > > > > priv = stub_priv_pop_from_listhead(&sdev->priv_init); > > - if (priv) { > > - spin_unlock_irqrestore(&sdev->priv_lock, flags); > > - return priv; > > - } > > + if (priv) > > + goto done; > > > > priv = stub_priv_pop_from_listhead(&sdev->priv_tx); > > - if (priv) { > > - spin_unlock_irqrestore(&sdev->priv_lock, flags); > > - return priv; > > - } > > + if (priv) > > + goto done; > > > > priv = stub_priv_pop_from_listhead(&sdev->priv_free); > > - if (priv) { > > - spin_unlock_irqrestore(&sdev->priv_lock, flags); > > - return priv; > > - } > > > > +done: > > spin_unlock_irqrestore(&sdev->priv_lock, flags); > > - return NULL; > > + > > + return priv; > > } > > > > void stub_device_cleanup_urbs(struct stub_device *sdev) > > { > > struct stub_priv *priv; > > + struct urb *urb; > > > > dev_dbg(&sdev->udev->dev, "free sdev %p\n", sdev); > > > > while ((priv = stub_priv_pop(sdev))) { > > - struct urb *urb = priv->urb; > > - > > + urb = priv->urb; > > dev_dbg(&sdev->udev->dev, "free urb %p\n", urb); > > usb_kill_urb(urb); > > > > @@ -238,7 +241,6 @@ void stub_device_cleanup_urbs(struct stub_device *sdev) > > > > kfree(urb->transfer_buffer); > > kfree(urb->setup_packet); > > - > > usb_free_urb(urb); > > } > > } > > @@ -250,34 +252,31 @@ static int __init usb_stub_init(void) > > stub_priv_cache = kmem_cache_create("stub_priv", > > sizeof(struct stub_priv), 0, > > SLAB_HWCACHE_ALIGN, NULL); > > - > > if (!stub_priv_cache) { > > - pr_err("create stub_priv_cache error\n"); > > + pr_err("kmem_cache_create failed\n"); > > return -ENOMEM; > > } > > > > ret = usb_register(&stub_driver); > > - if (ret) { > > + if (ret < 0) { > > pr_err("usb_register failed %d\n", ret); > > - goto error_usb_register; > > + goto err_usb_register; > > } > > > > - pr_info(DRIVER_DESC " " USBIP_VERSION "\n"); > > - > > - init_busid_table(); > > - > > ret = driver_create_file(&stub_driver.drvwrap.driver, > > &driver_attr_match_busid); > > - > > - if (ret) { > > - pr_err("create driver sysfs\n"); > > - goto error_create_file; > > + if (ret < 0) { > > + pr_err("driver_create_file failed\n"); > > + goto err_create_file; > > } > > > > + init_busid_table(); > > + pr_info(DRIVER_DESC " v" USBIP_VERSION "\n"); > > return ret; > > -error_create_file: > > + > > +err_create_file: > > usb_deregister(&stub_driver); > > -error_usb_register: > > +err_usb_register: > > kmem_cache_destroy(stub_priv_cache); > > return ret; > > } > ^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [PATCH 04/12] staging: usbip: stub_main.c: code cleanup @ 2011-05-20 18:45 ` matt mooney 0 siblings, 0 replies; 42+ messages in thread From: matt mooney @ 2011-05-20 18:45 UTC (permalink / raw) To: walter harms; +Cc: Greg Kroah-Hartman, linux-kernel, kernel-janitors On 11:08 Fri 20 May , walter harms wrote: > > > Am 20.05.2011 06:36, schrieb matt mooney: > > Remove match_find() and replace with get_busid_idx(); change > > get_busid_priv(), add_match_busid(), and del_match_busid() to use > > get_busid_idx(); and cleanup code in the other functions. > > > > Signed-off-by: matt mooney <mfm@muteddisk.com> > > --- > > drivers/staging/usbip/stub_main.c | 147 ++++++++++++++++++------------------- > > 1 files changed, 73 insertions(+), 74 deletions(-) > > > > diff --git a/drivers/staging/usbip/stub_main.c b/drivers/staging/usbip/stub_main.c > > index 0ca1462..00398a6 100644 > > --- a/drivers/staging/usbip/stub_main.c > > +++ b/drivers/staging/usbip/stub_main.c > > @@ -50,82 +50,90 @@ static void init_busid_table(void) > > spin_lock_init(&busid_table_lock); > > } > > > > -int match_busid(const char *busid) > > +/* > > + * Find the index of the busid by name. > > + * Must be called with busid_table_lock held. > > + */ > > +static int get_busid_idx(const char *busid) > > { > > int i; > > + int idx = -1; > > > > - spin_lock(&busid_table_lock); > > for (i = 0; i < MAX_BUSID; i++) > > if (busid_table[i].name[0]) > > if (!strncmp(busid_table[i].name, busid, BUSID_SIZE)) { > > - /* already registerd */ > > - spin_unlock(&busid_table_lock); > > - return 0; > > + idx = i; > > + break; > > } > > - spin_unlock(&busid_table_lock); > > - > > - return 1; > > + return idx; > > } > > > > struct bus_id_priv *get_busid_priv(const char *busid) > > { > > - int i; > > + int idx; > > + struct bus_id_priv *bid = NULL; > > > > spin_lock(&busid_table_lock); > > - for (i = 0; i < MAX_BUSID; i++) > > - if (busid_table[i].name[0]) > > - if (!strncmp(busid_table[i].name, busid, BUSID_SIZE)) { > > - /* already registerd */ > > - spin_unlock(&busid_table_lock); > > - return &(busid_table[i]); > > - } > > + idx = get_busid_idx(busid); > > + if (idx >= 0) > > + bid = &(busid_table[idx]); > > spin_unlock(&busid_table_lock); > > > > - return NULL; > > + return bid; > > } > > > > static int add_match_busid(char *busid) > > { > > int i; > > - > > - if (!match_busid(busid)) > > - return 0; > > + int ret = -1; > > > > spin_lock(&busid_table_lock); > > + /* already registered? */ > > + if (get_busid_idx(busid) >= 0) { > > + ret = 0; > > + goto out; > > + } > > + > > for (i = 0; i < MAX_BUSID; i++) > > if (!busid_table[i].name[0]) { > > strncpy(busid_table[i].name, busid, BUSID_SIZE); > > i am missing an if() here ?? I am not sure what you mean. It should be correct. > > > if ((busid_table[i].status != STUB_BUSID_ALLOC) && > > (busid_table[i].status != STUB_BUSID_REMOV)) > > busid_table[i].status = STUB_BUSID_ADDED; > > - spin_unlock(&busid_table_lock); > > - return 0; > > + ret = 0; > > + break; > > } > > + > > > > > > > +out: > > spin_unlock(&busid_table_lock); > > > > - return -1; > > + return ret; > > } > > > > int del_match_busid(char *busid) > > { > > - int i; > > + int idx; > > + int ret = -1; > > > > spin_lock(&busid_table_lock); > > - for (i = 0; i < MAX_BUSID; i++) > > - if (!strncmp(busid_table[i].name, busid, BUSID_SIZE)) { > > - /* found */ > > - if (busid_table[i].status = STUB_BUSID_OTHER) > > - memset(busid_table[i].name, 0, BUSID_SIZE); > > - if ((busid_table[i].status != STUB_BUSID_OTHER) && > > - (busid_table[i].status != STUB_BUSID_ADDED)) { > > - busid_table[i].status = STUB_BUSID_REMOV; > > - } > > - spin_unlock(&busid_table_lock); > > - return 0; > > - } > > + idx = get_busid_idx(busid); > > + if (idx < 0) > > + goto out; > > + > > + /* found */ > > + ret = 0; > > + > > + if (busid_table[idx].status = STUB_BUSID_OTHER) > > + memset(busid_table[idx].name, 0, BUSID_SIZE); > > + > > + if ((busid_table[idx].status != STUB_BUSID_OTHER) && > > + (busid_table[idx].status != STUB_BUSID_ADDED)) > > + busid_table[idx].status = STUB_BUSID_REMOV; > > + > > +out: > > spin_unlock(&busid_table_lock); > > > > - return -1; > > + return ret; > > } > > > > static ssize_t show_match_busid(struct device_driver *drv, char *buf) > > @@ -138,8 +146,8 @@ static ssize_t show_match_busid(struct device_driver *drv, char *buf) > > if (busid_table[i].name[0]) > > out += sprintf(out, "%s ", busid_table[i].name); > > spin_unlock(&busid_table_lock); > > - > > out += sprintf(out, "\n"); > > + > > return out - buf; > > } > > > > @@ -162,23 +170,24 @@ static ssize_t store_match_busid(struct device_driver *dev, const char *buf, > > strncpy(busid, buf + 4, BUSID_SIZE); > > > > if (!strncmp(buf, "add ", 4)) { > > - if (add_match_busid(busid) < 0) > > + if (add_match_busid(busid) < 0) { > > return -ENOMEM; > > - else { > > + } else { > > pr_debug("add busid %s\n", busid); > > return count; > > } > > } else if (!strncmp(buf, "del ", 4)) { > > - if (del_match_busid(busid) < 0) > > + if (del_match_busid(busid) < 0) { > > return -ENODEV; > > - else { > > + } else { > > pr_debug("del busid %s\n", busid); > > return count; > > } > > - } else > > + } else { > > return -EINVAL; > > + } > > } > > -static DRIVER_ATTR(match_busid, S_IRUSR|S_IWUSR, show_match_busid, > > +static DRIVER_ATTR(match_busid, S_IRUSR | S_IWUSR, show_match_busid, > > store_match_busid); > > > > static struct stub_priv *stub_priv_pop_from_listhead(struct list_head *listhead) > > @@ -201,36 +210,30 @@ static struct stub_priv *stub_priv_pop(struct stub_device *sdev) > > spin_lock_irqsave(&sdev->priv_lock, flags); > > > > priv = stub_priv_pop_from_listhead(&sdev->priv_init); > > - if (priv) { > > - spin_unlock_irqrestore(&sdev->priv_lock, flags); > > - return priv; > > - } > > + if (priv) > > + goto done; > > > > priv = stub_priv_pop_from_listhead(&sdev->priv_tx); > > - if (priv) { > > - spin_unlock_irqrestore(&sdev->priv_lock, flags); > > - return priv; > > - } > > + if (priv) > > + goto done; > > > > priv = stub_priv_pop_from_listhead(&sdev->priv_free); > > - if (priv) { > > - spin_unlock_irqrestore(&sdev->priv_lock, flags); > > - return priv; > > - } > > > > +done: > > spin_unlock_irqrestore(&sdev->priv_lock, flags); > > - return NULL; > > + > > + return priv; > > } > > > > void stub_device_cleanup_urbs(struct stub_device *sdev) > > { > > struct stub_priv *priv; > > + struct urb *urb; > > > > dev_dbg(&sdev->udev->dev, "free sdev %p\n", sdev); > > > > while ((priv = stub_priv_pop(sdev))) { > > - struct urb *urb = priv->urb; > > - > > + urb = priv->urb; > > dev_dbg(&sdev->udev->dev, "free urb %p\n", urb); > > usb_kill_urb(urb); > > > > @@ -238,7 +241,6 @@ void stub_device_cleanup_urbs(struct stub_device *sdev) > > > > kfree(urb->transfer_buffer); > > kfree(urb->setup_packet); > > - > > usb_free_urb(urb); > > } > > } > > @@ -250,34 +252,31 @@ static int __init usb_stub_init(void) > > stub_priv_cache = kmem_cache_create("stub_priv", > > sizeof(struct stub_priv), 0, > > SLAB_HWCACHE_ALIGN, NULL); > > - > > if (!stub_priv_cache) { > > - pr_err("create stub_priv_cache error\n"); > > + pr_err("kmem_cache_create failed\n"); > > return -ENOMEM; > > } > > > > ret = usb_register(&stub_driver); > > - if (ret) { > > + if (ret < 0) { > > pr_err("usb_register failed %d\n", ret); > > - goto error_usb_register; > > + goto err_usb_register; > > } > > > > - pr_info(DRIVER_DESC " " USBIP_VERSION "\n"); > > - > > - init_busid_table(); > > - > > ret = driver_create_file(&stub_driver.drvwrap.driver, > > &driver_attr_match_busid); > > - > > - if (ret) { > > - pr_err("create driver sysfs\n"); > > - goto error_create_file; > > + if (ret < 0) { > > + pr_err("driver_create_file failed\n"); > > + goto err_create_file; > > } > > > > + init_busid_table(); > > + pr_info(DRIVER_DESC " v" USBIP_VERSION "\n"); > > return ret; > > -error_create_file: > > + > > +err_create_file: > > usb_deregister(&stub_driver); > > -error_usb_register: > > +err_usb_register: > > kmem_cache_destroy(stub_priv_cache); > > return ret; > > } > ^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [PATCH 04/12] staging: usbip: stub_main.c: code cleanup 2011-05-20 18:45 ` matt mooney @ 2011-05-21 11:45 ` walter harms -1 siblings, 0 replies; 42+ messages in thread From: walter harms @ 2011-05-21 11:45 UTC (permalink / raw) To: Greg Kroah-Hartman, linux-kernel, kernel-janitors Am 20.05.2011 20:45, schrieb matt mooney: > On 11:08 Fri 20 May , walter harms wrote: >> >> >> Am 20.05.2011 06:36, schrieb matt mooney: >>> Remove match_find() and replace with get_busid_idx(); change >>> get_busid_priv(), add_match_busid(), and del_match_busid() to use >>> get_busid_idx(); and cleanup code in the other functions. >>> >>> Signed-off-by: matt mooney <mfm@muteddisk.com> >>> --- >>> drivers/staging/usbip/stub_main.c | 147 ++++++++++++++++++------------------- >>> 1 files changed, 73 insertions(+), 74 deletions(-) >>> >>> diff --git a/drivers/staging/usbip/stub_main.c b/drivers/staging/usbip/stub_main.c >>> index 0ca1462..00398a6 100644 >>> --- a/drivers/staging/usbip/stub_main.c >>> +++ b/drivers/staging/usbip/stub_main.c >>> @@ -50,82 +50,90 @@ static void init_busid_table(void) >>> spin_lock_init(&busid_table_lock); >>> } >>> >>> -int match_busid(const char *busid) >>> +/* >>> + * Find the index of the busid by name. >>> + * Must be called with busid_table_lock held. >>> + */ >>> +static int get_busid_idx(const char *busid) >>> { >>> int i; >>> + int idx = -1; >>> >>> - spin_lock(&busid_table_lock); >>> for (i = 0; i < MAX_BUSID; i++) >>> if (busid_table[i].name[0]) >>> if (!strncmp(busid_table[i].name, busid, BUSID_SIZE)) { >>> - /* already registerd */ >>> - spin_unlock(&busid_table_lock); >>> - return 0; >>> + idx = i; >>> + break; >>> } >>> - spin_unlock(&busid_table_lock); >>> - >>> - return 1; >>> + return idx; >>> } >>> >>> struct bus_id_priv *get_busid_priv(const char *busid) >>> { >>> - int i; >>> + int idx; >>> + struct bus_id_priv *bid = NULL; >>> >>> spin_lock(&busid_table_lock); >>> - for (i = 0; i < MAX_BUSID; i++) >>> - if (busid_table[i].name[0]) >>> - if (!strncmp(busid_table[i].name, busid, BUSID_SIZE)) { >>> - /* already registerd */ >>> - spin_unlock(&busid_table_lock); >>> - return &(busid_table[i]); >>> - } >>> + idx = get_busid_idx(busid); >>> + if (idx >= 0) >>> + bid = &(busid_table[idx]); >>> spin_unlock(&busid_table_lock); >>> >>> - return NULL; >>> + return bid; >>> } >>> >>> static int add_match_busid(char *busid) >>> { >>> int i; >>> - >>> - if (!match_busid(busid)) >>> - return 0; >>> + int ret = -1; >>> >>> spin_lock(&busid_table_lock); >>> + /* already registered? */ >>> + if (get_busid_idx(busid) >= 0) { >>> + ret = 0; >>> + goto out; >>> + } >>> + >>> for (i = 0; i < MAX_BUSID; i++) >>> if (!busid_table[i].name[0]) { >>> strncpy(busid_table[i].name, busid, BUSID_SIZE); >> >> i am missing an if() here ?? > > I am not sure what you mean. It should be correct. > ups, sorry my fault missread it as strcmp() everything is fine now. re, wh ^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [PATCH 04/12] staging: usbip: stub_main.c: code cleanup @ 2011-05-21 11:45 ` walter harms 0 siblings, 0 replies; 42+ messages in thread From: walter harms @ 2011-05-21 11:45 UTC (permalink / raw) To: Greg Kroah-Hartman, linux-kernel, kernel-janitors Am 20.05.2011 20:45, schrieb matt mooney: > On 11:08 Fri 20 May , walter harms wrote: >> >> >> Am 20.05.2011 06:36, schrieb matt mooney: >>> Remove match_find() and replace with get_busid_idx(); change >>> get_busid_priv(), add_match_busid(), and del_match_busid() to use >>> get_busid_idx(); and cleanup code in the other functions. >>> >>> Signed-off-by: matt mooney <mfm@muteddisk.com> >>> --- >>> drivers/staging/usbip/stub_main.c | 147 ++++++++++++++++++------------------- >>> 1 files changed, 73 insertions(+), 74 deletions(-) >>> >>> diff --git a/drivers/staging/usbip/stub_main.c b/drivers/staging/usbip/stub_main.c >>> index 0ca1462..00398a6 100644 >>> --- a/drivers/staging/usbip/stub_main.c >>> +++ b/drivers/staging/usbip/stub_main.c >>> @@ -50,82 +50,90 @@ static void init_busid_table(void) >>> spin_lock_init(&busid_table_lock); >>> } >>> >>> -int match_busid(const char *busid) >>> +/* >>> + * Find the index of the busid by name. >>> + * Must be called with busid_table_lock held. >>> + */ >>> +static int get_busid_idx(const char *busid) >>> { >>> int i; >>> + int idx = -1; >>> >>> - spin_lock(&busid_table_lock); >>> for (i = 0; i < MAX_BUSID; i++) >>> if (busid_table[i].name[0]) >>> if (!strncmp(busid_table[i].name, busid, BUSID_SIZE)) { >>> - /* already registerd */ >>> - spin_unlock(&busid_table_lock); >>> - return 0; >>> + idx = i; >>> + break; >>> } >>> - spin_unlock(&busid_table_lock); >>> - >>> - return 1; >>> + return idx; >>> } >>> >>> struct bus_id_priv *get_busid_priv(const char *busid) >>> { >>> - int i; >>> + int idx; >>> + struct bus_id_priv *bid = NULL; >>> >>> spin_lock(&busid_table_lock); >>> - for (i = 0; i < MAX_BUSID; i++) >>> - if (busid_table[i].name[0]) >>> - if (!strncmp(busid_table[i].name, busid, BUSID_SIZE)) { >>> - /* already registerd */ >>> - spin_unlock(&busid_table_lock); >>> - return &(busid_table[i]); >>> - } >>> + idx = get_busid_idx(busid); >>> + if (idx >= 0) >>> + bid = &(busid_table[idx]); >>> spin_unlock(&busid_table_lock); >>> >>> - return NULL; >>> + return bid; >>> } >>> >>> static int add_match_busid(char *busid) >>> { >>> int i; >>> - >>> - if (!match_busid(busid)) >>> - return 0; >>> + int ret = -1; >>> >>> spin_lock(&busid_table_lock); >>> + /* already registered? */ >>> + if (get_busid_idx(busid) >= 0) { >>> + ret = 0; >>> + goto out; >>> + } >>> + >>> for (i = 0; i < MAX_BUSID; i++) >>> if (!busid_table[i].name[0]) { >>> strncpy(busid_table[i].name, busid, BUSID_SIZE); >> >> i am missing an if() here ?? > > I am not sure what you mean. It should be correct. > ups, sorry my fault missread it as strcmp() everything is fine now. re, wh ^ permalink raw reply [flat|nested] 42+ messages in thread
* [PATCH 05/12] staging: usbip: stub_main.c: rename init and exit functions 2011-05-20 4:36 ` matt mooney @ 2011-05-20 4:36 ` matt mooney -1 siblings, 0 replies; 42+ messages in thread From: matt mooney @ 2011-05-20 4:36 UTC (permalink / raw) To: Greg Kroah-Hartman; +Cc: linux-kernel, kernel-janitors Change the prefix of the __init and __exit functions to usbip_host_ to correspond with the modules name. Signed-off-by: matt mooney <mfm@muteddisk.com> --- drivers/staging/usbip/stub_main.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/usbip/stub_main.c b/drivers/staging/usbip/stub_main.c index 00398a6..53d6977 100644 --- a/drivers/staging/usbip/stub_main.c +++ b/drivers/staging/usbip/stub_main.c @@ -245,7 +245,7 @@ void stub_device_cleanup_urbs(struct stub_device *sdev) } } -static int __init usb_stub_init(void) +static int __init usbip_host_init(void) { int ret; @@ -281,7 +281,7 @@ err_usb_register: return ret; } -static void __exit usb_stub_exit(void) +static void __exit usbip_host_exit(void) { driver_remove_file(&stub_driver.drvwrap.driver, &driver_attr_match_busid); @@ -295,8 +295,8 @@ static void __exit usb_stub_exit(void) kmem_cache_destroy(stub_priv_cache); } -module_init(usb_stub_init); -module_exit(usb_stub_exit); +module_init(usbip_host_init); +module_exit(usbip_host_exit); MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); -- 1.7.5.1 ^ permalink raw reply related [flat|nested] 42+ messages in thread
* [PATCH 05/12] staging: usbip: stub_main.c: rename init and exit functions @ 2011-05-20 4:36 ` matt mooney 0 siblings, 0 replies; 42+ messages in thread From: matt mooney @ 2011-05-20 4:36 UTC (permalink / raw) To: Greg Kroah-Hartman; +Cc: linux-kernel, kernel-janitors Change the prefix of the __init and __exit functions to usbip_host_ to correspond with the modules name. Signed-off-by: matt mooney <mfm@muteddisk.com> --- drivers/staging/usbip/stub_main.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/usbip/stub_main.c b/drivers/staging/usbip/stub_main.c index 00398a6..53d6977 100644 --- a/drivers/staging/usbip/stub_main.c +++ b/drivers/staging/usbip/stub_main.c @@ -245,7 +245,7 @@ void stub_device_cleanup_urbs(struct stub_device *sdev) } } -static int __init usb_stub_init(void) +static int __init usbip_host_init(void) { int ret; @@ -281,7 +281,7 @@ err_usb_register: return ret; } -static void __exit usb_stub_exit(void) +static void __exit usbip_host_exit(void) { driver_remove_file(&stub_driver.drvwrap.driver, &driver_attr_match_busid); @@ -295,8 +295,8 @@ static void __exit usb_stub_exit(void) kmem_cache_destroy(stub_priv_cache); } -module_init(usb_stub_init); -module_exit(usb_stub_exit); +module_init(usbip_host_init); +module_exit(usbip_host_exit); MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); -- 1.7.5.1 ^ permalink raw reply related [flat|nested] 42+ messages in thread
* [PATCH 06/12] staging: usbip: stub_main.c: use KMEM_CACHE macro 2011-05-20 4:36 ` matt mooney @ 2011-05-20 4:37 ` matt mooney -1 siblings, 0 replies; 42+ messages in thread From: matt mooney @ 2011-05-20 4:37 UTC (permalink / raw) To: Greg Kroah-Hartman; +Cc: linux-kernel, kernel-janitors Change kmem_cache_create() to the KMEM_CACHE() macro. Signed-off-by: matt mooney <mfm@muteddisk.com> --- drivers/staging/usbip/stub_main.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/usbip/stub_main.c b/drivers/staging/usbip/stub_main.c index 53d6977..45a0f5d 100644 --- a/drivers/staging/usbip/stub_main.c +++ b/drivers/staging/usbip/stub_main.c @@ -249,9 +249,8 @@ static int __init usbip_host_init(void) { int ret; - stub_priv_cache = kmem_cache_create("stub_priv", - sizeof(struct stub_priv), 0, - SLAB_HWCACHE_ALIGN, NULL); + stub_priv_cache = KMEM_CACHE(stub_priv, SLAB_HWCACHE_ALIGN); + if (!stub_priv_cache) { pr_err("kmem_cache_create failed\n"); return -ENOMEM; -- 1.7.5.1 ^ permalink raw reply related [flat|nested] 42+ messages in thread
* [PATCH 06/12] staging: usbip: stub_main.c: use KMEM_CACHE macro @ 2011-05-20 4:37 ` matt mooney 0 siblings, 0 replies; 42+ messages in thread From: matt mooney @ 2011-05-20 4:37 UTC (permalink / raw) To: Greg Kroah-Hartman; +Cc: linux-kernel, kernel-janitors Change kmem_cache_create() to the KMEM_CACHE() macro. Signed-off-by: matt mooney <mfm@muteddisk.com> --- drivers/staging/usbip/stub_main.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/usbip/stub_main.c b/drivers/staging/usbip/stub_main.c index 53d6977..45a0f5d 100644 --- a/drivers/staging/usbip/stub_main.c +++ b/drivers/staging/usbip/stub_main.c @@ -249,9 +249,8 @@ static int __init usbip_host_init(void) { int ret; - stub_priv_cache = kmem_cache_create("stub_priv", - sizeof(struct stub_priv), 0, - SLAB_HWCACHE_ALIGN, NULL); + stub_priv_cache = KMEM_CACHE(stub_priv, SLAB_HWCACHE_ALIGN); + if (!stub_priv_cache) { pr_err("kmem_cache_create failed\n"); return -ENOMEM; -- 1.7.5.1 ^ permalink raw reply related [flat|nested] 42+ messages in thread
* [PATCH 07/12] staging: usbip: usbip_common.c: fix misspelled function name 2011-05-20 4:36 ` matt mooney @ 2011-05-20 4:37 ` matt mooney -1 siblings, 0 replies; 42+ messages in thread From: matt mooney @ 2011-05-20 4:37 UTC (permalink / raw) To: Greg Kroah-Hartman; +Cc: linux-kernel, kernel-janitors Change pakcet to packet in usbip_iso_packet_correct_endian(). Signed-off-by: matt mooney <mfm@muteddisk.com> --- drivers/staging/usbip/usbip_common.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/usbip/usbip_common.c b/drivers/staging/usbip/usbip_common.c index 954d90d..b204e6f 100644 --- a/drivers/staging/usbip/usbip_common.c +++ b/drivers/staging/usbip/usbip_common.c @@ -627,7 +627,7 @@ void usbip_header_correct_endian(struct usbip_header *pdu, int send) } EXPORT_SYMBOL_GPL(usbip_header_correct_endian); -static void usbip_iso_pakcet_correct_endian( +static void usbip_iso_packet_correct_endian( struct usbip_iso_packet_descriptor *iso, int send) { /* does not need all members. but copy all simply. */ @@ -677,7 +677,7 @@ void *usbip_alloc_iso_desc_pdu(struct urb *urb, ssize_t *bufflen) iso = buff + (i * sizeof(*iso)); usbip_pack_iso(iso, &urb->iso_frame_desc[i], 1); - usbip_iso_pakcet_correct_endian(iso, 1); + usbip_iso_packet_correct_endian(iso, 1); } *bufflen = size; @@ -728,7 +728,7 @@ int usbip_recv_iso(struct usbip_device *ud, struct urb *urb) for (i = 0; i < np; i++) { iso = buff + (i * sizeof(*iso)); - usbip_iso_pakcet_correct_endian(iso, 0); + usbip_iso_packet_correct_endian(iso, 0); usbip_pack_iso(iso, &urb->iso_frame_desc[i], 0); total_length += urb->iso_frame_desc[i].actual_length; } -- 1.7.5.1 ^ permalink raw reply related [flat|nested] 42+ messages in thread
* [PATCH 07/12] staging: usbip: usbip_common.c: fix misspelled function name @ 2011-05-20 4:37 ` matt mooney 0 siblings, 0 replies; 42+ messages in thread From: matt mooney @ 2011-05-20 4:37 UTC (permalink / raw) To: Greg Kroah-Hartman; +Cc: linux-kernel, kernel-janitors Change pakcet to packet in usbip_iso_packet_correct_endian(). Signed-off-by: matt mooney <mfm@muteddisk.com> --- drivers/staging/usbip/usbip_common.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/usbip/usbip_common.c b/drivers/staging/usbip/usbip_common.c index 954d90d..b204e6f 100644 --- a/drivers/staging/usbip/usbip_common.c +++ b/drivers/staging/usbip/usbip_common.c @@ -627,7 +627,7 @@ void usbip_header_correct_endian(struct usbip_header *pdu, int send) } EXPORT_SYMBOL_GPL(usbip_header_correct_endian); -static void usbip_iso_pakcet_correct_endian( +static void usbip_iso_packet_correct_endian( struct usbip_iso_packet_descriptor *iso, int send) { /* does not need all members. but copy all simply. */ @@ -677,7 +677,7 @@ void *usbip_alloc_iso_desc_pdu(struct urb *urb, ssize_t *bufflen) iso = buff + (i * sizeof(*iso)); usbip_pack_iso(iso, &urb->iso_frame_desc[i], 1); - usbip_iso_pakcet_correct_endian(iso, 1); + usbip_iso_packet_correct_endian(iso, 1); } *bufflen = size; @@ -728,7 +728,7 @@ int usbip_recv_iso(struct usbip_device *ud, struct urb *urb) for (i = 0; i < np; i++) { iso = buff + (i * sizeof(*iso)); - usbip_iso_pakcet_correct_endian(iso, 0); + usbip_iso_packet_correct_endian(iso, 0); usbip_pack_iso(iso, &urb->iso_frame_desc[i], 0); total_length += urb->iso_frame_desc[i].actual_length; } -- 1.7.5.1 ^ permalink raw reply related [flat|nested] 42+ messages in thread
* [PATCH 08/12] staging: usbip: usbip_common.h: reorganize and document request headers 2011-05-20 4:36 ` matt mooney @ 2011-05-20 4:37 ` matt mooney -1 siblings, 0 replies; 42+ messages in thread From: matt mooney @ 2011-05-20 4:37 UTC (permalink / raw) To: Greg Kroah-Hartman; +Cc: linux-kernel, kernel-janitors Document the request header structures; move #defines out of the structures; organize function declarations by source file; and move inline functions to the end of file. Signed-off-by: matt mooney <mfm@muteddisk.com> --- drivers/staging/usbip/usbip_common.h | 236 +++++++++++++++++----------------- 1 files changed, 121 insertions(+), 115 deletions(-) diff --git a/drivers/staging/usbip/usbip_common.h b/drivers/staging/usbip/usbip_common.h index 83f8c1e..074ac42 100644 --- a/drivers/staging/usbip/usbip_common.h +++ b/drivers/staging/usbip/usbip_common.h @@ -104,111 +104,110 @@ extern struct device_attribute dev_attr_usbip_debug; usbip_dbg_with_flag(usbip_debug_stub_tx, fmt , ##args) /* - * USB/IP request headers. - * Currently, we define 4 request types: + * USB/IP request headers * - * - CMD_SUBMIT transfers a USB request, corresponding to usb_submit_urb(). - * (client to server) - * - RET_RETURN transfers the result of CMD_SUBMIT. - * (server to client) - * - CMD_UNLINK transfers an unlink request of a pending USB request. + * Each request is transferred across the network to its counterpart, which + * facilitates the normal USB communication. The values contained in the headers + * are basically the same as in a URB. Currently, four request types are + * defined: + * + * - USBIP_CMD_SUBMIT: a USB request block, corresponds to usb_submit_urb() * (client to server) - * - RET_UNLINK transfers the result of CMD_UNLINK. + * + * - USBIP_RET_SUBMIT: the result of USBIP_CMD_SUBMIT * (server to client) * - * Note: The below request formats are based on the USB subsystem of Linux. Its - * details will be defined when other implementations come. + * - USBIP_CMD_UNLINK: an unlink request of a pending USBIP_CMD_SUBMIT, + * corresponds to usb_unlink_urb() + * (client to server) * + * - USBIP_RET_UNLINK: the result of USBIP_CMD_UNLINK + * (server to client) * */ +#define USBIP_CMD_SUBMIT 0x0001 +#define USBIP_RET_SUBMIT 0x0002 +#define USBIP_CMD_UNLINK 0x0003 +#define USBIP_RET_UNLINK 0x0004 -/* - * A basic header followed by other additional headers. +#define USBIP_DIR_IN 0x00 +#define USBIP_DIR_OUT 0x01 + +/** + * struct usbip_header_basic - data pertinent to every request + * @command: the usbip request type + * @seqnum: sequential number that identifies requests; incremented per + * connection + * @devid: specifies a remote USB device uniquely instead of busnum and devnum; + * in the stub driver, this value is ((busnum << 16) | devnum) + * @direction: direction of the transfer + * @ep: endpoint number */ struct usbip_header_basic { -#define USBIP_CMD_SUBMIT 0x0001 -#define USBIP_CMD_UNLINK 0x0002 -#define USBIP_RET_SUBMIT 0x0003 -#define USBIP_RET_UNLINK 0x0004 __u32 command; - - /* sequential number which identifies requests. - * incremented per connections */ __u32 seqnum; - - /* devid is used to specify a remote USB device uniquely instead - * of busnum and devnum in Linux. In the case of Linux stub_driver, - * this value is ((busnum << 16) | devnum) */ __u32 devid; - -#define USBIP_DIR_OUT 0 -#define USBIP_DIR_IN 1 __u32 direction; - __u32 ep; /* endpoint number */ + __u32 ep; } __packed; -/* - * An additional header for a CMD_SUBMIT packet. +/** + * struct usbip_header_cmd_submit - USBIP_CMD_SUBMIT packet header + * @transfer_flags: URB flags + * @transfer_buffer_length: the data size for (in) or (out) transfer + * @start_frame: initial frame for isochronous or interrupt transfers + * @number_of_packets: number of isochronous packets + * @interval: maximum time for the request on the server-side host controller + * @setup: setup data for a control request */ struct usbip_header_cmd_submit { - /* these values are basically the same as in a URB. */ - - /* the same in a URB. */ __u32 transfer_flags; - - /* set the following data size (out), - * or expected reading data size (in) */ __s32 transfer_buffer_length; /* it is difficult for usbip to sync frames (reserved only?) */ __s32 start_frame; - - /* the number of iso descriptors that follows this header */ __s32 number_of_packets; - - /* the maximum time within which this request works in a host - * controller of a server side */ __s32 interval; - /* set setup packet data for a CTRL request */ unsigned char setup[8]; } __packed; -/* - * An additional header for a RET_SUBMIT packet. +/** + * struct usbip_header_ret_submit - USBIP_RET_SUBMIT packet header + * @status: return status of a non-iso request + * @actual_length: number of bytes transferred + * @start_frame: initial frame for isochronous or interrupt transfers + * @number_of_packets: number of isochronous packets + * @error_count: number of errors for isochronous transfers */ struct usbip_header_ret_submit { __s32 status; - __s32 actual_length; /* returned data length */ - __s32 start_frame; /* ISO and INT */ - __s32 number_of_packets; /* ISO only */ - __s32 error_count; /* ISO only */ + __s32 actual_length; + __s32 start_frame; + __s32 number_of_packets; + __s32 error_count; } __packed; -/* - * An additional header for a CMD_UNLINK packet. +/** + * struct usbip_header_cmd_unlink - USBIP_CMD_UNLINK packet header + * @seqnum: the URB seqnum to unlink */ struct usbip_header_cmd_unlink { - __u32 seqnum; /* URB's seqnum that will be unlinked */ + __u32 seqnum; } __packed; -/* - * An additional header for a RET_UNLINK packet. +/** + * struct usbip_header_ret_unlink - USBIP_RET_UNLINK packet header + * @status: return status of the request */ struct usbip_header_ret_unlink { __s32 status; } __packed; -/* the same as usb_iso_packet_descriptor but packed for pdu */ -struct usbip_iso_packet_descriptor { - __u32 offset; - __u32 length; /* expected length */ - __u32 actual_length; - __u32 status; -} __packed; - -/* - * All usbip packets use a common header to keep code simple. +/** + * struct usbip_header - common header for all usbip packets + * @base: the basic header + * @u: packet type dependent header */ struct usbip_header { struct usbip_header_basic base; @@ -221,40 +220,15 @@ struct usbip_header { } u; } __packed; -int usbip_xmit(int, struct socket *, char *, int, int); -int usbip_sendmsg(struct socket *, struct msghdr *, int); - -static inline int interface_to_busnum(struct usb_interface *interface) -{ - struct usb_device *udev = interface_to_usbdev(interface); - return udev->bus->busnum; -} - -static inline int interface_to_devnum(struct usb_interface *interface) -{ - struct usb_device *udev = interface_to_usbdev(interface); - return udev->devnum; -} - -static inline int interface_to_infnum(struct usb_interface *interface) -{ - return interface->cur_altsetting->desc.bInterfaceNumber; -} - -#if 0 -int setnodelay(struct socket *); -int setquickack(struct socket *); -int setkeepalive(struct socket *socket); -void setreuse(struct socket *); -#endif - -struct socket *sockfd_to_socket(unsigned int); -int set_sockaddr(struct socket *socket, struct sockaddr_storage *ss); - -void usbip_dump_urb(struct urb *purb); -void usbip_dump_header(struct usbip_header *pdu); - -struct usbip_device; +/* + * This is the same as usb_iso_packet_descriptor but packed for pdu. + */ +struct usbip_iso_packet_descriptor { + __u32 offset; + __u32 length; /* expected length */ + __u32 actual_length; + __u32 status; +} __packed; enum usbip_side { USBIP_VHCI, @@ -277,20 +251,7 @@ enum usbip_status { VDEV_ST_ERROR }; -/* a common structure for stub_device and vhci_device */ -struct usbip_device { - enum usbip_side side; - enum usbip_status status; - - /* lock for status */ - spinlock_t lock; - - struct socket *tcp_socket; - - struct task_struct *tcp_rx; - struct task_struct *tcp_tx; - - /* event handler */ +/* event handler */ #define USBIP_EH_SHUTDOWN (1 << 0) #define USBIP_EH_BYE (1 << 1) #define USBIP_EH_RESET (1 << 2) @@ -307,6 +268,19 @@ struct usbip_device { #define VDEV_EVENT_ERROR_TCP (USBIP_EH_SHUTDOWN | USBIP_EH_RESET) #define VDEV_EVENT_ERROR_MALLOC (USBIP_EH_SHUTDOWN | USBIP_EH_UNUSABLE) +/* a common structure for stub_device and vhci_device */ +struct usbip_device { + enum usbip_side side; + enum usbip_status status; + + /* lock for status */ + spinlock_t lock; + + struct socket *tcp_socket; + + struct task_struct *tcp_rx; + struct task_struct *tcp_tx; + unsigned long event; struct task_struct *eh; wait_queue_head_t eh_waitq; @@ -318,17 +292,32 @@ struct usbip_device { } eh_ops; }; +#if 0 +int usbip_sendmsg(struct socket *, struct msghdr *, int); +int set_sockaddr(struct socket *socket, struct sockaddr_storage *ss); +int setnodelay(struct socket *); +int setquickack(struct socket *); +int setkeepalive(struct socket *socket); +void setreuse(struct socket *); +#endif + +/* usbip_common.c */ +void usbip_dump_urb(struct urb *purb); +void usbip_dump_header(struct usbip_header *pdu); + +int usbip_xmit(int send, struct socket *sock, char *buf, int size, + int msg_flags); +struct socket *sockfd_to_socket(unsigned int sockfd); + void usbip_pack_pdu(struct usbip_header *pdu, struct urb *urb, int cmd, int pack); - void usbip_header_correct_endian(struct usbip_header *pdu, int send); -/* some members of urb must be substituted before. */ -int usbip_recv_xbuff(struct usbip_device *ud, struct urb *urb); + +void *usbip_alloc_iso_desc_pdu(struct urb *urb, ssize_t *bufflen); /* some members of urb must be substituted before. */ int usbip_recv_iso(struct usbip_device *ud, struct urb *urb); -/* some members of urb must be substituted before. */ int usbip_pad_iso(struct usbip_device *ud, struct urb *urb); -void *usbip_alloc_iso_desc_pdu(struct urb *urb, ssize_t *bufflen); +int usbip_recv_xbuff(struct usbip_device *ud, struct urb *urb); /* usbip_event.c */ int usbip_start_eh(struct usbip_device *ud); @@ -336,4 +325,21 @@ void usbip_stop_eh(struct usbip_device *ud); void usbip_event_add(struct usbip_device *ud, unsigned long event); int usbip_event_happened(struct usbip_device *ud); +static inline int interface_to_busnum(struct usb_interface *interface) +{ + struct usb_device *udev = interface_to_usbdev(interface); + return udev->bus->busnum; +} + +static inline int interface_to_devnum(struct usb_interface *interface) +{ + struct usb_device *udev = interface_to_usbdev(interface); + return udev->devnum; +} + +static inline int interface_to_infnum(struct usb_interface *interface) +{ + return interface->cur_altsetting->desc.bInterfaceNumber; +} + #endif /* __USBIP_COMMON_H */ -- 1.7.5.1 ^ permalink raw reply related [flat|nested] 42+ messages in thread
* [PATCH 08/12] staging: usbip: usbip_common.h: reorganize and document request headers @ 2011-05-20 4:37 ` matt mooney 0 siblings, 0 replies; 42+ messages in thread From: matt mooney @ 2011-05-20 4:37 UTC (permalink / raw) To: Greg Kroah-Hartman; +Cc: linux-kernel, kernel-janitors Document the request header structures; move #defines out of the structures; organize function declarations by source file; and move inline functions to the end of file. Signed-off-by: matt mooney <mfm@muteddisk.com> --- drivers/staging/usbip/usbip_common.h | 236 +++++++++++++++++----------------- 1 files changed, 121 insertions(+), 115 deletions(-) diff --git a/drivers/staging/usbip/usbip_common.h b/drivers/staging/usbip/usbip_common.h index 83f8c1e..074ac42 100644 --- a/drivers/staging/usbip/usbip_common.h +++ b/drivers/staging/usbip/usbip_common.h @@ -104,111 +104,110 @@ extern struct device_attribute dev_attr_usbip_debug; usbip_dbg_with_flag(usbip_debug_stub_tx, fmt , ##args) /* - * USB/IP request headers. - * Currently, we define 4 request types: + * USB/IP request headers * - * - CMD_SUBMIT transfers a USB request, corresponding to usb_submit_urb(). - * (client to server) - * - RET_RETURN transfers the result of CMD_SUBMIT. - * (server to client) - * - CMD_UNLINK transfers an unlink request of a pending USB request. + * Each request is transferred across the network to its counterpart, which + * facilitates the normal USB communication. The values contained in the headers + * are basically the same as in a URB. Currently, four request types are + * defined: + * + * - USBIP_CMD_SUBMIT: a USB request block, corresponds to usb_submit_urb() * (client to server) - * - RET_UNLINK transfers the result of CMD_UNLINK. + * + * - USBIP_RET_SUBMIT: the result of USBIP_CMD_SUBMIT * (server to client) * - * Note: The below request formats are based on the USB subsystem of Linux. Its - * details will be defined when other implementations come. + * - USBIP_CMD_UNLINK: an unlink request of a pending USBIP_CMD_SUBMIT, + * corresponds to usb_unlink_urb() + * (client to server) * + * - USBIP_RET_UNLINK: the result of USBIP_CMD_UNLINK + * (server to client) * */ +#define USBIP_CMD_SUBMIT 0x0001 +#define USBIP_RET_SUBMIT 0x0002 +#define USBIP_CMD_UNLINK 0x0003 +#define USBIP_RET_UNLINK 0x0004 -/* - * A basic header followed by other additional headers. +#define USBIP_DIR_IN 0x00 +#define USBIP_DIR_OUT 0x01 + +/** + * struct usbip_header_basic - data pertinent to every request + * @command: the usbip request type + * @seqnum: sequential number that identifies requests; incremented per + * connection + * @devid: specifies a remote USB device uniquely instead of busnum and devnum; + * in the stub driver, this value is ((busnum << 16) | devnum) + * @direction: direction of the transfer + * @ep: endpoint number */ struct usbip_header_basic { -#define USBIP_CMD_SUBMIT 0x0001 -#define USBIP_CMD_UNLINK 0x0002 -#define USBIP_RET_SUBMIT 0x0003 -#define USBIP_RET_UNLINK 0x0004 __u32 command; - - /* sequential number which identifies requests. - * incremented per connections */ __u32 seqnum; - - /* devid is used to specify a remote USB device uniquely instead - * of busnum and devnum in Linux. In the case of Linux stub_driver, - * this value is ((busnum << 16) | devnum) */ __u32 devid; - -#define USBIP_DIR_OUT 0 -#define USBIP_DIR_IN 1 __u32 direction; - __u32 ep; /* endpoint number */ + __u32 ep; } __packed; -/* - * An additional header for a CMD_SUBMIT packet. +/** + * struct usbip_header_cmd_submit - USBIP_CMD_SUBMIT packet header + * @transfer_flags: URB flags + * @transfer_buffer_length: the data size for (in) or (out) transfer + * @start_frame: initial frame for isochronous or interrupt transfers + * @number_of_packets: number of isochronous packets + * @interval: maximum time for the request on the server-side host controller + * @setup: setup data for a control request */ struct usbip_header_cmd_submit { - /* these values are basically the same as in a URB. */ - - /* the same in a URB. */ __u32 transfer_flags; - - /* set the following data size (out), - * or expected reading data size (in) */ __s32 transfer_buffer_length; /* it is difficult for usbip to sync frames (reserved only?) */ __s32 start_frame; - - /* the number of iso descriptors that follows this header */ __s32 number_of_packets; - - /* the maximum time within which this request works in a host - * controller of a server side */ __s32 interval; - /* set setup packet data for a CTRL request */ unsigned char setup[8]; } __packed; -/* - * An additional header for a RET_SUBMIT packet. +/** + * struct usbip_header_ret_submit - USBIP_RET_SUBMIT packet header + * @status: return status of a non-iso request + * @actual_length: number of bytes transferred + * @start_frame: initial frame for isochronous or interrupt transfers + * @number_of_packets: number of isochronous packets + * @error_count: number of errors for isochronous transfers */ struct usbip_header_ret_submit { __s32 status; - __s32 actual_length; /* returned data length */ - __s32 start_frame; /* ISO and INT */ - __s32 number_of_packets; /* ISO only */ - __s32 error_count; /* ISO only */ + __s32 actual_length; + __s32 start_frame; + __s32 number_of_packets; + __s32 error_count; } __packed; -/* - * An additional header for a CMD_UNLINK packet. +/** + * struct usbip_header_cmd_unlink - USBIP_CMD_UNLINK packet header + * @seqnum: the URB seqnum to unlink */ struct usbip_header_cmd_unlink { - __u32 seqnum; /* URB's seqnum that will be unlinked */ + __u32 seqnum; } __packed; -/* - * An additional header for a RET_UNLINK packet. +/** + * struct usbip_header_ret_unlink - USBIP_RET_UNLINK packet header + * @status: return status of the request */ struct usbip_header_ret_unlink { __s32 status; } __packed; -/* the same as usb_iso_packet_descriptor but packed for pdu */ -struct usbip_iso_packet_descriptor { - __u32 offset; - __u32 length; /* expected length */ - __u32 actual_length; - __u32 status; -} __packed; - -/* - * All usbip packets use a common header to keep code simple. +/** + * struct usbip_header - common header for all usbip packets + * @base: the basic header + * @u: packet type dependent header */ struct usbip_header { struct usbip_header_basic base; @@ -221,40 +220,15 @@ struct usbip_header { } u; } __packed; -int usbip_xmit(int, struct socket *, char *, int, int); -int usbip_sendmsg(struct socket *, struct msghdr *, int); - -static inline int interface_to_busnum(struct usb_interface *interface) -{ - struct usb_device *udev = interface_to_usbdev(interface); - return udev->bus->busnum; -} - -static inline int interface_to_devnum(struct usb_interface *interface) -{ - struct usb_device *udev = interface_to_usbdev(interface); - return udev->devnum; -} - -static inline int interface_to_infnum(struct usb_interface *interface) -{ - return interface->cur_altsetting->desc.bInterfaceNumber; -} - -#if 0 -int setnodelay(struct socket *); -int setquickack(struct socket *); -int setkeepalive(struct socket *socket); -void setreuse(struct socket *); -#endif - -struct socket *sockfd_to_socket(unsigned int); -int set_sockaddr(struct socket *socket, struct sockaddr_storage *ss); - -void usbip_dump_urb(struct urb *purb); -void usbip_dump_header(struct usbip_header *pdu); - -struct usbip_device; +/* + * This is the same as usb_iso_packet_descriptor but packed for pdu. + */ +struct usbip_iso_packet_descriptor { + __u32 offset; + __u32 length; /* expected length */ + __u32 actual_length; + __u32 status; +} __packed; enum usbip_side { USBIP_VHCI, @@ -277,20 +251,7 @@ enum usbip_status { VDEV_ST_ERROR }; -/* a common structure for stub_device and vhci_device */ -struct usbip_device { - enum usbip_side side; - enum usbip_status status; - - /* lock for status */ - spinlock_t lock; - - struct socket *tcp_socket; - - struct task_struct *tcp_rx; - struct task_struct *tcp_tx; - - /* event handler */ +/* event handler */ #define USBIP_EH_SHUTDOWN (1 << 0) #define USBIP_EH_BYE (1 << 1) #define USBIP_EH_RESET (1 << 2) @@ -307,6 +268,19 @@ struct usbip_device { #define VDEV_EVENT_ERROR_TCP (USBIP_EH_SHUTDOWN | USBIP_EH_RESET) #define VDEV_EVENT_ERROR_MALLOC (USBIP_EH_SHUTDOWN | USBIP_EH_UNUSABLE) +/* a common structure for stub_device and vhci_device */ +struct usbip_device { + enum usbip_side side; + enum usbip_status status; + + /* lock for status */ + spinlock_t lock; + + struct socket *tcp_socket; + + struct task_struct *tcp_rx; + struct task_struct *tcp_tx; + unsigned long event; struct task_struct *eh; wait_queue_head_t eh_waitq; @@ -318,17 +292,32 @@ struct usbip_device { } eh_ops; }; +#if 0 +int usbip_sendmsg(struct socket *, struct msghdr *, int); +int set_sockaddr(struct socket *socket, struct sockaddr_storage *ss); +int setnodelay(struct socket *); +int setquickack(struct socket *); +int setkeepalive(struct socket *socket); +void setreuse(struct socket *); +#endif + +/* usbip_common.c */ +void usbip_dump_urb(struct urb *purb); +void usbip_dump_header(struct usbip_header *pdu); + +int usbip_xmit(int send, struct socket *sock, char *buf, int size, + int msg_flags); +struct socket *sockfd_to_socket(unsigned int sockfd); + void usbip_pack_pdu(struct usbip_header *pdu, struct urb *urb, int cmd, int pack); - void usbip_header_correct_endian(struct usbip_header *pdu, int send); -/* some members of urb must be substituted before. */ -int usbip_recv_xbuff(struct usbip_device *ud, struct urb *urb); + +void *usbip_alloc_iso_desc_pdu(struct urb *urb, ssize_t *bufflen); /* some members of urb must be substituted before. */ int usbip_recv_iso(struct usbip_device *ud, struct urb *urb); -/* some members of urb must be substituted before. */ int usbip_pad_iso(struct usbip_device *ud, struct urb *urb); -void *usbip_alloc_iso_desc_pdu(struct urb *urb, ssize_t *bufflen); +int usbip_recv_xbuff(struct usbip_device *ud, struct urb *urb); /* usbip_event.c */ int usbip_start_eh(struct usbip_device *ud); @@ -336,4 +325,21 @@ void usbip_stop_eh(struct usbip_device *ud); void usbip_event_add(struct usbip_device *ud, unsigned long event); int usbip_event_happened(struct usbip_device *ud); +static inline int interface_to_busnum(struct usb_interface *interface) +{ + struct usb_device *udev = interface_to_usbdev(interface); + return udev->bus->busnum; +} + +static inline int interface_to_devnum(struct usb_interface *interface) +{ + struct usb_device *udev = interface_to_usbdev(interface); + return udev->devnum; +} + +static inline int interface_to_infnum(struct usb_interface *interface) +{ + return interface->cur_altsetting->desc.bInterfaceNumber; +} + #endif /* __USBIP_COMMON_H */ -- 1.7.5.1 ^ permalink raw reply related [flat|nested] 42+ messages in thread
* [PATCH 09/12] staging: usbip: stub_dev.c: move stub_driver definition and update driver name 2011-05-20 4:36 ` matt mooney @ 2011-05-20 4:37 ` matt mooney -1 siblings, 0 replies; 42+ messages in thread From: matt mooney @ 2011-05-20 4:37 UTC (permalink / raw) To: Greg Kroah-Hartman; +Cc: linux-kernel, kernel-janitors Move the stub_driver definition to the end of file and, therefore, remove foward declarations. Update driver name to usbip-host. A few comments were slightly edited too. Signed-off-by: matt mooney <mfm@muteddisk.com> --- drivers/staging/usbip/stub_dev.c | 28 ++++++++++++---------------- 1 files changed, 12 insertions(+), 16 deletions(-) diff --git a/drivers/staging/usbip/stub_dev.c b/drivers/staging/usbip/stub_dev.c index e35d62c..e26b2ee 100644 --- a/drivers/staging/usbip/stub_dev.c +++ b/drivers/staging/usbip/stub_dev.c @@ -23,14 +23,10 @@ #include "usbip_common.h" #include "stub.h" -static int stub_probe(struct usb_interface *interface, - const struct usb_device_id *id); -static void stub_disconnect(struct usb_interface *interface); - /* * Define device IDs here if you want to explicitly limit exportable devices. - * In the most cases, wild card matching will be ok because driver binding can - * be changed dynamically by a userland program. + * In most cases, wildcard matching will be okay because driver binding can be + * changed dynamically by a userland program. */ static struct usb_device_id stub_table[] = { #if 0 @@ -54,16 +50,9 @@ static struct usb_device_id stub_table[] = { }; MODULE_DEVICE_TABLE(usb, stub_table); -struct usb_driver stub_driver = { - .name = "usbip", - .probe = stub_probe, - .disconnect = stub_disconnect, - .id_table = stub_table, -}; - /* - * usbip_status shows status of usbip as long as this driver is bound to the - * target device. + * usbip_status shows the status of usbip-host as long as this driver is bound + * to the target device. */ static ssize_t show_status(struct device *dev, struct device_attribute *attr, char *buf) @@ -423,7 +412,7 @@ static int stub_probe(struct usb_interface *interface, return 0; } - /* ok. this is my device. */ + /* ok, this is my device */ sdev = stub_device_alloc(udev, interface); if (!sdev) return -ENOMEM; @@ -534,3 +523,10 @@ static void stub_disconnect(struct usb_interface *interface) del_match_busid((char *)udev_busid); } } + +struct usb_driver stub_driver = { + .name = "usbip-host", + .probe = stub_probe, + .disconnect = stub_disconnect, + .id_table = stub_table, +}; -- 1.7.5.1 ^ permalink raw reply related [flat|nested] 42+ messages in thread
* [PATCH 09/12] staging: usbip: stub_dev.c: move stub_driver definition and update driver name @ 2011-05-20 4:37 ` matt mooney 0 siblings, 0 replies; 42+ messages in thread From: matt mooney @ 2011-05-20 4:37 UTC (permalink / raw) To: Greg Kroah-Hartman; +Cc: linux-kernel, kernel-janitors Move the stub_driver definition to the end of file and, therefore, remove foward declarations. Update driver name to usbip-host. A few comments were slightly edited too. Signed-off-by: matt mooney <mfm@muteddisk.com> --- drivers/staging/usbip/stub_dev.c | 28 ++++++++++++---------------- 1 files changed, 12 insertions(+), 16 deletions(-) diff --git a/drivers/staging/usbip/stub_dev.c b/drivers/staging/usbip/stub_dev.c index e35d62c..e26b2ee 100644 --- a/drivers/staging/usbip/stub_dev.c +++ b/drivers/staging/usbip/stub_dev.c @@ -23,14 +23,10 @@ #include "usbip_common.h" #include "stub.h" -static int stub_probe(struct usb_interface *interface, - const struct usb_device_id *id); -static void stub_disconnect(struct usb_interface *interface); - /* * Define device IDs here if you want to explicitly limit exportable devices. - * In the most cases, wild card matching will be ok because driver binding can - * be changed dynamically by a userland program. + * In most cases, wildcard matching will be okay because driver binding can be + * changed dynamically by a userland program. */ static struct usb_device_id stub_table[] = { #if 0 @@ -54,16 +50,9 @@ static struct usb_device_id stub_table[] = { }; MODULE_DEVICE_TABLE(usb, stub_table); -struct usb_driver stub_driver = { - .name = "usbip", - .probe = stub_probe, - .disconnect = stub_disconnect, - .id_table = stub_table, -}; - /* - * usbip_status shows status of usbip as long as this driver is bound to the - * target device. + * usbip_status shows the status of usbip-host as long as this driver is bound + * to the target device. */ static ssize_t show_status(struct device *dev, struct device_attribute *attr, char *buf) @@ -423,7 +412,7 @@ static int stub_probe(struct usb_interface *interface, return 0; } - /* ok. this is my device. */ + /* ok, this is my device */ sdev = stub_device_alloc(udev, interface); if (!sdev) return -ENOMEM; @@ -534,3 +523,10 @@ static void stub_disconnect(struct usb_interface *interface) del_match_busid((char *)udev_busid); } } + +struct usb_driver stub_driver = { + .name = "usbip-host", + .probe = stub_probe, + .disconnect = stub_disconnect, + .id_table = stub_table, +}; -- 1.7.5.1 ^ permalink raw reply related [flat|nested] 42+ messages in thread
* [PATCH 10/12] staging: usbip: userspace: bind_driver.c: update kernel module name 2011-05-20 4:36 ` matt mooney @ 2011-05-20 4:37 ` matt mooney -1 siblings, 0 replies; 42+ messages in thread From: matt mooney @ 2011-05-20 4:37 UTC (permalink / raw) To: Greg Kroah-Hartman; +Cc: linux-kernel, kernel-janitors Change kernel module name to usbip-host. Signed-off-by: matt mooney <mfm@muteddisk.com> --- drivers/staging/usbip/userspace/src/bind-driver.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/usbip/userspace/src/bind-driver.c b/drivers/staging/usbip/userspace/src/bind-driver.c index 201ffbb..dcc540a 100644 --- a/drivers/staging/usbip/userspace/src/bind-driver.c +++ b/drivers/staging/usbip/userspace/src/bind-driver.c @@ -27,7 +27,7 @@ static const struct option longopts[] = { {NULL, 0, NULL, 0} }; -static const char match_busid_path[] = "/sys/bus/usb/drivers/usbip/match_busid"; +static const char match_busid_path[] = "/sys/bus/usb/drivers/usbip-host/match_busid"; static void show_help(void) @@ -228,7 +228,7 @@ static int bind_to_usbip(char *busid) for (i = 0; i < ninterface; i++) { int ret; - ret = bind_interface(busid, configvalue, i, "usbip"); + ret = bind_interface(busid, configvalue, i, "usbip-host"); if (ret < 0) { g_warning("bind usbip at %s:%d.%d, failed", busid, configvalue, i); -- 1.7.5.1 ^ permalink raw reply related [flat|nested] 42+ messages in thread
* [PATCH 10/12] staging: usbip: userspace: bind_driver.c: update kernel module name @ 2011-05-20 4:37 ` matt mooney 0 siblings, 0 replies; 42+ messages in thread From: matt mooney @ 2011-05-20 4:37 UTC (permalink / raw) To: Greg Kroah-Hartman; +Cc: linux-kernel, kernel-janitors Change kernel module name to usbip-host. Signed-off-by: matt mooney <mfm@muteddisk.com> --- drivers/staging/usbip/userspace/src/bind-driver.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/usbip/userspace/src/bind-driver.c b/drivers/staging/usbip/userspace/src/bind-driver.c index 201ffbb..dcc540a 100644 --- a/drivers/staging/usbip/userspace/src/bind-driver.c +++ b/drivers/staging/usbip/userspace/src/bind-driver.c @@ -27,7 +27,7 @@ static const struct option longopts[] = { {NULL, 0, NULL, 0} }; -static const char match_busid_path[] = "/sys/bus/usb/drivers/usbip/match_busid"; +static const char match_busid_path[] = "/sys/bus/usb/drivers/usbip-host/match_busid"; static void show_help(void) @@ -228,7 +228,7 @@ static int bind_to_usbip(char *busid) for (i = 0; i < ninterface; i++) { int ret; - ret = bind_interface(busid, configvalue, i, "usbip"); + ret = bind_interface(busid, configvalue, i, "usbip-host"); if (ret < 0) { g_warning("bind usbip at %s:%d.%d, failed", busid, configvalue, i); -- 1.7.5.1 ^ permalink raw reply related [flat|nested] 42+ messages in thread
* [PATCH 11/12] staging: usbip: usbip_common.c: rename init and exit functions 2011-05-20 4:36 ` matt mooney @ 2011-05-20 4:37 ` matt mooney -1 siblings, 0 replies; 42+ messages in thread From: matt mooney @ 2011-05-20 4:37 UTC (permalink / raw) To: Greg Kroah-Hartman; +Cc: linux-kernel, kernel-janitors Change the prefix of the __init and __exit functions to usbip_core_ to correspond with the modules name. Signed-off-by: matt mooney <mfm@muteddisk.com> --- drivers/staging/usbip/usbip_common.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/usbip/usbip_common.c b/drivers/staging/usbip/usbip_common.c index b204e6f..1be4dc1 100644 --- a/drivers/staging/usbip/usbip_common.c +++ b/drivers/staging/usbip/usbip_common.c @@ -838,19 +838,19 @@ int usbip_recv_xbuff(struct usbip_device *ud, struct urb *urb) } EXPORT_SYMBOL_GPL(usbip_recv_xbuff); -static int __init usbip_common_init(void) +static int __init usbip_core_init(void) { pr_info(DRIVER_DESC " v" USBIP_VERSION "\n"); return 0; } -static void __exit usbip_common_exit(void) +static void __exit usbip_core_exit(void) { return; } -module_init(usbip_common_init); -module_exit(usbip_common_exit); +module_init(usbip_core_init); +module_exit(usbip_core_exit); MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); -- 1.7.5.1 ^ permalink raw reply related [flat|nested] 42+ messages in thread
* [PATCH 11/12] staging: usbip: usbip_common.c: rename init and exit functions @ 2011-05-20 4:37 ` matt mooney 0 siblings, 0 replies; 42+ messages in thread From: matt mooney @ 2011-05-20 4:37 UTC (permalink / raw) To: Greg Kroah-Hartman; +Cc: linux-kernel, kernel-janitors Change the prefix of the __init and __exit functions to usbip_core_ to correspond with the modules name. Signed-off-by: matt mooney <mfm@muteddisk.com> --- drivers/staging/usbip/usbip_common.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/usbip/usbip_common.c b/drivers/staging/usbip/usbip_common.c index b204e6f..1be4dc1 100644 --- a/drivers/staging/usbip/usbip_common.c +++ b/drivers/staging/usbip/usbip_common.c @@ -838,19 +838,19 @@ int usbip_recv_xbuff(struct usbip_device *ud, struct urb *urb) } EXPORT_SYMBOL_GPL(usbip_recv_xbuff); -static int __init usbip_common_init(void) +static int __init usbip_core_init(void) { pr_info(DRIVER_DESC " v" USBIP_VERSION "\n"); return 0; } -static void __exit usbip_common_exit(void) +static void __exit usbip_core_exit(void) { return; } -module_init(usbip_common_init); -module_exit(usbip_common_exit); +module_init(usbip_core_init); +module_exit(usbip_core_exit); MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); -- 1.7.5.1 ^ permalink raw reply related [flat|nested] 42+ messages in thread
* [PATCH 12/12] staging: usbip: vhci_hcd.c: rename init and exit functions 2011-05-20 4:36 ` matt mooney @ 2011-05-20 4:37 ` matt mooney -1 siblings, 0 replies; 42+ messages in thread From: matt mooney @ 2011-05-20 4:37 UTC (permalink / raw) To: Greg Kroah-Hartman; +Cc: linux-kernel, kernel-janitors Change the prefix of the __init and __exit functions to vhci_hcd_ to correspond with the modules name. And change the suffix of the __exit function to exit instead of cleanup. Signed-off-by: matt mooney <mfm@muteddisk.com> --- drivers/staging/usbip/vhci_hcd.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c index 5b94b80..359b464 100644 --- a/drivers/staging/usbip/vhci_hcd.c +++ b/drivers/staging/usbip/vhci_hcd.c @@ -1209,7 +1209,7 @@ static struct platform_device the_pdev = { }, }; -static int __init vhci_init(void) +static int __init vhci_hcd_init(void) { int ret; @@ -1233,14 +1233,14 @@ err_driver_register: return ret; } -static void __exit vhci_cleanup(void) +static void __exit vhci_hcd_exit(void) { platform_device_unregister(&the_pdev); platform_driver_unregister(&vhci_driver); } -module_init(vhci_init); -module_exit(vhci_cleanup); +module_init(vhci_hcd_init); +module_exit(vhci_hcd_exit); MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); -- 1.7.5.1 ^ permalink raw reply related [flat|nested] 42+ messages in thread
* [PATCH 12/12] staging: usbip: vhci_hcd.c: rename init and exit functions @ 2011-05-20 4:37 ` matt mooney 0 siblings, 0 replies; 42+ messages in thread From: matt mooney @ 2011-05-20 4:37 UTC (permalink / raw) To: Greg Kroah-Hartman; +Cc: linux-kernel, kernel-janitors Change the prefix of the __init and __exit functions to vhci_hcd_ to correspond with the modules name. And change the suffix of the __exit function to exit instead of cleanup. Signed-off-by: matt mooney <mfm@muteddisk.com> --- drivers/staging/usbip/vhci_hcd.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c index 5b94b80..359b464 100644 --- a/drivers/staging/usbip/vhci_hcd.c +++ b/drivers/staging/usbip/vhci_hcd.c @@ -1209,7 +1209,7 @@ static struct platform_device the_pdev = { }, }; -static int __init vhci_init(void) +static int __init vhci_hcd_init(void) { int ret; @@ -1233,14 +1233,14 @@ err_driver_register: return ret; } -static void __exit vhci_cleanup(void) +static void __exit vhci_hcd_exit(void) { platform_device_unregister(&the_pdev); platform_driver_unregister(&vhci_driver); } -module_init(vhci_init); -module_exit(vhci_cleanup); +module_init(vhci_hcd_init); +module_exit(vhci_hcd_exit); MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); -- 1.7.5.1 ^ permalink raw reply related [flat|nested] 42+ messages in thread
end of thread, other threads:[~2011-05-21 11:45 UTC | newest] Thread overview: 42+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2011-05-20 4:36 [PATCH 00/12] staging: usbip matt mooney 2011-05-20 4:36 ` matt mooney 2011-05-20 4:36 ` [PATCH 01/12] staging: usbip: replace usbip_u{dbg,err,info} and printk with dev_ and pr_ matt mooney 2011-05-20 4:36 ` matt mooney 2011-05-20 4:59 ` [PATCH 01/12] staging: usbip: replace usbip_u{dbg,err,info} and Greg KH 2011-05-20 5:01 ` [PATCH 01/12] staging: usbip: replace usbip_u{dbg,err,info} and printk with dev_ and pr_ Greg KH 2011-05-20 5:25 ` matt mooney 2011-05-20 5:25 ` [PATCH 01/12] staging: usbip: replace usbip_u{dbg,err,info} and matt mooney 2011-05-20 12:53 ` [PATCH 01/12] staging: usbip: replace usbip_u{dbg,err,info} and printk with dev_ and pr_ Greg KH 2011-05-20 12:53 ` [PATCH 01/12] staging: usbip: replace usbip_u{dbg,err,info} and Greg KH 2011-05-20 18:51 ` [PATCH 01/12] staging: usbip: replace usbip_u{dbg,err,info} and printk with dev_ and pr_ matt mooney 2011-05-20 18:51 ` matt mooney 2011-05-20 4:36 ` [PATCH 02/12] staging: usbip: remove unnecessary lines and extra return statements matt mooney 2011-05-20 4:36 ` matt mooney 2011-05-20 4:36 ` [PATCH 03/12] staging: usbip: stub_main.c: reorder functions matt mooney 2011-05-20 4:36 ` matt mooney 2011-05-20 8:37 ` walter harms 2011-05-20 18:42 ` matt mooney 2011-05-20 4:36 ` [PATCH 04/12] staging: usbip: stub_main.c: code cleanup matt mooney 2011-05-20 4:36 ` matt mooney 2011-05-20 9:08 ` walter harms 2011-05-20 9:08 ` walter harms 2011-05-20 18:45 ` matt mooney 2011-05-20 18:45 ` matt mooney 2011-05-21 11:45 ` walter harms 2011-05-21 11:45 ` walter harms 2011-05-20 4:36 ` [PATCH 05/12] staging: usbip: stub_main.c: rename init and exit functions matt mooney 2011-05-20 4:36 ` matt mooney 2011-05-20 4:37 ` [PATCH 06/12] staging: usbip: stub_main.c: use KMEM_CACHE macro matt mooney 2011-05-20 4:37 ` matt mooney 2011-05-20 4:37 ` [PATCH 07/12] staging: usbip: usbip_common.c: fix misspelled function name matt mooney 2011-05-20 4:37 ` matt mooney 2011-05-20 4:37 ` [PATCH 08/12] staging: usbip: usbip_common.h: reorganize and document request headers matt mooney 2011-05-20 4:37 ` matt mooney 2011-05-20 4:37 ` [PATCH 09/12] staging: usbip: stub_dev.c: move stub_driver definition and update driver name matt mooney 2011-05-20 4:37 ` matt mooney 2011-05-20 4:37 ` [PATCH 10/12] staging: usbip: userspace: bind_driver.c: update kernel module name matt mooney 2011-05-20 4:37 ` matt mooney 2011-05-20 4:37 ` [PATCH 11/12] staging: usbip: usbip_common.c: rename init and exit functions matt mooney 2011-05-20 4:37 ` matt mooney 2011-05-20 4:37 ` [PATCH 12/12] staging: usbip: vhci_hcd.c: " matt mooney 2011-05-20 4:37 ` matt mooney
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.