1 /* Functions local to drivers/usb/core/ */
3 extern int usb_create_sysfs_dev_files(struct usb_device
*dev
);
4 extern void usb_remove_sysfs_dev_files(struct usb_device
*dev
);
5 extern int usb_create_sysfs_intf_files(struct usb_interface
*intf
);
6 extern void usb_remove_sysfs_intf_files(struct usb_interface
*intf
);
7 extern int usb_create_ep_files(struct device
*parent
,
8 struct usb_host_endpoint
*endpoint
,
9 struct usb_device
*udev
);
10 extern void usb_remove_ep_files(struct usb_host_endpoint
*endpoint
);
12 extern void usb_enable_endpoint(struct usb_device
*dev
,
13 struct usb_host_endpoint
*ep
);
14 extern void usb_disable_endpoint(struct usb_device
*dev
, unsigned int epaddr
);
15 extern void usb_disable_interface(struct usb_device
*dev
,
16 struct usb_interface
*intf
);
17 extern void usb_release_interface_cache(struct kref
*ref
);
18 extern void usb_disable_device(struct usb_device
*dev
, int skip_ep0
);
19 extern int usb_deauthorize_device(struct usb_device
*);
20 extern int usb_authorize_device(struct usb_device
*);
21 extern void usb_detect_quirks(struct usb_device
*udev
);
23 extern int usb_get_device_descriptor(struct usb_device
*dev
,
25 extern char *usb_cache_string(struct usb_device
*udev
, int index
);
26 extern int usb_set_configuration(struct usb_device
*dev
, int configuration
);
27 extern int usb_choose_configuration(struct usb_device
*udev
);
29 extern void usb_kick_khubd(struct usb_device
*dev
);
30 extern int usb_match_device(struct usb_device
*dev
,
31 const struct usb_device_id
*id
);
33 extern int usb_hub_init(void);
34 extern void usb_hub_cleanup(void);
35 extern int usb_major_init(void);
36 extern void usb_major_cleanup(void);
37 extern int usb_host_init(void);
38 extern void usb_host_cleanup(void);
42 extern void usb_autosuspend_work(struct work_struct
*work
);
43 extern int usb_port_suspend(struct usb_device
*dev
);
44 extern int usb_port_resume(struct usb_device
*dev
);
45 extern int usb_external_suspend_device(struct usb_device
*udev
,
47 extern int usb_external_resume_device(struct usb_device
*udev
);
49 static inline void usb_pm_lock(struct usb_device
*udev
)
51 mutex_lock_nested(&udev
->pm_mutex
, udev
->level
);
54 static inline void usb_pm_unlock(struct usb_device
*udev
)
56 mutex_unlock(&udev
->pm_mutex
);
61 static inline int usb_port_suspend(struct usb_device
*udev
)
66 static inline int usb_port_resume(struct usb_device
*udev
)
71 static inline void usb_pm_lock(struct usb_device
*udev
) {}
72 static inline void usb_pm_unlock(struct usb_device
*udev
) {}
76 #ifdef CONFIG_USB_SUSPEND
78 extern void usb_autosuspend_device(struct usb_device
*udev
);
79 extern void usb_try_autosuspend_device(struct usb_device
*udev
);
80 extern int usb_autoresume_device(struct usb_device
*udev
);
84 #define usb_autosuspend_device(udev) do {} while (0)
85 #define usb_try_autosuspend_device(udev) do {} while (0)
86 static inline int usb_autoresume_device(struct usb_device
*udev
)
93 extern struct workqueue_struct
*ksuspend_usb_wq
;
94 extern struct bus_type usb_bus_type
;
95 extern struct device_type usb_device_type
;
96 extern struct device_type usb_if_device_type
;
97 extern struct usb_device_driver usb_generic_driver
;
99 static inline int is_usb_device(const struct device
*dev
)
101 return dev
->type
== &usb_device_type
;
104 /* Do the same for device drivers and interface drivers. */
106 static inline int is_usb_device_driver(struct device_driver
*drv
)
108 return container_of(drv
, struct usbdrv_wrap
, driver
)->
112 /* Interfaces and their "power state" are owned by usbcore */
114 static inline void mark_active(struct usb_interface
*f
)
117 f
->dev
.power
.power_state
.event
= PM_EVENT_ON
;
120 static inline void mark_quiesced(struct usb_interface
*f
)
123 f
->dev
.power
.power_state
.event
= PM_EVENT_SUSPEND
;
126 static inline int is_active(const struct usb_interface
*f
)
132 /* for labeling diagnostics */
133 extern const char *usbcore_name
;
136 extern struct mutex usbfs_mutex
;
137 extern struct usb_driver usbfs_driver
;
138 extern const struct file_operations usbfs_devices_fops
;
139 extern const struct file_operations usbdev_file_operations
;
140 extern void usbfs_conn_disc_event(void);
142 extern int usb_devio_init(void);
143 extern void usb_devio_cleanup(void);
146 struct list_head list
; /* state list */
147 struct usb_device
*dev
;
149 spinlock_t lock
; /* protects the async urb lists */
150 struct list_head async_pending
;
151 struct list_head async_completed
;
152 wait_queue_head_t wait
; /* wake up if a request completed */
153 unsigned int discsignr
;
154 struct pid
*disc_pid
;
155 uid_t disc_uid
, disc_euid
;
156 void __user
*disccontext
;
157 unsigned long ifclaimed
;
161 /* internal notify stuff */
162 extern void usb_notify_add_device(struct usb_device
*udev
);
163 extern void usb_notify_remove_device(struct usb_device
*udev
);
164 extern void usb_notify_add_bus(struct usb_bus
*ubus
);
165 extern void usb_notify_remove_bus(struct usb_bus
*ubus
);