epca.c: reformat comments and coding style improvements
[linux-2.6/openmoko-kernel.git] / drivers / usb / core / usb.h
blobc52626c51f70bd99859c170739eb20b7695937bb
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_enable_endpoint(struct usb_device *dev,
12 struct usb_host_endpoint *ep);
13 extern void usb_disable_endpoint (struct usb_device *dev, unsigned int epaddr);
14 extern void usb_disable_interface (struct usb_device *dev,
15 struct usb_interface *intf);
16 extern void usb_release_interface_cache(struct kref *ref);
17 extern void usb_disable_device (struct usb_device *dev, int skip_ep0);
18 extern int usb_deauthorize_device (struct usb_device *);
19 extern int usb_authorize_device (struct usb_device *);
20 extern void usb_detect_quirks(struct usb_device *udev);
22 extern int usb_get_device_descriptor(struct usb_device *dev,
23 unsigned int size);
24 extern char *usb_cache_string(struct usb_device *udev, int index);
25 extern int usb_set_configuration(struct usb_device *dev, int configuration);
26 extern int usb_choose_configuration(struct usb_device *udev);
28 extern void usb_kick_khubd(struct usb_device *dev);
29 extern int usb_match_device(struct usb_device *dev,
30 const struct usb_device_id *id);
32 extern int usb_hub_init(void);
33 extern void usb_hub_cleanup(void);
34 extern int usb_major_init(void);
35 extern void usb_major_cleanup(void);
36 extern int usb_host_init(void);
37 extern void usb_host_cleanup(void);
39 #ifdef CONFIG_PM
41 extern void usb_autosuspend_work(struct work_struct *work);
42 extern int usb_port_suspend(struct usb_device *dev);
43 extern int usb_port_resume(struct usb_device *dev);
44 extern int usb_external_suspend_device(struct usb_device *udev,
45 pm_message_t msg);
46 extern int usb_external_resume_device(struct usb_device *udev);
48 static inline void usb_pm_lock(struct usb_device *udev)
50 mutex_lock_nested(&udev->pm_mutex, udev->level);
53 static inline void usb_pm_unlock(struct usb_device *udev)
55 mutex_unlock(&udev->pm_mutex);
58 #else
60 static inline int usb_port_suspend(struct usb_device *udev)
62 return 0;
65 static inline int usb_port_resume(struct usb_device *udev)
67 return 0;
70 static inline void usb_pm_lock(struct usb_device *udev) {}
71 static inline void usb_pm_unlock(struct usb_device *udev) {}
73 #endif
75 #ifdef CONFIG_USB_SUSPEND
77 extern void usb_autosuspend_device(struct usb_device *udev);
78 extern void usb_try_autosuspend_device(struct usb_device *udev);
79 extern int usb_autoresume_device(struct usb_device *udev);
81 #else
83 #define usb_autosuspend_device(udev) do {} while (0)
84 #define usb_try_autosuspend_device(udev) do {} while (0)
85 static inline int usb_autoresume_device(struct usb_device *udev)
87 return 0;
90 #endif
92 extern struct workqueue_struct *ksuspend_usb_wq;
93 extern struct bus_type usb_bus_type;
94 extern struct device_type usb_device_type;
95 extern struct device_type usb_if_device_type;
96 extern struct usb_device_driver usb_generic_driver;
98 static inline int is_usb_device(const struct device *dev)
100 return dev->type == &usb_device_type;
103 /* Do the same for device drivers and interface drivers. */
105 static inline int is_usb_device_driver(struct device_driver *drv)
107 return container_of(drv, struct usbdrv_wrap, driver)->
108 for_devices;
111 /* Interfaces and their "power state" are owned by usbcore */
113 static inline void mark_active(struct usb_interface *f)
115 f->is_active = 1;
116 f->dev.power.power_state.event = PM_EVENT_ON;
119 static inline void mark_quiesced(struct usb_interface *f)
121 f->is_active = 0;
122 f->dev.power.power_state.event = PM_EVENT_SUSPEND;
125 static inline int is_active(const struct usb_interface *f)
127 return f->is_active;
131 /* for labeling diagnostics */
132 extern const char *usbcore_name;
134 /* usbfs stuff */
135 extern struct mutex usbfs_mutex;
136 extern struct usb_driver usbfs_driver;
137 extern const struct file_operations usbfs_devices_fops;
138 extern const struct file_operations usbdev_file_operations;
139 extern void usbfs_conn_disc_event(void);
141 extern int usb_devio_init(void);
142 extern void usb_devio_cleanup(void);
144 struct dev_state {
145 struct list_head list; /* state list */
146 struct usb_device *dev;
147 struct file *file;
148 spinlock_t lock; /* protects the async urb lists */
149 struct list_head async_pending;
150 struct list_head async_completed;
151 wait_queue_head_t wait; /* wake up if a request completed */
152 unsigned int discsignr;
153 struct pid *disc_pid;
154 uid_t disc_uid, disc_euid;
155 void __user *disccontext;
156 unsigned long ifclaimed;
157 u32 secid;
160 /* internal notify stuff */
161 extern void usb_notify_add_device(struct usb_device *udev);
162 extern void usb_notify_remove_device(struct usb_device *udev);
163 extern void usb_notify_add_bus(struct usb_bus *ubus);
164 extern void usb_notify_remove_bus(struct usb_bus *ubus);