mm owner: fix race between swapoff and exit
[linux-2.6/next.git] / drivers / usb / core / usb.h
blob9a1a45ac3add0ba9ab582d713a6341ee6df311c7
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,
24 unsigned int size);
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);
32 extern void usb_forced_unbind_intf(struct usb_interface *intf);
33 extern void usb_rebind_intf(struct usb_interface *intf);
35 extern int usb_hub_init(void);
36 extern void usb_hub_cleanup(void);
37 extern int usb_major_init(void);
38 extern void usb_major_cleanup(void);
39 extern int usb_host_init(void);
40 extern void usb_host_cleanup(void);
42 #ifdef CONFIG_PM
44 extern int usb_suspend(struct device *dev, pm_message_t msg);
45 extern int usb_resume(struct device *dev);
47 extern void usb_autosuspend_work(struct work_struct *work);
48 extern int usb_port_suspend(struct usb_device *dev);
49 extern int usb_port_resume(struct usb_device *dev);
50 extern int usb_external_suspend_device(struct usb_device *udev,
51 pm_message_t msg);
52 extern int usb_external_resume_device(struct usb_device *udev);
54 static inline void usb_pm_lock(struct usb_device *udev)
56 mutex_lock_nested(&udev->pm_mutex, udev->level);
59 static inline void usb_pm_unlock(struct usb_device *udev)
61 mutex_unlock(&udev->pm_mutex);
64 #else
66 static inline int usb_port_suspend(struct usb_device *udev)
68 return 0;
71 static inline int usb_port_resume(struct usb_device *udev)
73 return 0;
76 static inline void usb_pm_lock(struct usb_device *udev) {}
77 static inline void usb_pm_unlock(struct usb_device *udev) {}
79 #endif
81 #ifdef CONFIG_USB_SUSPEND
83 extern void usb_autosuspend_device(struct usb_device *udev);
84 extern void usb_try_autosuspend_device(struct usb_device *udev);
85 extern int usb_autoresume_device(struct usb_device *udev);
87 #else
89 #define usb_autosuspend_device(udev) do {} while (0)
90 #define usb_try_autosuspend_device(udev) do {} while (0)
91 static inline int usb_autoresume_device(struct usb_device *udev)
93 return 0;
96 #endif
98 extern struct workqueue_struct *ksuspend_usb_wq;
99 extern struct bus_type usb_bus_type;
100 extern struct device_type usb_device_type;
101 extern struct device_type usb_if_device_type;
102 extern struct usb_device_driver usb_generic_driver;
104 static inline int is_usb_device(const struct device *dev)
106 return dev->type == &usb_device_type;
109 /* Do the same for device drivers and interface drivers. */
111 static inline int is_usb_device_driver(struct device_driver *drv)
113 return container_of(drv, struct usbdrv_wrap, driver)->
114 for_devices;
117 /* Interfaces and their "power state" are owned by usbcore */
119 static inline void mark_active(struct usb_interface *f)
121 f->is_active = 1;
124 static inline void mark_quiesced(struct usb_interface *f)
126 f->is_active = 0;
129 static inline int is_active(const struct usb_interface *f)
131 return f->is_active;
135 /* for labeling diagnostics */
136 extern const char *usbcore_name;
138 /* sysfs stuff */
139 extern struct attribute_group *usb_device_groups[];
140 extern struct attribute_group *usb_interface_groups[];
142 /* usbfs stuff */
143 extern struct mutex usbfs_mutex;
144 extern struct usb_driver usbfs_driver;
145 extern const struct file_operations usbfs_devices_fops;
146 extern const struct file_operations usbdev_file_operations;
147 extern void usbfs_conn_disc_event(void);
148 extern void usb_fs_classdev_common_remove(struct usb_device *udev);
150 extern int usb_devio_init(void);
151 extern void usb_devio_cleanup(void);
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);