diff options
Diffstat (limited to 'drivers/staging/usbip/stub_main.c')
-rw-r--r-- | drivers/staging/usbip/stub_main.c | 51 |
1 files changed, 15 insertions, 36 deletions
diff --git a/drivers/staging/usbip/stub_main.c b/drivers/staging/usbip/stub_main.c index 076a7e531098..e9085d663945 100644 --- a/drivers/staging/usbip/stub_main.c +++ b/drivers/staging/usbip/stub_main.c @@ -17,24 +17,17 @@ * USA. */ -#include <linux/slab.h> +#include <linux/string.h> #include "usbip_common.h" #include "stub.h" -/* Version Information */ -#define DRIVER_VERSION "1.0" #define DRIVER_AUTHOR "Takahiro Hirofuchi" -#define DRIVER_DESC "Stub Driver for USB/IP" +#define DRIVER_DESC "USB/IP Host Driver" /* stub_priv is allocated from stub_priv_cache */ struct kmem_cache *stub_priv_cache; -/*-------------------------------------------------------------------------*/ - -/* Define sysfs entries for the usbip driver */ - - /* * 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 @@ -44,7 +37,6 @@ struct kmem_cache *stub_priv_cache; static struct bus_id_priv busid_table[MAX_BUSID]; static spinlock_t busid_table_lock; - int match_busid(const char *busid) { int i; @@ -148,11 +140,11 @@ int del_match_busid(char *busid) return -1; } + 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; @@ -160,11 +152,12 @@ static void init_busid_table(void) busid_table[i].sdev = NULL; busid_table[i].shutdown_busid = 0; } + spin_lock_init(&busid_table_lock); } static ssize_t store_match_busid(struct device_driver *dev, const char *buf, - size_t count) + size_t count) { int len; char busid[BUSID_SIZE]; @@ -181,33 +174,25 @@ 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) 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 return -EINVAL; } - static DRIVER_ATTR(match_busid, S_IRUSR|S_IWUSR, show_match_busid, - store_match_busid); - - - -/*-------------------------------------------------------------------------*/ - -/* Cleanup functions used to free private data */ + store_match_busid); static struct stub_priv *stub_priv_pop_from_listhead(struct list_head *listhead) { @@ -254,27 +239,23 @@ 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); kfree(urb->transfer_buffer); - kfree(urb->setup_packet); usb_free_urb(urb); } } - -/*-------------------------------------------------------------------------*/ - static int __init usb_stub_init(void) { int ret; @@ -284,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 ":" DRIVER_VERSION "\n"); + pr_info(DRIVER_DESC " " USBIP_VERSION "\n"); init_busid_table(); @@ -305,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; } @@ -337,3 +315,4 @@ module_exit(usb_stub_exit); MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); MODULE_LICENSE("GPL"); +MODULE_VERSION(USBIP_VERSION); |