1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22#include <linux/usb.h>
23#include <linux/usb/ch11.h>
24#include <linux/usb/hcd.h>
25#include "usb.h"
26
27struct usb_hub {
28 struct device *intfdev;
29 struct usb_device *hdev;
30 struct kref kref;
31 struct urb *urb;
32
33
34 u8 (*buffer)[8];
35 union {
36 struct usb_hub_status hub;
37 struct usb_port_status port;
38 } *status;
39 struct mutex status_mutex;
40
41 int error;
42 int nerrors;
43
44 struct list_head event_list;
45 unsigned long event_bits[1];
46 unsigned long change_bits[1];
47
48 unsigned long busy_bits[1];
49
50 unsigned long removed_bits[1];
51
52 unsigned long wakeup_bits[1];
53
54#if USB_MAXCHILDREN > 31
55#error event_bits[] is too short!
56#endif
57
58 struct usb_hub_descriptor *descriptor;
59 struct usb_tt tt;
60
61 unsigned mA_per_port;
62
63 unsigned limited_power:1;
64 unsigned quiescing:1;
65 unsigned disconnected:1;
66
67 unsigned quirk_check_port_auto_suspend:1;
68
69 unsigned has_indicators:1;
70 u8 indicator[USB_MAXCHILDREN];
71 struct delayed_work leds;
72 struct delayed_work init_work;
73 struct usb_port **ports;
74};
75
76
77
78
79
80
81
82
83
84
85
86struct usb_port {
87 struct usb_device *child;
88 struct device dev;
89 struct dev_state *port_owner;
90 enum usb_port_connect_type connect_type;
91 u8 portnum;
92 unsigned power_is_on:1;
93 unsigned did_runtime_put:1;
94};
95
96#define to_usb_port(_dev) \
97 container_of(_dev, struct usb_port, dev)
98
99extern int usb_hub_create_port_device(struct usb_hub *hub,
100 int port1);
101extern void usb_hub_remove_port_device(struct usb_hub *hub,
102 int port1);
103extern int usb_hub_set_port_power(struct usb_device *hdev,
104 int port1, bool set);
105extern struct usb_hub *usb_hub_to_struct_hub(struct usb_device *hdev);
106extern int hub_port_debounce(struct usb_hub *hub, int port1,
107 bool must_be_connected);
108extern int usb_clear_port_feature(struct usb_device *hdev,
109 int port1, int feature);
110
111static inline int hub_port_debounce_be_connected(struct usb_hub *hub,
112 int port1)
113{
114 return hub_port_debounce(hub, port1, true);
115}
116
117static inline int hub_port_debounce_be_stable(struct usb_hub *hub,
118 int port1)
119{
120 return hub_port_debounce(hub, port1, false);
121}
122
123