Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
usb.h
Go to the documentation of this file.
1 #include <linux/pm.h>
2 #include <linux/acpi.h>
3 
4 struct dev_state;
5 
6 /* Functions local to drivers/usb/core/ */
7 
8 extern int usb_create_sysfs_dev_files(struct usb_device *dev);
9 extern void usb_remove_sysfs_dev_files(struct usb_device *dev);
12 extern int usb_create_ep_devs(struct device *parent,
13  struct usb_host_endpoint *endpoint,
14  struct usb_device *udev);
15 extern void usb_remove_ep_devs(struct usb_host_endpoint *endpoint);
16 
17 extern void usb_enable_endpoint(struct usb_device *dev,
18  struct usb_host_endpoint *ep, bool reset_toggle);
19 extern void usb_enable_interface(struct usb_device *dev,
20  struct usb_interface *intf, bool reset_toggles);
21 extern void usb_disable_endpoint(struct usb_device *dev, unsigned int epaddr,
22  bool reset_hardware);
23 extern void usb_disable_interface(struct usb_device *dev,
24  struct usb_interface *intf, bool reset_hardware);
25 extern void usb_release_interface_cache(struct kref *ref);
26 extern void usb_disable_device(struct usb_device *dev, int skip_ep0);
27 extern int usb_deauthorize_device(struct usb_device *);
28 extern int usb_authorize_device(struct usb_device *);
29 extern void usb_detect_quirks(struct usb_device *udev);
30 extern void usb_detect_interface_quirks(struct usb_device *udev);
31 extern int usb_remove_device(struct usb_device *udev);
32 
33 extern int usb_get_device_descriptor(struct usb_device *dev,
34  unsigned int size);
35 extern int usb_get_bos_descriptor(struct usb_device *dev);
36 extern void usb_release_bos_descriptor(struct usb_device *dev);
37 extern char *usb_cache_string(struct usb_device *udev, int index);
38 extern int usb_set_configuration(struct usb_device *dev, int configuration);
39 extern int usb_choose_configuration(struct usb_device *udev);
40 
41 extern void usb_kick_khubd(struct usb_device *dev);
42 extern int usb_match_one_id_intf(struct usb_device *dev,
43  struct usb_host_interface *intf,
44  const struct usb_device_id *id);
45 extern int usb_match_device(struct usb_device *dev,
46  const struct usb_device_id *id);
47 extern void usb_forced_unbind_intf(struct usb_interface *intf);
48 extern void usb_rebind_intf(struct usb_interface *intf);
49 
50 extern int usb_hub_claim_port(struct usb_device *hdev, unsigned port,
51  struct dev_state *owner);
52 extern int usb_hub_release_port(struct usb_device *hdev, unsigned port,
53  struct dev_state *owner);
54 extern void usb_hub_release_all_ports(struct usb_device *hdev,
55  struct dev_state *owner);
56 extern bool usb_device_is_owned(struct usb_device *udev);
57 
58 extern int usb_hub_init(void);
59 extern void usb_hub_cleanup(void);
60 extern int usb_major_init(void);
61 extern void usb_major_cleanup(void);
62 
63 #ifdef CONFIG_PM
64 
65 extern int usb_suspend(struct device *dev, pm_message_t msg);
66 extern int usb_resume(struct device *dev, pm_message_t msg);
67 extern int usb_resume_complete(struct device *dev);
68 
69 extern int usb_port_suspend(struct usb_device *dev, pm_message_t msg);
70 extern int usb_port_resume(struct usb_device *dev, pm_message_t msg);
71 
72 #else
73 
74 static inline int usb_port_suspend(struct usb_device *udev, pm_message_t msg)
75 {
76  return 0;
77 }
78 
79 static inline int usb_port_resume(struct usb_device *udev, pm_message_t msg)
80 {
81  return 0;
82 }
83 
84 #endif
85 
86 #ifdef CONFIG_USB_SUSPEND
87 
88 extern void usb_autosuspend_device(struct usb_device *udev);
89 extern int usb_autoresume_device(struct usb_device *udev);
90 extern int usb_remote_wakeup(struct usb_device *dev);
91 extern int usb_runtime_suspend(struct device *dev);
92 extern int usb_runtime_resume(struct device *dev);
93 extern int usb_runtime_idle(struct device *dev);
94 extern int usb_set_usb2_hardware_lpm(struct usb_device *udev, int enable);
95 
96 #else
97 
98 #define usb_autosuspend_device(udev) do {} while (0)
99 static inline int usb_autoresume_device(struct usb_device *udev)
100 {
101  return 0;
102 }
103 
104 static inline int usb_remote_wakeup(struct usb_device *udev)
105 {
106  return 0;
107 }
108 
109 static inline int usb_set_usb2_hardware_lpm(struct usb_device *udev, int enable)
110 {
111  return 0;
112 }
113 #endif
114 
115 extern struct bus_type usb_bus_type;
116 extern struct device_type usb_device_type;
117 extern struct device_type usb_if_device_type;
118 extern struct device_type usb_ep_device_type;
119 extern struct device_type usb_port_device_type;
120 extern struct usb_device_driver usb_generic_driver;
121 
122 static inline int is_usb_device(const struct device *dev)
123 {
124  return dev->type == &usb_device_type;
125 }
126 
127 static inline int is_usb_interface(const struct device *dev)
128 {
129  return dev->type == &usb_if_device_type;
130 }
131 
132 static inline int is_usb_endpoint(const struct device *dev)
133 {
134  return dev->type == &usb_ep_device_type;
135 }
136 
137 static inline int is_usb_port(const struct device *dev)
138 {
139  return dev->type == &usb_port_device_type;
140 }
141 
142 /* Do the same for device drivers and interface drivers. */
143 
144 static inline int is_usb_device_driver(struct device_driver *drv)
145 {
146  return container_of(drv, struct usbdrv_wrap, driver)->
147  for_devices;
148 }
149 
150 /* for labeling diagnostics */
151 extern const char *usbcore_name;
152 
153 /* sysfs stuff */
154 extern const struct attribute_group *usb_device_groups[];
155 extern const struct attribute_group *usb_interface_groups[];
156 
157 /* usbfs stuff */
158 extern struct mutex usbfs_mutex;
159 extern struct usb_driver usbfs_driver;
160 extern const struct file_operations usbfs_devices_fops;
161 extern const struct file_operations usbdev_file_operations;
162 extern void usbfs_conn_disc_event(void);
163 
164 extern int usb_devio_init(void);
165 extern void usb_devio_cleanup(void);
166 
167 /* internal notify stuff */
168 extern void usb_notify_add_device(struct usb_device *udev);
169 extern void usb_notify_remove_device(struct usb_device *udev);
170 extern void usb_notify_add_bus(struct usb_bus *ubus);
171 extern void usb_notify_remove_bus(struct usb_bus *ubus);
172 extern enum usb_port_connect_type
173  usb_get_hub_port_connect_type(struct usb_device *hdev, int port1);
174 extern void usb_set_hub_port_connect_type(struct usb_device *hdev, int port1,
175  enum usb_port_connect_type type);
176 
177 #ifdef CONFIG_ACPI
178 extern int usb_acpi_register(void);
179 extern void usb_acpi_unregister(void);
180 extern acpi_handle usb_get_hub_port_acpi_handle(struct usb_device *hdev,
181  int port1);
182 #else
183 static inline int usb_acpi_register(void) { return 0; };
184 static inline void usb_acpi_unregister(void) { };
185 #endif