treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / drivers / usb / usbip / stub.h
blobd11270560c2477870374bfc8d694de9a294f6d31
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3 * Copyright (C) 2003-2008 Takahiro Hirofuchi
4 */
6 #ifndef __USBIP_STUB_H
7 #define __USBIP_STUB_H
9 #include <linux/list.h>
10 #include <linux/slab.h>
11 #include <linux/spinlock.h>
12 #include <linux/types.h>
13 #include <linux/usb.h>
14 #include <linux/wait.h>
16 #define STUB_BUSID_OTHER 0
17 #define STUB_BUSID_REMOV 1
18 #define STUB_BUSID_ADDED 2
19 #define STUB_BUSID_ALLOC 3
21 struct stub_device {
22 struct usb_device *udev;
24 struct usbip_device ud;
25 __u32 devid;
28 * stub_priv preserves private data of each urb.
29 * It is allocated as stub_priv_cache and assigned to urb->context.
31 * stub_priv is always linked to any one of 3 lists;
32 * priv_init: linked to this until the comletion of a urb.
33 * priv_tx : linked to this after the completion of a urb.
34 * priv_free: linked to this after the sending of the result.
36 * Any of these list operations should be locked by priv_lock.
38 spinlock_t priv_lock;
39 struct list_head priv_init;
40 struct list_head priv_tx;
41 struct list_head priv_free;
43 /* see comments for unlinking in stub_rx.c */
44 struct list_head unlink_tx;
45 struct list_head unlink_free;
47 wait_queue_head_t tx_waitq;
50 /* private data into urb->priv */
51 struct stub_priv {
52 unsigned long seqnum;
53 struct list_head list;
54 struct stub_device *sdev;
55 struct urb **urbs;
56 struct scatterlist *sgl;
57 int num_urbs;
58 int completed_urbs;
59 int urb_status;
61 int unlinking;
64 struct stub_unlink {
65 unsigned long seqnum;
66 struct list_head list;
67 __u32 status;
70 /* same as SYSFS_BUS_ID_SIZE */
71 #define BUSID_SIZE 32
73 struct bus_id_priv {
74 char name[BUSID_SIZE];
75 char status;
76 int interf_count;
77 struct stub_device *sdev;
78 struct usb_device *udev;
79 char shutdown_busid;
80 spinlock_t busid_lock;
83 /* stub_priv is allocated from stub_priv_cache */
84 extern struct kmem_cache *stub_priv_cache;
86 /* stub_dev.c */
87 extern struct usb_device_driver stub_driver;
89 /* stub_main.c */
90 struct bus_id_priv *get_busid_priv(const char *busid);
91 void put_busid_priv(struct bus_id_priv *bid);
92 int del_match_busid(char *busid);
93 void stub_free_priv_and_urb(struct stub_priv *priv);
94 void stub_device_cleanup_urbs(struct stub_device *sdev);
96 /* stub_rx.c */
97 int stub_rx_loop(void *data);
99 /* stub_tx.c */
100 void stub_enqueue_ret_unlink(struct stub_device *sdev, __u32 seqnum,
101 __u32 status);
102 void stub_complete(struct urb *urb);
103 int stub_tx_loop(void *data);
105 #endif /* __USBIP_STUB_H */