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 mutex_lock(&sdev->ud.sysfs_lock); in usbip_sockfd_store()
123 spin_lock_irq(&sdev->ud.lock); in usbip_sockfd_store()
124 if (sdev->ud.status != SDEV_ST_USED) in usbip_sockfd_store()
127 spin_unlock_irq(&sdev->ud.lock); in usbip_sockfd_store()
129 usbip_event_add(&sdev->ud, SDEV_EVENT_DOWN); in usbip_sockfd_store()
130 mutex_unlock(&sdev->ud.sysfs_lock); in usbip_sockfd_store()
138 spin_unlock_irq(&sdev->ud.lock); in usbip_sockfd_store()
140 mutex_unlock(&sdev->ud.sysfs_lock); in usbip_sockfd_store()
155 struct stub_device *sdev = container_of(ud, struct stub_device, ud); in stub_shutdown_connection() local
164 dev_dbg(&sdev->udev->dev, "shutdown sockfd %d\n", ud->sockfd); in stub_shutdown_connection()
191 stub_device_cleanup_urbs(sdev); in stub_shutdown_connection()
198 spin_lock_irqsave(&sdev->priv_lock, flags); in stub_shutdown_connection()
199 list_for_each_entry_safe(unlink, tmp, &sdev->unlink_tx, list) { in stub_shutdown_connection()
203 list_for_each_entry_safe(unlink, tmp, &sdev->unlink_free, in stub_shutdown_connection()
208 spin_unlock_irqrestore(&sdev->priv_lock, flags); in stub_shutdown_connection()
214 struct stub_device *sdev = container_of(ud, struct stub_device, ud); in stub_device_reset() local
215 struct usb_device *udev = sdev->udev; in stub_device_reset()
259 struct stub_device *sdev; in stub_device_alloc() local
266 sdev = kzalloc(sizeof(struct stub_device), GFP_KERNEL); in stub_device_alloc()
267 if (!sdev) in stub_device_alloc()
270 sdev->udev = usb_get_dev(udev); in stub_device_alloc()
277 sdev->devid = (busnum << 16) | devnum; in stub_device_alloc()
278 sdev->ud.side = USBIP_STUB; in stub_device_alloc()
279 sdev->ud.status = SDEV_ST_AVAILABLE; in stub_device_alloc()
280 spin_lock_init(&sdev->ud.lock); in stub_device_alloc()
281 mutex_init(&sdev->ud.sysfs_lock); in stub_device_alloc()
282 sdev->ud.tcp_socket = NULL; in stub_device_alloc()
283 sdev->ud.sockfd = -1; in stub_device_alloc()
285 INIT_LIST_HEAD(&sdev->priv_init); in stub_device_alloc()
286 INIT_LIST_HEAD(&sdev->priv_tx); in stub_device_alloc()
287 INIT_LIST_HEAD(&sdev->priv_free); in stub_device_alloc()
288 INIT_LIST_HEAD(&sdev->unlink_free); in stub_device_alloc()
289 INIT_LIST_HEAD(&sdev->unlink_tx); in stub_device_alloc()
290 spin_lock_init(&sdev->priv_lock); in stub_device_alloc()
292 init_waitqueue_head(&sdev->tx_waitq); in stub_device_alloc()
294 sdev->ud.eh_ops.shutdown = stub_shutdown_connection; in stub_device_alloc()
295 sdev->ud.eh_ops.reset = stub_device_reset; in stub_device_alloc()
296 sdev->ud.eh_ops.unusable = stub_device_unusable; in stub_device_alloc()
298 usbip_start_eh(&sdev->ud); in stub_device_alloc()
302 return sdev; in stub_device_alloc()
305 static void stub_device_free(struct stub_device *sdev) in stub_device_free() argument
307 kfree(sdev); in stub_device_free()
312 struct stub_device *sdev = NULL; in stub_probe() local
323 sdev = stub_device_alloc(udev); in stub_probe()
324 if (!sdev) in stub_probe()
371 dev_set_drvdata(&udev->dev, sdev); in stub_probe()
373 busid_priv->sdev = sdev; in stub_probe()
401 busid_priv->sdev = NULL; in stub_probe()
413 stub_device_free(sdev); in stub_probe()
420 usbip_event_add(&busid_priv->sdev->ud, SDEV_EVENT_REMOVED); in shutdown_busid()
423 usbip_stop_eh(&busid_priv->sdev->ud); in shutdown_busid()
432 struct stub_device *sdev; in stub_disconnect() local
445 sdev = dev_get_drvdata(&udev->dev); in stub_disconnect()
448 if (!sdev) { in stub_disconnect()
491 usb_put_dev(sdev->udev); in stub_disconnect()
496 busid_priv->sdev = NULL; in stub_disconnect()
497 stub_device_free(sdev); in stub_disconnect()