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
50 if (!sdev) { in usbip_sockfd_store()
64 spin_lock_irq(&sdev->ud.lock); in usbip_sockfd_store()
66 if (sdev->ud.status != SDEV_ST_AVAILABLE) { in usbip_sockfd_store()
75 sdev->ud.tcp_socket = socket; in usbip_sockfd_store()
76 sdev->ud.sockfd = sockfd; in usbip_sockfd_store()
78 spin_unlock_irq(&sdev->ud.lock); in usbip_sockfd_store()
80 sdev->ud.tcp_rx = kthread_get_run(stub_rx_loop, &sdev->ud, in usbip_sockfd_store()
82 sdev->ud.tcp_tx = kthread_get_run(stub_tx_loop, &sdev->ud, in usbip_sockfd_store()
85 spin_lock_irq(&sdev->ud.lock); in usbip_sockfd_store()
86 sdev->ud.status = SDEV_ST_USED; in usbip_sockfd_store()
87 spin_unlock_irq(&sdev->ud.lock); in usbip_sockfd_store()
92 spin_lock_irq(&sdev->ud.lock); in usbip_sockfd_store()
93 if (sdev->ud.status != SDEV_ST_USED) in usbip_sockfd_store()
96 spin_unlock_irq(&sdev->ud.lock); in usbip_sockfd_store()
98 usbip_event_add(&sdev->ud, SDEV_EVENT_DOWN); in usbip_sockfd_store()
104 spin_unlock_irq(&sdev->ud.lock); in usbip_sockfd_store()
119 struct stub_device *sdev = container_of(ud, struct stub_device, ud); in stub_shutdown_connection() local
128 dev_dbg(&sdev->udev->dev, "shutdown sockfd %d\n", ud->sockfd); in stub_shutdown_connection()
155 stub_device_cleanup_urbs(sdev); in stub_shutdown_connection()
162 spin_lock_irqsave(&sdev->priv_lock, flags); in stub_shutdown_connection()
163 list_for_each_entry_safe(unlink, tmp, &sdev->unlink_tx, list) { in stub_shutdown_connection()
167 list_for_each_entry_safe(unlink, tmp, &sdev->unlink_free, in stub_shutdown_connection()
172 spin_unlock_irqrestore(&sdev->priv_lock, flags); in stub_shutdown_connection()
178 struct stub_device *sdev = container_of(ud, struct stub_device, ud); in stub_device_reset() local
179 struct usb_device *udev = sdev->udev; in stub_device_reset()
223 struct stub_device *sdev; in stub_device_alloc() local
230 sdev = kzalloc(sizeof(struct stub_device), GFP_KERNEL); in stub_device_alloc()
231 if (!sdev) in stub_device_alloc()
234 sdev->udev = usb_get_dev(udev); in stub_device_alloc()
241 sdev->devid = (busnum << 16) | devnum; in stub_device_alloc()
242 sdev->ud.side = USBIP_STUB; in stub_device_alloc()
243 sdev->ud.status = SDEV_ST_AVAILABLE; in stub_device_alloc()
244 spin_lock_init(&sdev->ud.lock); in stub_device_alloc()
245 sdev->ud.tcp_socket = NULL; in stub_device_alloc()
246 sdev->ud.sockfd = -1; in stub_device_alloc()
248 INIT_LIST_HEAD(&sdev->priv_init); in stub_device_alloc()
249 INIT_LIST_HEAD(&sdev->priv_tx); in stub_device_alloc()
250 INIT_LIST_HEAD(&sdev->priv_free); in stub_device_alloc()
251 INIT_LIST_HEAD(&sdev->unlink_free); in stub_device_alloc()
252 INIT_LIST_HEAD(&sdev->unlink_tx); in stub_device_alloc()
253 spin_lock_init(&sdev->priv_lock); in stub_device_alloc()
255 init_waitqueue_head(&sdev->tx_waitq); in stub_device_alloc()
257 sdev->ud.eh_ops.shutdown = stub_shutdown_connection; in stub_device_alloc()
258 sdev->ud.eh_ops.reset = stub_device_reset; in stub_device_alloc()
259 sdev->ud.eh_ops.unusable = stub_device_unusable; in stub_device_alloc()
261 usbip_start_eh(&sdev->ud); in stub_device_alloc()
265 return sdev; in stub_device_alloc()
268 static void stub_device_free(struct stub_device *sdev) in stub_device_free() argument
270 kfree(sdev); in stub_device_free()
275 struct stub_device *sdev = NULL; in stub_probe() local
286 sdev = stub_device_alloc(udev); in stub_probe()
287 if (!sdev) in stub_probe()
334 dev_set_drvdata(&udev->dev, sdev); in stub_probe()
336 busid_priv->sdev = sdev; in stub_probe()
365 busid_priv->sdev = NULL; in stub_probe()
376 stub_device_free(sdev); in stub_probe()
383 usbip_event_add(&busid_priv->sdev->ud, SDEV_EVENT_REMOVED); in shutdown_busid()
386 usbip_stop_eh(&busid_priv->sdev->ud); in shutdown_busid()
395 struct stub_device *sdev; in stub_disconnect() local
408 sdev = dev_get_drvdata(&udev->dev); in stub_disconnect()
411 if (!sdev) { in stub_disconnect()
449 usb_put_dev(sdev->udev); in stub_disconnect()
454 busid_priv->sdev = NULL; in stub_disconnect()
455 stub_device_free(sdev); in stub_disconnect()