3 /* Functions local to drivers/usb/core/ */
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 int 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
);
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
,
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
);
28 extern int usb_get_device_descriptor(struct usb_device
*dev
,
30 extern char *usb_cache_string(struct usb_device
*udev
, int index
);
31 extern int usb_set_configuration(struct usb_device
*dev
, int configuration
);
32 extern int usb_choose_configuration(struct usb_device
*udev
);
34 extern void usb_kick_khubd(struct usb_device
*dev
);
35 extern int usb_match_device(struct usb_device
*dev
,
36 const struct usb_device_id
*id
);
37 extern void usb_forced_unbind_intf(struct usb_interface
*intf
);
38 extern void usb_rebind_intf(struct usb_interface
*intf
);
40 extern int usb_hub_init(void);
41 extern void usb_hub_cleanup(void);
42 extern int usb_major_init(void);
43 extern void usb_major_cleanup(void);
47 extern int usb_suspend(struct device
*dev
, pm_message_t msg
);
48 extern int usb_resume(struct device
*dev
, pm_message_t msg
);
50 extern void usb_autosuspend_work(struct work_struct
*work
);
51 extern void usb_autoresume_work(struct work_struct
*work
);
52 extern int usb_port_suspend(struct usb_device
*dev
, pm_message_t msg
);
53 extern int usb_port_resume(struct usb_device
*dev
, pm_message_t msg
);
54 extern int usb_external_suspend_device(struct usb_device
*udev
,
56 extern int usb_external_resume_device(struct usb_device
*udev
,
59 static inline void usb_pm_lock(struct usb_device
*udev
)
61 mutex_lock_nested(&udev
->pm_mutex
, udev
->level
);
64 static inline void usb_pm_unlock(struct usb_device
*udev
)
66 mutex_unlock(&udev
->pm_mutex
);
71 static inline int usb_port_suspend(struct usb_device
*udev
, pm_message_t msg
)
76 static inline int usb_port_resume(struct usb_device
*udev
, pm_message_t msg
)
81 static inline void usb_pm_lock(struct usb_device
*udev
) {}
82 static inline void usb_pm_unlock(struct usb_device
*udev
) {}
86 #ifdef CONFIG_USB_SUSPEND
88 extern void usb_autosuspend_device(struct usb_device
*udev
);
89 extern void usb_try_autosuspend_device(struct usb_device
*udev
);
90 extern int usb_autoresume_device(struct usb_device
*udev
);
94 #define usb_autosuspend_device(udev) do {} while (0)
95 #define usb_try_autosuspend_device(udev) do {} while (0)
96 static inline int usb_autoresume_device(struct usb_device
*udev
)
103 extern struct workqueue_struct
*ksuspend_usb_wq
;
104 extern struct bus_type usb_bus_type
;
105 extern struct device_type usb_device_type
;
106 extern struct device_type usb_if_device_type
;
107 extern struct device_type usb_ep_device_type
;
108 extern struct usb_device_driver usb_generic_driver
;
110 static inline int is_usb_device(const struct device
*dev
)
112 return dev
->type
== &usb_device_type
;
115 static inline int is_usb_interface(const struct device
*dev
)
117 return dev
->type
== &usb_if_device_type
;
120 static inline int is_usb_endpoint(const struct device
*dev
)
122 return dev
->type
== &usb_ep_device_type
;
125 /* Do the same for device drivers and interface drivers. */
127 static inline int is_usb_device_driver(struct device_driver
*drv
)
129 return container_of(drv
, struct usbdrv_wrap
, driver
)->
133 /* Interfaces and their "power state" are owned by usbcore */
135 static inline void mark_active(struct usb_interface
*f
)
140 static inline void mark_quiesced(struct usb_interface
*f
)
145 static inline int is_active(const struct usb_interface
*f
)
151 /* for labeling diagnostics */
152 extern const char *usbcore_name
;
155 extern struct attribute_group
*usb_device_groups
[];
156 extern struct attribute_group
*usb_interface_groups
[];
159 extern struct mutex usbfs_mutex
;
160 extern struct usb_driver usbfs_driver
;
161 extern const struct file_operations usbfs_devices_fops
;
162 extern const struct file_operations usbdev_file_operations
;
163 extern void usbfs_conn_disc_event(void);
165 extern int usb_devio_init(void);
166 extern void usb_devio_cleanup(void);
168 /* internal notify stuff */
169 extern void usb_notify_add_device(struct usb_device
*udev
);
170 extern void usb_notify_remove_device(struct usb_device
*udev
);
171 extern void usb_notify_add_bus(struct usb_bus
*ubus
);
172 extern void usb_notify_remove_bus(struct usb_bus
*ubus
);