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, struct usb_host_endpoint *endpoint,
8 struct usb_device *udev);
9 extern void usb_remove_ep_files(struct usb_host_endpoint *endpoint);
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);
16 extern void usb_detect_quirks(struct usb_device *udev);
18 extern int usb_get_device_descriptor(struct usb_device *dev,
20 extern char *usb_cache_string(struct usb_device *udev, int index);
21 extern int usb_set_configuration(struct usb_device *dev, int configuration);
23 extern void usb_kick_khubd(struct usb_device *dev);
24 extern int usb_match_device(struct usb_device *dev,
25 const struct usb_device_id *id);
27 extern int usb_hub_init(void);
28 extern void usb_hub_cleanup(void);
29 extern int usb_major_init(void);
30 extern void usb_major_cleanup(void);
31 extern int usb_host_init(void);
32 extern void usb_host_cleanup(void);
36 extern void usb_autosuspend_work(struct work_struct *work);
37 extern int usb_port_suspend(struct usb_device *dev);
38 extern int usb_port_resume(struct usb_device *dev);
39 extern int usb_external_suspend_device(struct usb_device *udev,
41 extern int usb_external_resume_device(struct usb_device *udev);
43 static inline void usb_pm_lock(struct usb_device *udev)
45 mutex_lock_nested(&udev->pm_mutex, udev->level);
48 static inline void usb_pm_unlock(struct usb_device *udev)
50 mutex_unlock(&udev->pm_mutex);
55 static inline int usb_port_suspend(struct usb_device *udev)
60 static inline int usb_port_resume(struct usb_device *udev)
65 static inline void usb_pm_lock(struct usb_device *udev) {}
66 static inline void usb_pm_unlock(struct usb_device *udev) {}
70 #ifdef CONFIG_USB_SUSPEND
72 extern void usb_autosuspend_device(struct usb_device *udev);
73 extern void usb_try_autosuspend_device(struct usb_device *udev);
74 extern int usb_autoresume_device(struct usb_device *udev);
78 #define usb_autosuspend_device(udev) do {} while (0)
79 #define usb_try_autosuspend_device(udev) do {} while (0)
80 static inline int usb_autoresume_device(struct usb_device *udev)
87 extern struct workqueue_struct *ksuspend_usb_wq;
88 extern struct bus_type usb_bus_type;
89 extern struct device_type usb_device_type;
90 extern struct device_type usb_if_device_type;
91 extern struct usb_device_driver usb_generic_driver;
93 static inline int is_usb_device(const struct device *dev)
95 return dev->type == &usb_device_type;
98 /* Do the same for device drivers and interface drivers. */
100 static inline int is_usb_device_driver(struct device_driver *drv)
102 return container_of(drv, struct usbdrv_wrap, driver)->
106 /* Interfaces and their "power state" are owned by usbcore */
108 static inline void mark_active(struct usb_interface *f)
111 f->dev.power.power_state.event = PM_EVENT_ON;
114 static inline void mark_quiesced(struct usb_interface *f)
117 f->dev.power.power_state.event = PM_EVENT_SUSPEND;
120 static inline int is_active(const struct usb_interface *f)
126 /* for labeling diagnostics */
127 extern const char *usbcore_name;
130 extern struct mutex usbfs_mutex;
131 extern struct usb_driver usbfs_driver;
132 extern const struct file_operations usbfs_devices_fops;
133 extern const struct file_operations usbdev_file_operations;
134 extern void usbfs_conn_disc_event(void);
136 extern int usb_devio_init(void);
137 extern void usb_devio_cleanup(void);
140 struct list_head list; /* state list */
141 struct usb_device *dev;
143 spinlock_t lock; /* protects the async urb lists */
144 struct list_head async_pending;
145 struct list_head async_completed;
146 wait_queue_head_t wait; /* wake up if a request completed */
147 unsigned int discsignr;
148 struct pid *disc_pid;
149 uid_t disc_uid, disc_euid;
150 void __user *disccontext;
151 unsigned long ifclaimed;
155 /* internal notify stuff */
156 extern void usb_notify_add_device(struct usb_device *udev);
157 extern void usb_notify_remove_device(struct usb_device *udev);
158 extern void usb_notify_add_bus(struct usb_bus *ubus);
159 extern void usb_notify_remove_bus(struct usb_bus *ubus);