Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* Functions local to drivers/usb/core/ */ |
2 | ||
1b21d5e1 | 3 | extern int usb_create_sysfs_dev_files (struct usb_device *dev); |
1da177e4 | 4 | extern void usb_remove_sysfs_dev_files (struct usb_device *dev); |
1b21d5e1 | 5 | extern int usb_create_sysfs_intf_files (struct usb_interface *intf); |
1da177e4 | 6 | extern void usb_remove_sysfs_intf_files (struct usb_interface *intf); |
1b21d5e1 | 7 | extern int usb_create_ep_files(struct device *parent, struct usb_host_endpoint *endpoint, |
84412f62 GKH |
8 | struct usb_device *udev); |
9 | extern void usb_remove_ep_files(struct usb_host_endpoint *endpoint); | |
1da177e4 LT |
10 | |
11 | extern void usb_disable_endpoint (struct usb_device *dev, unsigned int epaddr); | |
12 | extern void usb_disable_interface (struct usb_device *dev, | |
13 | struct usb_interface *intf); | |
14 | extern void usb_release_interface_cache(struct kref *ref); | |
15 | extern void usb_disable_device (struct usb_device *dev, int skip_ep0); | |
7ceec1f1 | 16 | extern void usb_detect_quirks(struct usb_device *udev); |
1da177e4 LT |
17 | |
18 | extern int usb_get_device_descriptor(struct usb_device *dev, | |
19 | unsigned int size); | |
4f62efe6 | 20 | extern char *usb_cache_string(struct usb_device *udev, int index); |
1da177e4 LT |
21 | extern int usb_set_configuration(struct usb_device *dev, int configuration); |
22 | ||
1da177e4 LT |
23 | extern void usb_kick_khubd(struct usb_device *dev); |
24 | extern void usb_resume_root_hub(struct usb_device *dev); | |
bb417020 GKH |
25 | extern int usb_match_device(struct usb_device *dev, |
26 | const struct usb_device_id *id); | |
1da177e4 | 27 | |
6d5e8254 GK |
28 | extern int usb_hub_init(void); |
29 | extern void usb_hub_cleanup(void); | |
30 | extern int usb_major_init(void); | |
31 | extern void usb_major_cleanup(void); | |
32 | extern int usb_host_init(void); | |
33 | extern void usb_host_cleanup(void); | |
34 | ||
d388dab7 AS |
35 | #ifdef CONFIG_PM |
36 | ||
a8e7c565 AS |
37 | extern int usb_suspend_both(struct usb_device *udev, pm_message_t msg); |
38 | extern int usb_resume_both(struct usb_device *udev); | |
140d8f68 AS |
39 | extern int usb_port_suspend(struct usb_device *dev); |
40 | extern int usb_port_resume(struct usb_device *dev); | |
5edbfb7c | 41 | |
e0318ebf AS |
42 | static inline void usb_pm_lock(struct usb_device *udev) |
43 | { | |
44 | mutex_lock_nested(&udev->pm_mutex, udev->level); | |
45 | } | |
46 | ||
47 | static inline void usb_pm_unlock(struct usb_device *udev) | |
48 | { | |
49 | mutex_unlock(&udev->pm_mutex); | |
50 | } | |
51 | ||
d388dab7 AS |
52 | #else |
53 | ||
54 | #define usb_suspend_both(udev, msg) 0 | |
42d8a2d2 AD |
55 | static inline int usb_resume_both(struct usb_device *udev) |
56 | { | |
57 | return 0; | |
58 | } | |
d388dab7 AS |
59 | #define usb_port_suspend(dev) 0 |
60 | #define usb_port_resume(dev) 0 | |
e0318ebf AS |
61 | static inline void usb_pm_lock(struct usb_device *udev) {} |
62 | static inline void usb_pm_unlock(struct usb_device *udev) {} | |
d388dab7 AS |
63 | |
64 | #endif | |
65 | ||
645daaab AS |
66 | #ifdef CONFIG_USB_SUSPEND |
67 | ||
94fcda1f AS |
68 | extern void usb_autosuspend_device(struct usb_device *udev); |
69 | extern int usb_autoresume_device(struct usb_device *udev); | |
645daaab AS |
70 | |
71 | #else | |
72 | ||
94fcda1f AS |
73 | #define usb_autosuspend_device(udev) do {} while (0) |
74 | static inline int usb_autoresume_device(struct usb_device *udev) | |
e0318ebf AS |
75 | { |
76 | return 0; | |
77 | } | |
645daaab AS |
78 | |
79 | #endif | |
80 | ||
bd859281 | 81 | extern struct workqueue_struct *ksuspend_usb_wq; |
36e56a34 | 82 | extern struct bus_type usb_bus_type; |
8bb54ab5 AS |
83 | extern struct usb_device_driver usb_generic_driver; |
84 | ||
85 | /* Here's how we tell apart devices and interfaces. Luckily there's | |
86 | * no such thing as a platform USB device, so we can steal the use | |
87 | * of the platform_data field. */ | |
88 | ||
095bc335 | 89 | static inline int is_usb_device(const struct device *dev) |
8bb54ab5 AS |
90 | { |
91 | return dev->platform_data == &usb_generic_driver; | |
92 | } | |
93 | ||
94 | /* Do the same for device drivers and interface drivers. */ | |
95 | ||
96 | static inline int is_usb_device_driver(struct device_driver *drv) | |
97 | { | |
98 | return container_of(drv, struct usbdrv_wrap, driver)-> | |
99 | for_devices; | |
100 | } | |
5edbfb7c | 101 | |
db690874 DB |
102 | /* Interfaces and their "power state" are owned by usbcore */ |
103 | ||
104 | static inline void mark_active(struct usb_interface *f) | |
105 | { | |
4d064c08 | 106 | f->is_active = 1; |
db690874 DB |
107 | } |
108 | ||
109 | static inline void mark_quiesced(struct usb_interface *f) | |
110 | { | |
4d064c08 | 111 | f->is_active = 0; |
db690874 DB |
112 | } |
113 | ||
095bc335 | 114 | static inline int is_active(const struct usb_interface *f) |
db690874 | 115 | { |
4d064c08 | 116 | return f->is_active; |
db690874 DB |
117 | } |
118 | ||
119 | ||
1da177e4 LT |
120 | /* for labeling diagnostics */ |
121 | extern const char *usbcore_name; | |
122 | ||
123 | /* usbfs stuff */ | |
4a2a8a2c | 124 | extern struct mutex usbfs_mutex; |
1da177e4 | 125 | extern struct usb_driver usbfs_driver; |
066202dd LFC |
126 | extern const struct file_operations usbfs_devices_fops; |
127 | extern const struct file_operations usbfs_device_file_operations; | |
1da177e4 LT |
128 | extern void usbfs_conn_disc_event(void); |
129 | ||
fbf82fd2 KS |
130 | extern int usbdev_init(void); |
131 | extern void usbdev_cleanup(void); | |
6d5e8254 | 132 | |
1da177e4 LT |
133 | struct dev_state { |
134 | struct list_head list; /* state list */ | |
135 | struct usb_device *dev; | |
136 | struct file *file; | |
137 | spinlock_t lock; /* protects the async urb lists */ | |
138 | struct list_head async_pending; | |
139 | struct list_head async_completed; | |
140 | wait_queue_head_t wait; /* wake up if a request completed */ | |
141 | unsigned int discsignr; | |
2425c08b | 142 | struct pid *disc_pid; |
d7dd8a72 | 143 | uid_t disc_uid, disc_euid; |
1da177e4 LT |
144 | void __user *disccontext; |
145 | unsigned long ifclaimed; | |
7a01955f | 146 | u32 secid; |
1da177e4 LT |
147 | }; |
148 | ||
3099e75a GKH |
149 | /* internal notify stuff */ |
150 | extern void usb_notify_add_device(struct usb_device *udev); | |
151 | extern void usb_notify_remove_device(struct usb_device *udev); | |
152 | extern void usb_notify_add_bus(struct usb_bus *ubus); | |
153 | extern void usb_notify_remove_bus(struct usb_bus *ubus); | |
154 |