20 #include <linux/device.h>
22 #include <linux/module.h>
35 { USB_DEVICE(0x05ac, 0x0301) },
36 { USB_DEVICE(0x0430, 0x0009) },
37 { USB_DEVICE(0x059b, 0x0001) },
38 { USB_DEVICE(0x04b3, 0x4427) },
39 { USB_DEVICE(0x05a9, 0xa511) },
40 { USB_DEVICE(0x55aa, 0x0201) },
41 { USB_DEVICE(0x046d, 0x0870) },
42 { USB_DEVICE(0x04bb, 0x0101) },
43 { USB_DEVICE(0x04bb, 0x0904) },
44 { USB_DEVICE(0x04bb, 0x0201) },
45 { USB_DEVICE(0x08bb, 0x2702) },
46 { USB_DEVICE(0x046d, 0x08b2) },
69 spin_lock(&sdev->
ud.lock);
70 status = sdev->
ud.status;
71 spin_unlock(&sdev->
ud.lock);
83 const char *buf,
size_t count)
94 sscanf(buf,
"%d", &sockfd);
99 spin_lock(&sdev->
ud.lock);
103 spin_unlock(&sdev->
ud.lock);
109 spin_unlock(&sdev->
ud.lock);
112 sdev->
ud.tcp_socket = socket;
114 spin_unlock(&sdev->
ud.lock);
119 spin_lock(&sdev->
ud.lock);
121 spin_unlock(&sdev->
ud.lock);
126 spin_lock(&sdev->
ud.lock);
128 spin_unlock(&sdev->
ud.lock);
131 spin_unlock(&sdev->
ud.lock);
140 static int stub_add_files(
struct device *dev)
166 static void stub_remove_files(
struct device *dev)
184 dev_dbg(&sdev->
udev->dev,
"shutdown tcp_socket %p\n",
228 spin_unlock_irqrestore(&sdev->
priv_lock, flags);
235 struct usb_device *
udev = sdev->
udev;
238 dev_dbg(&udev->dev,
"device reset");
242 dev_err(&udev->dev,
"lock for reset\n");
243 spin_lock(&ud->
lock);
245 spin_unlock(&ud->
lock);
251 usb_unlock_device(udev);
253 spin_lock(&ud->
lock);
255 dev_err(&udev->dev,
"device reset\n");
258 dev_info(&udev->dev,
"device reset\n");
261 spin_unlock(&ud->
lock);
264 static void stub_device_unusable(
struct usbip_device *ud)
266 spin_lock(&ud->
lock);
268 spin_unlock(&ud->
lock);
277 static struct stub_device *stub_device_alloc(
struct usb_device *udev,
281 int busnum = interface_to_busnum(interface);
282 int devnum = interface_to_devnum(interface);
284 dev_dbg(&interface->dev,
"allocating stub device");
289 dev_err(&interface->dev,
"no memory for stub_device\n");
301 sdev->
devid = (busnum << 16) | devnum;
305 sdev->
ud.tcp_socket =
NULL;
308 INIT_LIST_HEAD(&sdev->
priv_tx);
316 sdev->
ud.eh_ops.shutdown = stub_shutdown_connection;
317 sdev->
ud.eh_ops.reset = stub_device_reset;
318 sdev->
ud.eh_ops.unusable = stub_device_unusable;
322 dev_dbg(&interface->dev,
"register new interface\n");
327 static int stub_device_free(
struct stub_device *sdev)
351 struct usb_device *udev = interface_to_usbdev(interface);
353 const char *udev_busid = dev_name(interface->dev.parent);
357 dev_dbg(&interface->dev,
"Enter\n");
363 dev_info(&interface->dev,
"%s is not in match_busid table... "
364 "skip!\n", udev_busid);
375 dev_dbg(&udev->dev,
"%s is a usb hub device... skip!\n",
380 if (!
strcmp(udev->bus->bus_name,
"vhci_hcd")) {
381 dev_dbg(&udev->dev,
"%s is attached on vhci_hcd... skip!\n",
387 sdev = busid_priv->
sdev;
392 dev_info(&interface->dev,
"usbip-host: register new interface "
393 "(bus %u dev %u ifn %u)\n",
394 udev->bus->busnum, udev->devnum,
395 interface->cur_altsetting->desc.bInterfaceNumber);
398 usb_set_intfdata(interface, sdev);
400 err = stub_add_files(&interface->dev);
402 dev_err(&interface->dev,
"stub_add_files for %s\n",
404 usb_set_intfdata(interface,
NULL);
414 sdev = stub_device_alloc(udev, interface);
418 dev_info(&interface->dev,
"usbip-host: register new device "
419 "(bus %u dev %u ifn %u)\n", udev->bus->busnum, udev->devnum,
420 interface->cur_altsetting->desc.bInterfaceNumber);
426 usb_set_intfdata(interface, sdev);
430 err = stub_add_files(&interface->dev);
432 dev_err(&interface->dev,
"stub_add_files for %s\n", udev_busid);
433 usb_set_intfdata(interface,
NULL);
438 stub_device_free(sdev);
464 const char *udev_busid = dev_name(interface->dev.parent);
467 dev_dbg(&interface->dev,
"Enter\n");
475 sdev = usb_get_intfdata(interface);
479 dev_err(&interface->dev,
"could not get device");
484 usb_set_intfdata(interface,
NULL);
490 stub_remove_files(&interface->dev);
515 stub_device_free(sdev);
532 dev_dbg(&interface->dev,
"pre_reset\n");
538 dev_dbg(&interface->dev,
"post_reset\n");
543 .name =
"usbip-host",
545 .disconnect = stub_disconnect,
546 .id_table = stub_table,