Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
[linux-btrfs-devel.git] / drivers / staging / usbip / stub.h
blobd4073684eacd0b78b6d0184bf0c41fa1fe67c03d
1 /*
2 * Copyright (C) 2003-2008 Takahiro Hirofuchi
4 * This is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
17 * USA.
20 #ifndef __USBIP_STUB_H
21 #define __USBIP_STUB_H
23 #include <linux/list.h>
24 #include <linux/slab.h>
25 #include <linux/spinlock.h>
26 #include <linux/types.h>
27 #include <linux/usb.h>
28 #include <linux/wait.h>
30 #define STUB_BUSID_OTHER 0
31 #define STUB_BUSID_REMOV 1
32 #define STUB_BUSID_ADDED 2
33 #define STUB_BUSID_ALLOC 3
35 struct stub_device {
36 struct usb_interface *interface;
37 struct usb_device *udev;
38 struct list_head list;
40 struct usbip_device ud;
41 __u32 devid;
44 * stub_priv preserves private data of each urb.
45 * It is allocated as stub_priv_cache and assigned to urb->context.
47 * stub_priv is always linked to any one of 3 lists;
48 * priv_init: linked to this until the comletion of a urb.
49 * priv_tx : linked to this after the completion of a urb.
50 * priv_free: linked to this after the sending of the result.
52 * Any of these list operations should be locked by priv_lock.
54 spinlock_t priv_lock;
55 struct list_head priv_init;
56 struct list_head priv_tx;
57 struct list_head priv_free;
59 /* see comments for unlinking in stub_rx.c */
60 struct list_head unlink_tx;
61 struct list_head unlink_free;
63 wait_queue_head_t tx_waitq;
66 /* private data into urb->priv */
67 struct stub_priv {
68 unsigned long seqnum;
69 struct list_head list;
70 struct stub_device *sdev;
71 struct urb *urb;
73 int unlinking;
76 struct stub_unlink {
77 unsigned long seqnum;
78 struct list_head list;
79 __u32 status;
82 /* same as SYSFS_BUS_ID_SIZE */
83 #define BUSID_SIZE 32
85 struct bus_id_priv {
86 char name[BUSID_SIZE];
87 char status;
88 int interf_count;
89 struct stub_device *sdev;
90 char shutdown_busid;
93 /* stub_priv is allocated from stub_priv_cache */
94 extern struct kmem_cache *stub_priv_cache;
96 /* stub_dev.c */
97 extern struct usb_driver stub_driver;
99 /* stub_main.c */
100 struct bus_id_priv *get_busid_priv(const char *busid);
101 int del_match_busid(char *busid);
102 void stub_device_cleanup_urbs(struct stub_device *sdev);
104 /* stub_rx.c */
105 int stub_rx_loop(void *data);
107 /* stub_tx.c */
108 void stub_enqueue_ret_unlink(struct stub_device *sdev, __u32 seqnum,
109 __u32 status);
110 void stub_complete(struct urb *urb);
111 int stub_tx_loop(void *data);
113 #endif /* __USBIP_STUB_H */