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