blob: bf2eb0dae2ecc3aeee8e08f2c941d59513c733fe [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* Functions local to drivers/usb/core/ */
2
Greg Kroah-Hartman1b21d5e2006-08-28 11:43:25 -07003extern int usb_create_sysfs_dev_files (struct usb_device *dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004extern void usb_remove_sysfs_dev_files (struct usb_device *dev);
Greg Kroah-Hartman1b21d5e2006-08-28 11:43:25 -07005extern int usb_create_sysfs_intf_files (struct usb_interface *intf);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006extern void usb_remove_sysfs_intf_files (struct usb_interface *intf);
Greg Kroah-Hartman1b21d5e2006-08-28 11:43:25 -07007extern int usb_create_ep_files(struct device *parent, struct usb_host_endpoint *endpoint,
Greg Kroah-Hartman84412f62006-06-14 12:14:34 -07008 struct usb_device *udev);
9extern void usb_remove_ep_files(struct usb_host_endpoint *endpoint);
Linus Torvalds1da177e2005-04-16 15:20:36 -070010
11extern void usb_disable_endpoint (struct usb_device *dev, unsigned int epaddr);
12extern void usb_disable_interface (struct usb_device *dev,
13 struct usb_interface *intf);
14extern void usb_release_interface_cache(struct kref *ref);
15extern void usb_disable_device (struct usb_device *dev, int skip_ep0);
Oliver Neukum7ceec1f2007-01-26 14:26:21 +010016extern void usb_detect_quirks(struct usb_device *udev);
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
18extern int usb_get_device_descriptor(struct usb_device *dev,
19 unsigned int size);
Alan Stern4f62efe2005-10-24 16:24:14 -040020extern char *usb_cache_string(struct usb_device *udev, int index);
Linus Torvalds1da177e2005-04-16 15:20:36 -070021extern int usb_set_configuration(struct usb_device *dev, int configuration);
22
Linus Torvalds1da177e2005-04-16 15:20:36 -070023extern void usb_kick_khubd(struct usb_device *dev);
Greg Kroah-Hartmanbb417022007-01-26 14:26:21 +010024extern int usb_match_device(struct usb_device *dev,
25 const struct usb_device_id *id);
Linus Torvalds1da177e2005-04-16 15:20:36 -070026
Greg KH6d5e8252005-04-18 17:39:24 -070027extern int usb_hub_init(void);
28extern void usb_hub_cleanup(void);
29extern int usb_major_init(void);
30extern void usb_major_cleanup(void);
31extern int usb_host_init(void);
32extern void usb_host_cleanup(void);
33
Alan Sternd388dab2006-07-01 22:14:24 -040034#ifdef CONFIG_PM
35
Alan Stern718efa62007-03-09 15:41:13 -050036extern void usb_autosuspend_work(struct work_struct *work);
Alan Stern140d8f62006-07-01 22:07:21 -040037extern int usb_port_suspend(struct usb_device *dev);
38extern int usb_port_resume(struct usb_device *dev);
Alan Stern6b157c92007-03-13 16:37:30 -040039extern int usb_external_suspend_device(struct usb_device *udev,
40 pm_message_t msg);
41extern int usb_external_resume_device(struct usb_device *udev);
David Brownell5edbfb72005-09-22 22:45:26 -070042
Alan Sterne0318eb2006-09-26 14:50:20 -040043static inline void usb_pm_lock(struct usb_device *udev)
44{
45 mutex_lock_nested(&udev->pm_mutex, udev->level);
46}
47
48static inline void usb_pm_unlock(struct usb_device *udev)
49{
50 mutex_unlock(&udev->pm_mutex);
51}
52
Alan Sternd388dab2006-07-01 22:14:24 -040053#else
54
Alan Sternd388dab2006-07-01 22:14:24 -040055#define usb_port_suspend(dev) 0
56#define usb_port_resume(dev) 0
Alan Sterne0318eb2006-09-26 14:50:20 -040057static inline void usb_pm_lock(struct usb_device *udev) {}
58static inline void usb_pm_unlock(struct usb_device *udev) {}
Alan Sternd388dab2006-07-01 22:14:24 -040059
60#endif
61
Alan Stern645daaa2006-08-30 15:47:02 -040062#ifdef CONFIG_USB_SUSPEND
63
Alan Stern94fcda12006-11-20 11:38:46 -050064extern void usb_autosuspend_device(struct usb_device *udev);
Alan Stern19c26232007-02-20 15:03:32 -050065extern void usb_try_autosuspend_device(struct usb_device *udev);
Alan Stern94fcda12006-11-20 11:38:46 -050066extern int usb_autoresume_device(struct usb_device *udev);
Alan Stern645daaa2006-08-30 15:47:02 -040067
68#else
69
Alan Stern19c26232007-02-20 15:03:32 -050070#define usb_autosuspend_device(udev) do {} while (0)
71#define usb_try_autosuspend_device(udev) do {} while (0)
Alan Stern94fcda12006-11-20 11:38:46 -050072static inline int usb_autoresume_device(struct usb_device *udev)
Alan Sterne0318eb2006-09-26 14:50:20 -040073{
74 return 0;
75}
Alan Stern645daaa2006-08-30 15:47:02 -040076
77#endif
78
Alan Sternbd859282006-09-19 10:14:07 -040079extern struct workqueue_struct *ksuspend_usb_wq;
Alan Stern36e56a32006-07-01 22:08:06 -040080extern struct bus_type usb_bus_type;
Kay Sievers9f8b17e2007-03-13 15:59:31 +010081extern struct device_type usb_device_type;
82extern struct device_type usb_if_device_type;
Alan Stern8bb54ab2006-07-01 22:08:49 -040083extern struct usb_device_driver usb_generic_driver;
84
Luiz Fernando N. Capitulino095bc332006-08-26 23:48:11 -030085static inline int is_usb_device(const struct device *dev)
Alan Stern8bb54ab2006-07-01 22:08:49 -040086{
Kay Sievers9f8b17e2007-03-13 15:59:31 +010087 return dev->type == &usb_device_type;
Alan Stern8bb54ab2006-07-01 22:08:49 -040088}
89
90/* Do the same for device drivers and interface drivers. */
91
92static inline int is_usb_device_driver(struct device_driver *drv)
93{
94 return container_of(drv, struct usbdrv_wrap, driver)->
95 for_devices;
96}
David Brownell5edbfb72005-09-22 22:45:26 -070097
David Brownelldb690872005-09-13 19:56:33 -070098/* Interfaces and their "power state" are owned by usbcore */
99
100static inline void mark_active(struct usb_interface *f)
101{
Alan Stern4d064c02006-07-01 22:11:44 -0400102 f->is_active = 1;
David Brownelldb690872005-09-13 19:56:33 -0700103}
104
105static inline void mark_quiesced(struct usb_interface *f)
106{
Alan Stern4d064c02006-07-01 22:11:44 -0400107 f->is_active = 0;
David Brownelldb690872005-09-13 19:56:33 -0700108}
109
Luiz Fernando N. Capitulino095bc332006-08-26 23:48:11 -0300110static inline int is_active(const struct usb_interface *f)
David Brownelldb690872005-09-13 19:56:33 -0700111{
Alan Stern4d064c02006-07-01 22:11:44 -0400112 return f->is_active;
David Brownelldb690872005-09-13 19:56:33 -0700113}
114
115
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116/* for labeling diagnostics */
117extern const char *usbcore_name;
118
119/* usbfs stuff */
Alan Stern4a2a8a22006-07-01 22:05:01 -0400120extern struct mutex usbfs_mutex;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121extern struct usb_driver usbfs_driver;
Luiz Fernando N. Capitulino066202d2006-08-05 20:37:11 -0300122extern const struct file_operations usbfs_devices_fops;
Kay Sievers9f8b17e2007-03-13 15:59:31 +0100123extern const struct file_operations usbdev_file_operations;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124extern void usbfs_conn_disc_event(void);
125
Kay Sievers9f8b17e2007-03-13 15:59:31 +0100126extern int usb_devio_init(void);
127extern void usb_devio_cleanup(void);
Greg KH6d5e8252005-04-18 17:39:24 -0700128
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129struct dev_state {
130 struct list_head list; /* state list */
131 struct usb_device *dev;
132 struct file *file;
133 spinlock_t lock; /* protects the async urb lists */
134 struct list_head async_pending;
135 struct list_head async_completed;
136 wait_queue_head_t wait; /* wake up if a request completed */
137 unsigned int discsignr;
Eric W. Biederman2425c082006-10-02 02:17:28 -0700138 struct pid *disc_pid;
Linus Torvaldsd7dd8a72005-10-10 16:31:30 -0700139 uid_t disc_uid, disc_euid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140 void __user *disccontext;
141 unsigned long ifclaimed;
David Quigley7a019552006-06-30 01:55:48 -0700142 u32 secid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143};
144
Greg Kroah-Hartman3099e752005-06-20 21:15:16 -0700145/* internal notify stuff */
146extern void usb_notify_add_device(struct usb_device *udev);
147extern void usb_notify_remove_device(struct usb_device *udev);
148extern void usb_notify_add_bus(struct usb_bus *ubus);
149extern void usb_notify_remove_bus(struct usb_bus *ubus);
150