Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2003-2008 Takahiro Hirofuchi |
| 3 | * |
| 4 | * This is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation; either version 2 of the License, or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | * This is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
| 17 | * USA. |
| 18 | */ |
| 19 | |
matt mooney | 7aaacb4 | 2011-05-11 22:33:43 -0700 | [diff] [blame] | 20 | #include <linux/string.h> |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 21 | |
| 22 | #include "usbip_common.h" |
| 23 | #include "stub.h" |
| 24 | |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 25 | #define DRIVER_AUTHOR "Takahiro Hirofuchi" |
matt mooney | 64e6242 | 2011-05-11 22:33:44 -0700 | [diff] [blame] | 26 | #define DRIVER_DESC "USB/IP Host Driver" |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 27 | |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 28 | struct kmem_cache *stub_priv_cache; |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 29 | /* |
| 30 | * busid_tables defines matching busids that usbip can grab. A user can change |
| 31 | * dynamically what device is locally used and what device is exported to a |
| 32 | * remote host. |
| 33 | */ |
| 34 | #define MAX_BUSID 16 |
Endre Kollar | aa5873e | 2010-07-27 12:39:30 +0200 | [diff] [blame] | 35 | static struct bus_id_priv busid_table[MAX_BUSID]; |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 36 | static spinlock_t busid_table_lock; |
| 37 | |
matt mooney | efad25e | 2011-05-19 21:36:57 -0700 | [diff] [blame] | 38 | static void init_busid_table(void) |
| 39 | { |
| 40 | int i; |
| 41 | |
| 42 | for (i = 0; i < MAX_BUSID; i++) { |
| 43 | memset(busid_table[i].name, 0, BUSID_SIZE); |
| 44 | busid_table[i].status = STUB_BUSID_OTHER; |
| 45 | busid_table[i].interf_count = 0; |
| 46 | busid_table[i].sdev = NULL; |
| 47 | busid_table[i].shutdown_busid = 0; |
| 48 | } |
| 49 | |
| 50 | spin_lock_init(&busid_table_lock); |
| 51 | } |
| 52 | |
matt mooney | 41e02f0 | 2011-05-19 21:36:58 -0700 | [diff] [blame] | 53 | /* |
| 54 | * Find the index of the busid by name. |
| 55 | * Must be called with busid_table_lock held. |
| 56 | */ |
| 57 | static int get_busid_idx(const char *busid) |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 58 | { |
| 59 | int i; |
matt mooney | 41e02f0 | 2011-05-19 21:36:58 -0700 | [diff] [blame] | 60 | int idx = -1; |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 61 | |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 62 | for (i = 0; i < MAX_BUSID; i++) |
Endre Kollar | aa5873e | 2010-07-27 12:39:30 +0200 | [diff] [blame] | 63 | if (busid_table[i].name[0]) |
| 64 | if (!strncmp(busid_table[i].name, busid, BUSID_SIZE)) { |
matt mooney | 41e02f0 | 2011-05-19 21:36:58 -0700 | [diff] [blame] | 65 | idx = i; |
| 66 | break; |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 67 | } |
matt mooney | 41e02f0 | 2011-05-19 21:36:58 -0700 | [diff] [blame] | 68 | return idx; |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 69 | } |
| 70 | |
Endre Kollar | aa5873e | 2010-07-27 12:39:30 +0200 | [diff] [blame] | 71 | struct bus_id_priv *get_busid_priv(const char *busid) |
| 72 | { |
matt mooney | 41e02f0 | 2011-05-19 21:36:58 -0700 | [diff] [blame] | 73 | int idx; |
| 74 | struct bus_id_priv *bid = NULL; |
Endre Kollar | aa5873e | 2010-07-27 12:39:30 +0200 | [diff] [blame] | 75 | |
| 76 | spin_lock(&busid_table_lock); |
matt mooney | 41e02f0 | 2011-05-19 21:36:58 -0700 | [diff] [blame] | 77 | idx = get_busid_idx(busid); |
| 78 | if (idx >= 0) |
| 79 | bid = &(busid_table[idx]); |
Endre Kollar | aa5873e | 2010-07-27 12:39:30 +0200 | [diff] [blame] | 80 | spin_unlock(&busid_table_lock); |
| 81 | |
matt mooney | 41e02f0 | 2011-05-19 21:36:58 -0700 | [diff] [blame] | 82 | return bid; |
Endre Kollar | aa5873e | 2010-07-27 12:39:30 +0200 | [diff] [blame] | 83 | } |
| 84 | |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 85 | static int add_match_busid(char *busid) |
| 86 | { |
| 87 | int i; |
matt mooney | 41e02f0 | 2011-05-19 21:36:58 -0700 | [diff] [blame] | 88 | int ret = -1; |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 89 | |
| 90 | spin_lock(&busid_table_lock); |
matt mooney | 41e02f0 | 2011-05-19 21:36:58 -0700 | [diff] [blame] | 91 | /* already registered? */ |
| 92 | if (get_busid_idx(busid) >= 0) { |
| 93 | ret = 0; |
| 94 | goto out; |
| 95 | } |
| 96 | |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 97 | for (i = 0; i < MAX_BUSID; i++) |
Endre Kollar | aa5873e | 2010-07-27 12:39:30 +0200 | [diff] [blame] | 98 | if (!busid_table[i].name[0]) { |
| 99 | strncpy(busid_table[i].name, busid, BUSID_SIZE); |
| 100 | if ((busid_table[i].status != STUB_BUSID_ALLOC) && |
| 101 | (busid_table[i].status != STUB_BUSID_REMOV)) |
| 102 | busid_table[i].status = STUB_BUSID_ADDED; |
matt mooney | 41e02f0 | 2011-05-19 21:36:58 -0700 | [diff] [blame] | 103 | ret = 0; |
| 104 | break; |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 105 | } |
matt mooney | 41e02f0 | 2011-05-19 21:36:58 -0700 | [diff] [blame] | 106 | |
| 107 | out: |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 108 | spin_unlock(&busid_table_lock); |
| 109 | |
matt mooney | 41e02f0 | 2011-05-19 21:36:58 -0700 | [diff] [blame] | 110 | return ret; |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 111 | } |
| 112 | |
Endre Kollar | aa5873e | 2010-07-27 12:39:30 +0200 | [diff] [blame] | 113 | int del_match_busid(char *busid) |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 114 | { |
matt mooney | 41e02f0 | 2011-05-19 21:36:58 -0700 | [diff] [blame] | 115 | int idx; |
| 116 | int ret = -1; |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 117 | |
| 118 | spin_lock(&busid_table_lock); |
matt mooney | 41e02f0 | 2011-05-19 21:36:58 -0700 | [diff] [blame] | 119 | idx = get_busid_idx(busid); |
| 120 | if (idx < 0) |
| 121 | goto out; |
| 122 | |
| 123 | /* found */ |
| 124 | ret = 0; |
| 125 | |
| 126 | if (busid_table[idx].status == STUB_BUSID_OTHER) |
| 127 | memset(busid_table[idx].name, 0, BUSID_SIZE); |
| 128 | |
| 129 | if ((busid_table[idx].status != STUB_BUSID_OTHER) && |
| 130 | (busid_table[idx].status != STUB_BUSID_ADDED)) |
| 131 | busid_table[idx].status = STUB_BUSID_REMOV; |
| 132 | |
| 133 | out: |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 134 | spin_unlock(&busid_table_lock); |
| 135 | |
matt mooney | 41e02f0 | 2011-05-19 21:36:58 -0700 | [diff] [blame] | 136 | return ret; |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 137 | } |
matt mooney | 6c033b4 | 2011-05-06 03:47:42 -0700 | [diff] [blame] | 138 | |
matt mooney | efad25e | 2011-05-19 21:36:57 -0700 | [diff] [blame] | 139 | static ssize_t show_match_busid(struct device_driver *drv, char *buf) |
Endre Kollar | aa5873e | 2010-07-27 12:39:30 +0200 | [diff] [blame] | 140 | { |
| 141 | int i; |
matt mooney | efad25e | 2011-05-19 21:36:57 -0700 | [diff] [blame] | 142 | char *out = buf; |
Endre Kollar | aa5873e | 2010-07-27 12:39:30 +0200 | [diff] [blame] | 143 | |
matt mooney | efad25e | 2011-05-19 21:36:57 -0700 | [diff] [blame] | 144 | spin_lock(&busid_table_lock); |
| 145 | for (i = 0; i < MAX_BUSID; i++) |
| 146 | if (busid_table[i].name[0]) |
| 147 | out += sprintf(out, "%s ", busid_table[i].name); |
| 148 | spin_unlock(&busid_table_lock); |
matt mooney | efad25e | 2011-05-19 21:36:57 -0700 | [diff] [blame] | 149 | out += sprintf(out, "\n"); |
matt mooney | 41e02f0 | 2011-05-19 21:36:58 -0700 | [diff] [blame] | 150 | |
matt mooney | efad25e | 2011-05-19 21:36:57 -0700 | [diff] [blame] | 151 | return out - buf; |
Endre Kollar | aa5873e | 2010-07-27 12:39:30 +0200 | [diff] [blame] | 152 | } |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 153 | |
| 154 | static ssize_t store_match_busid(struct device_driver *dev, const char *buf, |
matt mooney | 6c033b4 | 2011-05-06 03:47:42 -0700 | [diff] [blame] | 155 | size_t count) |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 156 | { |
| 157 | int len; |
Kay Sievers | e913397 | 2008-10-30 01:59:32 +0100 | [diff] [blame] | 158 | char busid[BUSID_SIZE]; |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 159 | |
| 160 | if (count < 5) |
| 161 | return -EINVAL; |
| 162 | |
| 163 | /* strnlen() does not include \0 */ |
Kay Sievers | e913397 | 2008-10-30 01:59:32 +0100 | [diff] [blame] | 164 | len = strnlen(buf + 4, BUSID_SIZE); |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 165 | |
| 166 | /* busid needs to include \0 termination */ |
Kay Sievers | e913397 | 2008-10-30 01:59:32 +0100 | [diff] [blame] | 167 | if (!(len < BUSID_SIZE)) |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 168 | return -EINVAL; |
| 169 | |
Kay Sievers | e913397 | 2008-10-30 01:59:32 +0100 | [diff] [blame] | 170 | strncpy(busid, buf + 4, BUSID_SIZE); |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 171 | |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 172 | if (!strncmp(buf, "add ", 4)) { |
matt mooney | 41e02f0 | 2011-05-19 21:36:58 -0700 | [diff] [blame] | 173 | if (add_match_busid(busid) < 0) { |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 174 | return -ENOMEM; |
matt mooney | 41e02f0 | 2011-05-19 21:36:58 -0700 | [diff] [blame] | 175 | } else { |
matt mooney | 1a4b6f6 | 2011-05-19 16:47:32 -0700 | [diff] [blame] | 176 | pr_debug("add busid %s\n", busid); |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 177 | return count; |
| 178 | } |
| 179 | } else if (!strncmp(buf, "del ", 4)) { |
matt mooney | 41e02f0 | 2011-05-19 21:36:58 -0700 | [diff] [blame] | 180 | if (del_match_busid(busid) < 0) { |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 181 | return -ENODEV; |
matt mooney | 41e02f0 | 2011-05-19 21:36:58 -0700 | [diff] [blame] | 182 | } else { |
matt mooney | 1a4b6f6 | 2011-05-19 16:47:32 -0700 | [diff] [blame] | 183 | pr_debug("del busid %s\n", busid); |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 184 | return count; |
| 185 | } |
matt mooney | 41e02f0 | 2011-05-19 21:36:58 -0700 | [diff] [blame] | 186 | } else { |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 187 | return -EINVAL; |
matt mooney | 41e02f0 | 2011-05-19 21:36:58 -0700 | [diff] [blame] | 188 | } |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 189 | } |
matt mooney | 41e02f0 | 2011-05-19 21:36:58 -0700 | [diff] [blame] | 190 | static DRIVER_ATTR(match_busid, S_IRUSR | S_IWUSR, show_match_busid, |
matt mooney | 6c033b4 | 2011-05-06 03:47:42 -0700 | [diff] [blame] | 191 | store_match_busid); |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 192 | |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 193 | static struct stub_priv *stub_priv_pop_from_listhead(struct list_head *listhead) |
| 194 | { |
| 195 | struct stub_priv *priv, *tmp; |
| 196 | |
| 197 | list_for_each_entry_safe(priv, tmp, listhead, list) { |
| 198 | list_del(&priv->list); |
| 199 | return priv; |
| 200 | } |
| 201 | |
| 202 | return NULL; |
| 203 | } |
| 204 | |
| 205 | static struct stub_priv *stub_priv_pop(struct stub_device *sdev) |
| 206 | { |
| 207 | unsigned long flags; |
| 208 | struct stub_priv *priv; |
| 209 | |
| 210 | spin_lock_irqsave(&sdev->priv_lock, flags); |
| 211 | |
| 212 | priv = stub_priv_pop_from_listhead(&sdev->priv_init); |
matt mooney | 41e02f0 | 2011-05-19 21:36:58 -0700 | [diff] [blame] | 213 | if (priv) |
| 214 | goto done; |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 215 | |
| 216 | priv = stub_priv_pop_from_listhead(&sdev->priv_tx); |
matt mooney | 41e02f0 | 2011-05-19 21:36:58 -0700 | [diff] [blame] | 217 | if (priv) |
| 218 | goto done; |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 219 | |
| 220 | priv = stub_priv_pop_from_listhead(&sdev->priv_free); |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 221 | |
matt mooney | 41e02f0 | 2011-05-19 21:36:58 -0700 | [diff] [blame] | 222 | done: |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 223 | spin_unlock_irqrestore(&sdev->priv_lock, flags); |
matt mooney | 41e02f0 | 2011-05-19 21:36:58 -0700 | [diff] [blame] | 224 | |
| 225 | return priv; |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 226 | } |
| 227 | |
| 228 | void stub_device_cleanup_urbs(struct stub_device *sdev) |
| 229 | { |
| 230 | struct stub_priv *priv; |
matt mooney | 41e02f0 | 2011-05-19 21:36:58 -0700 | [diff] [blame] | 231 | struct urb *urb; |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 232 | |
matt mooney | 1a4b6f6 | 2011-05-19 16:47:32 -0700 | [diff] [blame] | 233 | dev_dbg(&sdev->udev->dev, "free sdev %p\n", sdev); |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 234 | |
| 235 | while ((priv = stub_priv_pop(sdev))) { |
matt mooney | 41e02f0 | 2011-05-19 21:36:58 -0700 | [diff] [blame] | 236 | urb = priv->urb; |
matt mooney | 1a4b6f6 | 2011-05-19 16:47:32 -0700 | [diff] [blame] | 237 | dev_dbg(&sdev->udev->dev, "free urb %p\n", urb); |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 238 | usb_kill_urb(urb); |
| 239 | |
| 240 | kmem_cache_free(stub_priv_cache, priv); |
| 241 | |
Ilia Mirkin | 06dde50 | 2011-03-13 00:29:12 -0500 | [diff] [blame] | 242 | kfree(urb->transfer_buffer); |
Ilia Mirkin | 06dde50 | 2011-03-13 00:29:12 -0500 | [diff] [blame] | 243 | kfree(urb->setup_packet); |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 244 | usb_free_urb(urb); |
| 245 | } |
| 246 | } |
| 247 | |
matt mooney | 27ed5da | 2011-05-19 21:36:59 -0700 | [diff] [blame^] | 248 | static int __init usbip_host_init(void) |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 249 | { |
| 250 | int ret; |
| 251 | |
| 252 | stub_priv_cache = kmem_cache_create("stub_priv", |
| 253 | sizeof(struct stub_priv), 0, |
| 254 | SLAB_HWCACHE_ALIGN, NULL); |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 255 | if (!stub_priv_cache) { |
matt mooney | 41e02f0 | 2011-05-19 21:36:58 -0700 | [diff] [blame] | 256 | pr_err("kmem_cache_create failed\n"); |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 257 | return -ENOMEM; |
| 258 | } |
| 259 | |
| 260 | ret = usb_register(&stub_driver); |
matt mooney | 41e02f0 | 2011-05-19 21:36:58 -0700 | [diff] [blame] | 261 | if (ret < 0) { |
matt mooney | 1a4b6f6 | 2011-05-19 16:47:32 -0700 | [diff] [blame] | 262 | pr_err("usb_register failed %d\n", ret); |
matt mooney | 41e02f0 | 2011-05-19 21:36:58 -0700 | [diff] [blame] | 263 | goto err_usb_register; |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 264 | } |
| 265 | |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 266 | ret = driver_create_file(&stub_driver.drvwrap.driver, |
| 267 | &driver_attr_match_busid); |
matt mooney | 41e02f0 | 2011-05-19 21:36:58 -0700 | [diff] [blame] | 268 | if (ret < 0) { |
| 269 | pr_err("driver_create_file failed\n"); |
| 270 | goto err_create_file; |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 271 | } |
| 272 | |
matt mooney | 41e02f0 | 2011-05-19 21:36:58 -0700 | [diff] [blame] | 273 | init_busid_table(); |
| 274 | pr_info(DRIVER_DESC " v" USBIP_VERSION "\n"); |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 275 | return ret; |
matt mooney | 41e02f0 | 2011-05-19 21:36:58 -0700 | [diff] [blame] | 276 | |
| 277 | err_create_file: |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 278 | usb_deregister(&stub_driver); |
matt mooney | 41e02f0 | 2011-05-19 21:36:58 -0700 | [diff] [blame] | 279 | err_usb_register: |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 280 | kmem_cache_destroy(stub_priv_cache); |
| 281 | return ret; |
| 282 | } |
| 283 | |
matt mooney | 27ed5da | 2011-05-19 21:36:59 -0700 | [diff] [blame^] | 284 | static void __exit usbip_host_exit(void) |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 285 | { |
| 286 | driver_remove_file(&stub_driver.drvwrap.driver, |
| 287 | &driver_attr_match_busid); |
| 288 | |
| 289 | /* |
| 290 | * deregister() calls stub_disconnect() for all devices. Device |
| 291 | * specific data is cleared in stub_disconnect(). |
| 292 | */ |
| 293 | usb_deregister(&stub_driver); |
| 294 | |
| 295 | kmem_cache_destroy(stub_priv_cache); |
| 296 | } |
| 297 | |
matt mooney | 27ed5da | 2011-05-19 21:36:59 -0700 | [diff] [blame^] | 298 | module_init(usbip_host_init); |
| 299 | module_exit(usbip_host_exit); |
Takahiro Hirofuchi | 4d7b5c7 | 2008-07-09 14:56:51 -0600 | [diff] [blame] | 300 | |
| 301 | MODULE_AUTHOR(DRIVER_AUTHOR); |
| 302 | MODULE_DESCRIPTION(DRIVER_DESC); |
| 303 | MODULE_LICENSE("GPL"); |
matt mooney | 6973c6f | 2011-05-11 01:54:14 -0700 | [diff] [blame] | 304 | MODULE_VERSION(USBIP_VERSION); |