blob: 77a5b3f8736af1e760a807894da0f5b2a0c9cbbb [file] [log] [blame]
Greg Kroah-Hartman5fd54ac2017-11-03 11:28:30 +01001// SPDX-License-Identifier: GPL-2.0+
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -06002/*
3 * Copyright (C) 2003-2008 Takahiro Hirofuchi
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -06004 */
5
matt mooney7aaacb42011-05-11 22:33:43 -07006#include <linux/string.h>
Paul Gortmaker99c97852011-07-03 15:49:50 -04007#include <linux/module.h>
Valentina Maneaa46034c2014-03-08 14:53:33 +02008#include <linux/device.h>
Suwan Kimea44d192019-08-28 12:27:41 +09009#include <linux/scatterlist.h>
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -060010
11#include "usbip_common.h"
12#include "stub.h"
13
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -060014#define DRIVER_AUTHOR "Takahiro Hirofuchi"
matt mooney64e62422011-05-11 22:33:44 -070015#define DRIVER_DESC "USB/IP Host Driver"
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -060016
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -060017struct kmem_cache *stub_priv_cache;
Shuah Khan (Samsung OSG)7510df32018-04-30 16:17:20 -060018
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -060019/*
20 * busid_tables defines matching busids that usbip can grab. A user can change
21 * dynamically what device is locally used and what device is exported to a
22 * remote host.
23 */
24#define MAX_BUSID 16
Endre Kollaraa5873e2010-07-27 12:39:30 +020025static struct bus_id_priv busid_table[MAX_BUSID];
Zheng Yongjun841081d2020-12-23 22:14:31 +080026static DEFINE_SPINLOCK(busid_table_lock);
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -060027
matt mooneyefad25e2011-05-19 21:36:57 -070028static void init_busid_table(void)
29{
Shuah Khan (Samsung OSG)220765572018-05-14 20:49:58 -060030 int i;
31
Kurt Kanzenbach521e1e72013-04-04 16:03:10 +020032 /*
33 * This also sets the bus_table[i].status to
34 * STUB_BUSID_OTHER, which is 0.
35 */
matt mooney0a186be2011-05-27 01:49:24 -070036 memset(busid_table, 0, sizeof(busid_table));
matt mooneyefad25e2011-05-19 21:36:57 -070037
Shuah Khan (Samsung OSG)220765572018-05-14 20:49:58 -060038 for (i = 0; i < MAX_BUSID; i++)
39 spin_lock_init(&busid_table[i].busid_lock);
matt mooneyefad25e2011-05-19 21:36:57 -070040}
41
matt mooney41e02f02011-05-19 21:36:58 -070042/*
43 * Find the index of the busid by name.
44 * Must be called with busid_table_lock held.
45 */
46static int get_busid_idx(const char *busid)
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -060047{
48 int i;
matt mooney41e02f02011-05-19 21:36:58 -070049 int idx = -1;
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -060050
Shuah Khan (Samsung OSG)220765572018-05-14 20:49:58 -060051 for (i = 0; i < MAX_BUSID; i++) {
52 spin_lock(&busid_table[i].busid_lock);
Endre Kollaraa5873e2010-07-27 12:39:30 +020053 if (busid_table[i].name[0])
54 if (!strncmp(busid_table[i].name, busid, BUSID_SIZE)) {
matt mooney41e02f02011-05-19 21:36:58 -070055 idx = i;
Shuah Khan (Samsung OSG)220765572018-05-14 20:49:58 -060056 spin_unlock(&busid_table[i].busid_lock);
matt mooney41e02f02011-05-19 21:36:58 -070057 break;
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -060058 }
Shuah Khan (Samsung OSG)220765572018-05-14 20:49:58 -060059 spin_unlock(&busid_table[i].busid_lock);
60 }
matt mooney41e02f02011-05-19 21:36:58 -070061 return idx;
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -060062}
63
Shuah Khan (Samsung OSG)220765572018-05-14 20:49:58 -060064/* Returns holding busid_lock. Should call put_busid_priv() to unlock */
Endre Kollaraa5873e2010-07-27 12:39:30 +020065struct bus_id_priv *get_busid_priv(const char *busid)
66{
matt mooney41e02f02011-05-19 21:36:58 -070067 int idx;
68 struct bus_id_priv *bid = NULL;
Endre Kollaraa5873e2010-07-27 12:39:30 +020069
70 spin_lock(&busid_table_lock);
matt mooney41e02f02011-05-19 21:36:58 -070071 idx = get_busid_idx(busid);
Shuah Khan (Samsung OSG)220765572018-05-14 20:49:58 -060072 if (idx >= 0) {
matt mooney41e02f02011-05-19 21:36:58 -070073 bid = &(busid_table[idx]);
Shuah Khan (Samsung OSG)220765572018-05-14 20:49:58 -060074 /* get busid_lock before returning */
75 spin_lock(&bid->busid_lock);
76 }
Endre Kollaraa5873e2010-07-27 12:39:30 +020077 spin_unlock(&busid_table_lock);
78
matt mooney41e02f02011-05-19 21:36:58 -070079 return bid;
Endre Kollaraa5873e2010-07-27 12:39:30 +020080}
81
Shuah Khan (Samsung OSG)220765572018-05-14 20:49:58 -060082void put_busid_priv(struct bus_id_priv *bid)
83{
Shuah Khan (Samsung OSG)c1716542018-05-15 17:57:23 -060084 if (bid)
85 spin_unlock(&bid->busid_lock);
Shuah Khan (Samsung OSG)220765572018-05-14 20:49:58 -060086}
87
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -060088static int add_match_busid(char *busid)
89{
90 int i;
matt mooney41e02f02011-05-19 21:36:58 -070091 int ret = -1;
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -060092
93 spin_lock(&busid_table_lock);
matt mooney41e02f02011-05-19 21:36:58 -070094 /* already registered? */
95 if (get_busid_idx(busid) >= 0) {
96 ret = 0;
97 goto out;
98 }
99
Shuah Khan (Samsung OSG)220765572018-05-14 20:49:58 -0600100 for (i = 0; i < MAX_BUSID; i++) {
101 spin_lock(&busid_table[i].busid_lock);
Endre Kollaraa5873e2010-07-27 12:39:30 +0200102 if (!busid_table[i].name[0]) {
Rickard Strandqvist96955ed2014-07-26 16:43:20 +0200103 strlcpy(busid_table[i].name, busid, BUSID_SIZE);
Endre Kollaraa5873e2010-07-27 12:39:30 +0200104 if ((busid_table[i].status != STUB_BUSID_ALLOC) &&
105 (busid_table[i].status != STUB_BUSID_REMOV))
106 busid_table[i].status = STUB_BUSID_ADDED;
matt mooney41e02f02011-05-19 21:36:58 -0700107 ret = 0;
Shuah Khan (Samsung OSG)220765572018-05-14 20:49:58 -0600108 spin_unlock(&busid_table[i].busid_lock);
matt mooney41e02f02011-05-19 21:36:58 -0700109 break;
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -0600110 }
Shuah Khan (Samsung OSG)220765572018-05-14 20:49:58 -0600111 spin_unlock(&busid_table[i].busid_lock);
112 }
matt mooney41e02f02011-05-19 21:36:58 -0700113
114out:
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -0600115 spin_unlock(&busid_table_lock);
116
matt mooney41e02f02011-05-19 21:36:58 -0700117 return ret;
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -0600118}
119
Endre Kollaraa5873e2010-07-27 12:39:30 +0200120int del_match_busid(char *busid)
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -0600121{
matt mooney41e02f02011-05-19 21:36:58 -0700122 int idx;
123 int ret = -1;
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -0600124
125 spin_lock(&busid_table_lock);
matt mooney41e02f02011-05-19 21:36:58 -0700126 idx = get_busid_idx(busid);
127 if (idx < 0)
128 goto out;
129
130 /* found */
131 ret = 0;
132
Shuah Khan (Samsung OSG)220765572018-05-14 20:49:58 -0600133 spin_lock(&busid_table[idx].busid_lock);
134
matt mooney41e02f02011-05-19 21:36:58 -0700135 if (busid_table[idx].status == STUB_BUSID_OTHER)
136 memset(busid_table[idx].name, 0, BUSID_SIZE);
137
138 if ((busid_table[idx].status != STUB_BUSID_OTHER) &&
139 (busid_table[idx].status != STUB_BUSID_ADDED))
140 busid_table[idx].status = STUB_BUSID_REMOV;
141
Shuah Khan (Samsung OSG)220765572018-05-14 20:49:58 -0600142 spin_unlock(&busid_table[idx].busid_lock);
matt mooney41e02f02011-05-19 21:36:58 -0700143out:
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -0600144 spin_unlock(&busid_table_lock);
145
matt mooney41e02f02011-05-19 21:36:58 -0700146 return ret;
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -0600147}
matt mooney6c033b42011-05-06 03:47:42 -0700148
Greg Kroah-Hartmancc3d53d2017-06-09 11:03:14 +0200149static ssize_t match_busid_show(struct device_driver *drv, char *buf)
Endre Kollaraa5873e2010-07-27 12:39:30 +0200150{
151 int i;
matt mooneyefad25e2011-05-19 21:36:57 -0700152 char *out = buf;
Endre Kollaraa5873e2010-07-27 12:39:30 +0200153
matt mooneyefad25e2011-05-19 21:36:57 -0700154 spin_lock(&busid_table_lock);
Shuah Khan (Samsung OSG)220765572018-05-14 20:49:58 -0600155 for (i = 0; i < MAX_BUSID; i++) {
156 spin_lock(&busid_table[i].busid_lock);
matt mooneyefad25e2011-05-19 21:36:57 -0700157 if (busid_table[i].name[0])
158 out += sprintf(out, "%s ", busid_table[i].name);
Shuah Khan (Samsung OSG)220765572018-05-14 20:49:58 -0600159 spin_unlock(&busid_table[i].busid_lock);
160 }
matt mooneyefad25e2011-05-19 21:36:57 -0700161 spin_unlock(&busid_table_lock);
matt mooneyefad25e2011-05-19 21:36:57 -0700162 out += sprintf(out, "\n");
matt mooney41e02f02011-05-19 21:36:58 -0700163
matt mooneyefad25e2011-05-19 21:36:57 -0700164 return out - buf;
Endre Kollaraa5873e2010-07-27 12:39:30 +0200165}
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -0600166
Greg Kroah-Hartmancc3d53d2017-06-09 11:03:14 +0200167static ssize_t match_busid_store(struct device_driver *dev, const char *buf,
matt mooney6c033b42011-05-06 03:47:42 -0700168 size_t count)
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -0600169{
170 int len;
Kay Sieverse9133972008-10-30 01:59:32 +0100171 char busid[BUSID_SIZE];
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -0600172
173 if (count < 5)
174 return -EINVAL;
175
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -0600176 /* busid needs to include \0 termination */
Rickard Strandqvist96955ed2014-07-26 16:43:20 +0200177 len = strlcpy(busid, buf + 4, BUSID_SIZE);
178 if (sizeof(busid) <= len)
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -0600179 return -EINVAL;
180
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -0600181 if (!strncmp(buf, "add ", 4)) {
Kurt Kanzenbach2183b772013-04-04 16:03:09 +0200182 if (add_match_busid(busid) < 0)
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -0600183 return -ENOMEM;
Kurt Kanzenbach2183b772013-04-04 16:03:09 +0200184
185 pr_debug("add busid %s\n", busid);
186 return count;
matt mooney41e02f02011-05-19 21:36:58 -0700187 }
Kurt Kanzenbach2183b772013-04-04 16:03:09 +0200188
189 if (!strncmp(buf, "del ", 4)) {
190 if (del_match_busid(busid) < 0)
191 return -ENODEV;
192
193 pr_debug("del busid %s\n", busid);
194 return count;
195 }
196
197 return -EINVAL;
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -0600198}
Greg Kroah-Hartmancc3d53d2017-06-09 11:03:14 +0200199static DRIVER_ATTR_RW(match_busid);
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -0600200
Shuah Khan (Samsung OSG)7510df32018-04-30 16:17:20 -0600201static int do_rebind(char *busid, struct bus_id_priv *busid_priv)
202{
Shuah Khan3a38e872019-05-02 13:47:18 -0600203 int ret = 0;
Shuah Khan (Samsung OSG)7510df32018-04-30 16:17:20 -0600204
205 /* device_attach() callers should hold parent lock for USB */
206 if (busid_priv->udev->dev.parent)
207 device_lock(busid_priv->udev->dev.parent);
208 ret = device_attach(&busid_priv->udev->dev);
209 if (busid_priv->udev->dev.parent)
210 device_unlock(busid_priv->udev->dev.parent);
Shuah Khan3a38e872019-05-02 13:47:18 -0600211 if (ret < 0)
Shuah Khan (Samsung OSG)7510df32018-04-30 16:17:20 -0600212 dev_err(&busid_priv->udev->dev, "rebind failed\n");
Shuah Khan3a38e872019-05-02 13:47:18 -0600213 return ret;
Shuah Khan (Samsung OSG)7510df32018-04-30 16:17:20 -0600214}
215
216static void stub_device_rebind(void)
217{
218#if IS_MODULE(CONFIG_USBIP_HOST)
219 struct bus_id_priv *busid_priv;
220 int i;
221
222 /* update status to STUB_BUSID_OTHER so probe ignores the device */
223 spin_lock(&busid_table_lock);
224 for (i = 0; i < MAX_BUSID; i++) {
225 if (busid_table[i].name[0] &&
226 busid_table[i].shutdown_busid) {
227 busid_priv = &(busid_table[i]);
228 busid_priv->status = STUB_BUSID_OTHER;
229 }
230 }
231 spin_unlock(&busid_table_lock);
232
Shuah Khan (Samsung OSG)220765572018-05-14 20:49:58 -0600233 /* now run rebind - no need to hold locks. driver files are removed */
Shuah Khan (Samsung OSG)7510df32018-04-30 16:17:20 -0600234 for (i = 0; i < MAX_BUSID; i++) {
235 if (busid_table[i].name[0] &&
236 busid_table[i].shutdown_busid) {
237 busid_priv = &(busid_table[i]);
238 do_rebind(busid_table[i].name, busid_priv);
239 }
240 }
241#endif
242}
243
Valentina Maneaa46034c2014-03-08 14:53:33 +0200244static ssize_t rebind_store(struct device_driver *dev, const char *buf,
245 size_t count)
246{
247 int ret;
248 int len;
249 struct bus_id_priv *bid;
250
251 /* buf length should be less that BUSID_SIZE */
252 len = strnlen(buf, BUSID_SIZE);
253
254 if (!(len < BUSID_SIZE))
255 return -EINVAL;
256
257 bid = get_busid_priv(buf);
258 if (!bid)
259 return -ENODEV;
260
Shuah Khan (Samsung OSG)1e180f12018-04-30 16:17:19 -0600261 /* mark the device for deletion so probe ignores it during rescan */
262 bid->status = STUB_BUSID_OTHER;
Shuah Khan (Samsung OSG)220765572018-05-14 20:49:58 -0600263 /* release the busid lock */
264 put_busid_priv(bid);
Shuah Khan (Samsung OSG)1e180f12018-04-30 16:17:19 -0600265
Shuah Khan (Samsung OSG)7510df32018-04-30 16:17:20 -0600266 ret = do_rebind((char *) buf, bid);
267 if (ret < 0)
Valentina Maneaa46034c2014-03-08 14:53:33 +0200268 return ret;
Valentina Maneaa46034c2014-03-08 14:53:33 +0200269
Shuah Khan (Samsung OSG)1e180f12018-04-30 16:17:19 -0600270 /* delete device from busid_table */
271 del_match_busid((char *) buf);
272
Valentina Maneaa46034c2014-03-08 14:53:33 +0200273 return count;
274}
275
276static DRIVER_ATTR_WO(rebind);
277
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -0600278static struct stub_priv *stub_priv_pop_from_listhead(struct list_head *listhead)
279{
280 struct stub_priv *priv, *tmp;
281
282 list_for_each_entry_safe(priv, tmp, listhead, list) {
Suwan Kimea44d192019-08-28 12:27:41 +0900283 list_del_init(&priv->list);
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -0600284 return priv;
285 }
286
287 return NULL;
288}
289
Suwan Kimea44d192019-08-28 12:27:41 +0900290void stub_free_priv_and_urb(struct stub_priv *priv)
291{
292 struct urb *urb;
293 int i;
294
295 for (i = 0; i < priv->num_urbs; i++) {
296 urb = priv->urbs[i];
297
298 if (!urb)
299 return;
300
301 kfree(urb->setup_packet);
302 urb->setup_packet = NULL;
303
304
305 if (urb->transfer_buffer && !priv->sgl) {
306 kfree(urb->transfer_buffer);
307 urb->transfer_buffer = NULL;
308 }
309
310 if (urb->num_sgs) {
311 sgl_free(urb->sg);
312 urb->sg = NULL;
313 urb->num_sgs = 0;
314 }
315
316 usb_free_urb(urb);
317 }
318 if (!list_empty(&priv->list))
319 list_del(&priv->list);
320 if (priv->sgl)
321 sgl_free(priv->sgl);
322 kfree(priv->urbs);
323 kmem_cache_free(stub_priv_cache, priv);
324}
325
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -0600326static struct stub_priv *stub_priv_pop(struct stub_device *sdev)
327{
328 unsigned long flags;
329 struct stub_priv *priv;
330
331 spin_lock_irqsave(&sdev->priv_lock, flags);
332
333 priv = stub_priv_pop_from_listhead(&sdev->priv_init);
matt mooney41e02f02011-05-19 21:36:58 -0700334 if (priv)
335 goto done;
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -0600336
337 priv = stub_priv_pop_from_listhead(&sdev->priv_tx);
matt mooney41e02f02011-05-19 21:36:58 -0700338 if (priv)
339 goto done;
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -0600340
341 priv = stub_priv_pop_from_listhead(&sdev->priv_free);
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -0600342
matt mooney41e02f02011-05-19 21:36:58 -0700343done:
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -0600344 spin_unlock_irqrestore(&sdev->priv_lock, flags);
matt mooney41e02f02011-05-19 21:36:58 -0700345
346 return priv;
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -0600347}
348
349void stub_device_cleanup_urbs(struct stub_device *sdev)
350{
351 struct stub_priv *priv;
Suwan Kimea44d192019-08-28 12:27:41 +0900352 int i;
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -0600353
Shuah Khan248a2202017-12-18 17:23:37 -0700354 dev_dbg(&sdev->udev->dev, "Stub device cleaning up urbs\n");
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -0600355
356 while ((priv = stub_priv_pop(sdev))) {
Suwan Kimea44d192019-08-28 12:27:41 +0900357 for (i = 0; i < priv->num_urbs; i++)
358 usb_kill_urb(priv->urbs[i]);
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -0600359
Suwan Kimea44d192019-08-28 12:27:41 +0900360 stub_free_priv_and_urb(priv);
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -0600361 }
362}
363
matt mooney27ed5da2011-05-19 21:36:59 -0700364static int __init usbip_host_init(void)
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -0600365{
366 int ret;
367
Bart Westgeest737912e2012-01-25 13:46:32 -0500368 init_busid_table();
matt mooney7d4de892011-05-19 21:37:00 -0700369
Bart Westgeest737912e2012-01-25 13:46:32 -0500370 stub_priv_cache = KMEM_CACHE(stub_priv, SLAB_HWCACHE_ALIGN);
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -0600371 if (!stub_priv_cache) {
matt mooney41e02f02011-05-19 21:36:58 -0700372 pr_err("kmem_cache_create failed\n");
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -0600373 return -ENOMEM;
374 }
375
Valentina Maneab7945b72014-01-23 23:12:29 +0200376 ret = usb_register_device_driver(&stub_driver, THIS_MODULE);
navin patidar1583aeb2013-09-10 10:44:07 +0530377 if (ret) {
matt mooney1a4b6f62011-05-19 16:47:32 -0700378 pr_err("usb_register failed %d\n", ret);
matt mooney41e02f02011-05-19 21:36:58 -0700379 goto err_usb_register;
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -0600380 }
381
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -0600382 ret = driver_create_file(&stub_driver.drvwrap.driver,
383 &driver_attr_match_busid);
navin patidar1583aeb2013-09-10 10:44:07 +0530384 if (ret) {
matt mooney41e02f02011-05-19 21:36:58 -0700385 pr_err("driver_create_file failed\n");
386 goto err_create_file;
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -0600387 }
388
Valentina Maneaa46034c2014-03-08 14:53:33 +0200389 ret = driver_create_file(&stub_driver.drvwrap.driver,
390 &driver_attr_rebind);
391 if (ret) {
392 pr_err("driver_create_file failed\n");
393 goto err_create_file;
394 }
395
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -0600396 return ret;
matt mooney41e02f02011-05-19 21:36:58 -0700397
398err_create_file:
Valentina Maneab7945b72014-01-23 23:12:29 +0200399 usb_deregister_device_driver(&stub_driver);
matt mooney41e02f02011-05-19 21:36:58 -0700400err_usb_register:
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -0600401 kmem_cache_destroy(stub_priv_cache);
402 return ret;
403}
404
matt mooney27ed5da2011-05-19 21:36:59 -0700405static void __exit usbip_host_exit(void)
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -0600406{
407 driver_remove_file(&stub_driver.drvwrap.driver,
408 &driver_attr_match_busid);
409
Valentina Maneaa46034c2014-03-08 14:53:33 +0200410 driver_remove_file(&stub_driver.drvwrap.driver,
411 &driver_attr_rebind);
412
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -0600413 /*
414 * deregister() calls stub_disconnect() for all devices. Device
415 * specific data is cleared in stub_disconnect().
416 */
Valentina Maneab7945b72014-01-23 23:12:29 +0200417 usb_deregister_device_driver(&stub_driver);
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -0600418
Shuah Khan (Samsung OSG)7510df32018-04-30 16:17:20 -0600419 /* initiate scan to attach devices */
420 stub_device_rebind();
421
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -0600422 kmem_cache_destroy(stub_priv_cache);
423}
424
matt mooney27ed5da2011-05-19 21:36:59 -0700425module_init(usbip_host_init);
426module_exit(usbip_host_exit);
Takahiro Hirofuchi4d7b5c72008-07-09 14:56:51 -0600427
428MODULE_AUTHOR(DRIVER_AUTHOR);
429MODULE_DESCRIPTION(DRIVER_DESC);
430MODULE_LICENSE("GPL");