Lines Matching full:ud

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()
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()
104 /* lock and update sdev->ud state */ 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()
153 static void stub_shutdown_connection(struct usbip_device *ud) in stub_shutdown_connection() argument
155 struct stub_device *sdev = container_of(ud, struct stub_device, ud); in stub_shutdown_connection()
163 if (ud->tcp_socket) { in stub_shutdown_connection()
164 dev_dbg(&sdev->udev->dev, "shutdown sockfd %d\n", ud->sockfd); in stub_shutdown_connection()
165 kernel_sock_shutdown(ud->tcp_socket, SHUT_RDWR); in stub_shutdown_connection()
169 if (ud->tcp_rx) { in stub_shutdown_connection()
170 kthread_stop_put(ud->tcp_rx); in stub_shutdown_connection()
171 ud->tcp_rx = NULL; in stub_shutdown_connection()
173 if (ud->tcp_tx) { in stub_shutdown_connection()
174 kthread_stop_put(ud->tcp_tx); in stub_shutdown_connection()
175 ud->tcp_tx = NULL; in stub_shutdown_connection()
184 if (ud->tcp_socket) { in stub_shutdown_connection()
185 sockfd_put(ud->tcp_socket); in stub_shutdown_connection()
186 ud->tcp_socket = NULL; in stub_shutdown_connection()
187 ud->sockfd = -1; in stub_shutdown_connection()
212 static void stub_device_reset(struct usbip_device *ud) in stub_device_reset() argument
214 struct stub_device *sdev = container_of(ud, struct stub_device, ud); in stub_device_reset()
223 spin_lock_irq(&ud->lock); in stub_device_reset()
224 ud->status = SDEV_ST_ERROR; in stub_device_reset()
225 spin_unlock_irq(&ud->lock); in stub_device_reset()
233 spin_lock_irq(&ud->lock); in stub_device_reset()
236 ud->status = SDEV_ST_ERROR; in stub_device_reset()
239 ud->status = SDEV_ST_AVAILABLE; in stub_device_reset()
241 spin_unlock_irq(&ud->lock); in stub_device_reset()
244 static void stub_device_unusable(struct usbip_device *ud) in stub_device_unusable() argument
246 spin_lock_irq(&ud->lock); in stub_device_unusable()
247 ud->status = SDEV_ST_ERROR; in stub_device_unusable()
248 spin_unlock_irq(&ud->lock); in stub_device_unusable()
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()
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()
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()