Lines Matching refs:sdev

21 	struct stub_device *sdev = dev_get_drvdata(dev);  in usbip_status_show()  local
24 if (!sdev) { in usbip_status_show()
29 spin_lock_irq(&sdev->ud.lock); in usbip_status_show()
30 status = sdev->ud.status; in usbip_status_show()
31 spin_unlock_irq(&sdev->ud.lock); in usbip_status_show()
45 struct stub_device *sdev = dev_get_drvdata(dev); in usbip_sockfd_store() local
52 if (!sdev) { in usbip_sockfd_store()
66 mutex_lock(&sdev->ud.sysfs_lock); in usbip_sockfd_store()
67 spin_lock_irq(&sdev->ud.lock); in usbip_sockfd_store()
69 if (sdev->ud.status != SDEV_ST_AVAILABLE) { in usbip_sockfd_store()
87 spin_unlock_irq(&sdev->ud.lock); in usbip_sockfd_store()
88 tcp_rx = kthread_create(stub_rx_loop, &sdev->ud, "stub_rx"); in usbip_sockfd_store()
93 tcp_tx = kthread_create(stub_tx_loop, &sdev->ud, "stub_tx"); in usbip_sockfd_store()
105 spin_lock_irq(&sdev->ud.lock); in usbip_sockfd_store()
106 sdev->ud.tcp_socket = socket; in usbip_sockfd_store()
107 sdev->ud.sockfd = sockfd; in usbip_sockfd_store()
108 sdev->ud.tcp_rx = tcp_rx; in usbip_sockfd_store()
109 sdev->ud.tcp_tx = tcp_tx; in usbip_sockfd_store()
110 sdev->ud.status = SDEV_ST_USED; in usbip_sockfd_store()
111 spin_unlock_irq(&sdev->ud.lock); in usbip_sockfd_store()
113 wake_up_process(sdev->ud.tcp_rx); in usbip_sockfd_store()
114 wake_up_process(sdev->ud.tcp_tx); in usbip_sockfd_store()
116 mutex_unlock(&sdev->ud.sysfs_lock); in usbip_sockfd_store()
121 spin_lock_irq(&sdev->ud.lock); in usbip_sockfd_store()
122 if (sdev->ud.status != SDEV_ST_USED) in usbip_sockfd_store()
125 spin_unlock_irq(&sdev->ud.lock); in usbip_sockfd_store()
127 usbip_event_add(&sdev->ud, SDEV_EVENT_DOWN); in usbip_sockfd_store()
128 mutex_unlock(&sdev->ud.sysfs_lock); in usbip_sockfd_store()
136 spin_unlock_irq(&sdev->ud.lock); in usbip_sockfd_store()
138 mutex_unlock(&sdev->ud.sysfs_lock); in usbip_sockfd_store()
153 struct stub_device *sdev = container_of(ud, struct stub_device, ud); in stub_shutdown_connection() local
162 dev_dbg(&sdev->udev->dev, "shutdown sockfd %d\n", ud->sockfd); in stub_shutdown_connection()
189 stub_device_cleanup_urbs(sdev); in stub_shutdown_connection()
196 spin_lock_irqsave(&sdev->priv_lock, flags); in stub_shutdown_connection()
197 list_for_each_entry_safe(unlink, tmp, &sdev->unlink_tx, list) { in stub_shutdown_connection()
201 list_for_each_entry_safe(unlink, tmp, &sdev->unlink_free, in stub_shutdown_connection()
206 spin_unlock_irqrestore(&sdev->priv_lock, flags); in stub_shutdown_connection()
212 struct stub_device *sdev = container_of(ud, struct stub_device, ud); in stub_device_reset() local
213 struct usb_device *udev = sdev->udev; in stub_device_reset()
257 struct stub_device *sdev; in stub_device_alloc() local
264 sdev = kzalloc(sizeof(struct stub_device), GFP_KERNEL); in stub_device_alloc()
265 if (!sdev) in stub_device_alloc()
268 sdev->udev = usb_get_dev(udev); in stub_device_alloc()
275 sdev->devid = (busnum << 16) | devnum; in stub_device_alloc()
276 sdev->ud.side = USBIP_STUB; in stub_device_alloc()
277 sdev->ud.status = SDEV_ST_AVAILABLE; in stub_device_alloc()
278 spin_lock_init(&sdev->ud.lock); in stub_device_alloc()
279 mutex_init(&sdev->ud.sysfs_lock); in stub_device_alloc()
280 sdev->ud.tcp_socket = NULL; in stub_device_alloc()
281 sdev->ud.sockfd = -1; in stub_device_alloc()
283 INIT_LIST_HEAD(&sdev->priv_init); in stub_device_alloc()
284 INIT_LIST_HEAD(&sdev->priv_tx); in stub_device_alloc()
285 INIT_LIST_HEAD(&sdev->priv_free); in stub_device_alloc()
286 INIT_LIST_HEAD(&sdev->unlink_free); in stub_device_alloc()
287 INIT_LIST_HEAD(&sdev->unlink_tx); in stub_device_alloc()
288 spin_lock_init(&sdev->priv_lock); in stub_device_alloc()
290 init_waitqueue_head(&sdev->tx_waitq); in stub_device_alloc()
292 sdev->ud.eh_ops.shutdown = stub_shutdown_connection; in stub_device_alloc()
293 sdev->ud.eh_ops.reset = stub_device_reset; in stub_device_alloc()
294 sdev->ud.eh_ops.unusable = stub_device_unusable; in stub_device_alloc()
296 usbip_start_eh(&sdev->ud); in stub_device_alloc()
300 return sdev; in stub_device_alloc()
303 static void stub_device_free(struct stub_device *sdev) in stub_device_free() argument
305 kfree(sdev); in stub_device_free()
310 struct stub_device *sdev = NULL; in stub_probe() local
321 sdev = stub_device_alloc(udev); in stub_probe()
322 if (!sdev) in stub_probe()
369 dev_set_drvdata(&udev->dev, sdev); in stub_probe()
371 busid_priv->sdev = sdev; in stub_probe()
400 busid_priv->sdev = NULL; in stub_probe()
411 stub_device_free(sdev); in stub_probe()
418 usbip_event_add(&busid_priv->sdev->ud, SDEV_EVENT_REMOVED); in shutdown_busid()
421 usbip_stop_eh(&busid_priv->sdev->ud); in shutdown_busid()
430 struct stub_device *sdev; in stub_disconnect() local
443 sdev = dev_get_drvdata(&udev->dev); in stub_disconnect()
446 if (!sdev) { in stub_disconnect()
484 usb_put_dev(sdev->udev); in stub_disconnect()
489 busid_priv->sdev = NULL; in stub_disconnect()
490 stub_device_free(sdev); in stub_disconnect()