Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
[linux-btrfs-devel.git] / drivers / staging / usbip / vhci.h
blob88b32981cf1f1d5d89b83c67fdfb8c13cb155702
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 */
11 #ifndef __USBIP_VHCI_H
12 #define __USBIP_VHCI_H
14 #include <linux/device.h>
15 #include <linux/list.h>
16 #include <linux/spinlock.h>
17 #include <linux/sysfs.h>
18 #include <linux/types.h>
19 #include <linux/usb.h>
20 #include <linux/usb/hcd.h>
21 #include <linux/wait.h>
23 struct vhci_device {
24 struct usb_device *udev;
27 * devid specifies a remote usb device uniquely instead
28 * of combination of busnum and devnum.
30 __u32 devid;
32 /* speed of a remote device */
33 enum usb_device_speed speed;
35 /* vhci root-hub port to which this device is attached */
36 __u32 rhport;
38 struct usbip_device ud;
40 /* lock for the below link lists */
41 spinlock_t priv_lock;
43 /* vhci_priv is linked to one of them. */
44 struct list_head priv_tx;
45 struct list_head priv_rx;
47 /* vhci_unlink is linked to one of them */
48 struct list_head unlink_tx;
49 struct list_head unlink_rx;
51 /* vhci_tx thread sleeps for this queue */
52 wait_queue_head_t waitq_tx;
55 /* urb->hcpriv, use container_of() */
56 struct vhci_priv {
57 unsigned long seqnum;
58 struct list_head list;
60 struct vhci_device *vdev;
61 struct urb *urb;
64 struct vhci_unlink {
65 /* seqnum of this request */
66 unsigned long seqnum;
68 struct list_head list;
70 /* seqnum of the unlink target */
71 unsigned long unlink_seqnum;
75 * The number of ports is less than 16 ?
76 * USB_MAXCHILDREN is statically defined to 16 in usb.h. Its maximum value
77 * would be 31 because the event_bits[1] of struct usb_hub is defined as
78 * unsigned long in hub.h
80 #define VHCI_NPORTS 8
82 /* for usb_bus.hcpriv */
83 struct vhci_hcd {
84 spinlock_t lock;
86 u32 port_status[VHCI_NPORTS];
88 unsigned resuming:1;
89 unsigned long re_timeout;
91 atomic_t seqnum;
94 * NOTE:
95 * wIndex shows the port number and begins from 1.
96 * But, the index of this array begins from 0.
98 struct vhci_device vdev[VHCI_NPORTS];
101 extern struct vhci_hcd *the_controller;
102 extern const struct attribute_group dev_attr_group;
103 #define hardware (&the_controller->pdev.dev)
105 /* vhci_hcd.c */
106 void rh_port_connect(int rhport, enum usb_device_speed speed);
107 void rh_port_disconnect(int rhport);
109 /* vhci_rx.c */
110 struct urb *pickup_urb_and_free_priv(struct vhci_device *vdev, __u32 seqnum);
111 int vhci_rx_loop(void *data);
113 /* vhci_tx.c */
114 int vhci_tx_loop(void *data);
116 static inline struct vhci_device *port_to_vdev(__u32 port)
118 return &the_controller->vdev[port];
121 static inline struct vhci_hcd *hcd_to_vhci(struct usb_hcd *hcd)
123 return (struct vhci_hcd *) (hcd->hcd_priv);
126 static inline struct usb_hcd *vhci_to_hcd(struct vhci_hcd *vhci)
128 return container_of((void *) vhci, struct usb_hcd, hcd_priv);
131 static inline struct device *vhci_dev(struct vhci_hcd *vhci)
133 return vhci_to_hcd(vhci)->self.controller;
136 #endif /* __USBIP_VHCI_H */