blob: 1d25ccac783276f47fe7b9b26dd3025f356d1b70 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* Functions local to drivers/usb/core/ */
2
3extern void usb_create_sysfs_dev_files (struct usb_device *dev);
4extern void usb_remove_sysfs_dev_files (struct usb_device *dev);
5extern void usb_create_sysfs_intf_files (struct usb_interface *intf);
6extern void usb_remove_sysfs_intf_files (struct usb_interface *intf);
Greg Kroah-Hartman36679ea2006-06-14 12:14:34 -07007extern void 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);
16
17extern int usb_get_device_descriptor(struct usb_device *dev,
18 unsigned int size);
Alan Stern4f62efe2005-10-24 16:24:14 -040019extern char *usb_cache_string(struct usb_device *udev, int index);
Linus Torvalds1da177e2005-04-16 15:20:36 -070020extern int usb_set_configuration(struct usb_device *dev, int configuration);
21
Linus Torvalds1da177e2005-04-16 15:20:36 -070022extern void usb_kick_khubd(struct usb_device *dev);
David Brownell979d5192005-09-22 22:32:24 -070023extern void usb_suspend_root_hub(struct usb_device *hdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -070024extern void usb_resume_root_hub(struct usb_device *dev);
25
Greg KH6d5e8252005-04-18 17:39:24 -070026extern int usb_hub_init(void);
27extern void usb_hub_cleanup(void);
28extern int usb_major_init(void);
29extern void usb_major_cleanup(void);
30extern int usb_host_init(void);
31extern void usb_host_cleanup(void);
32
Alan Stern140d8f62006-07-01 22:07:21 -040033extern int usb_port_suspend(struct usb_device *dev);
34extern int usb_port_resume(struct usb_device *dev);
David Brownell5edbfb72005-09-22 22:45:26 -070035
Alan Stern36e56a32006-07-01 22:08:06 -040036extern struct bus_type usb_bus_type;
Alan Stern8bb54ab2006-07-01 22:08:49 -040037extern struct usb_device_driver usb_generic_driver;
38
39/* Here's how we tell apart devices and interfaces. Luckily there's
40 * no such thing as a platform USB device, so we can steal the use
41 * of the platform_data field. */
42
43static inline int is_usb_device(struct device *dev)
44{
45 return dev->platform_data == &usb_generic_driver;
46}
47
48/* Do the same for device drivers and interface drivers. */
49
50static inline int is_usb_device_driver(struct device_driver *drv)
51{
52 return container_of(drv, struct usbdrv_wrap, driver)->
53 for_devices;
54}
David Brownell5edbfb72005-09-22 22:45:26 -070055
David Brownelldb690872005-09-13 19:56:33 -070056/* Interfaces and their "power state" are owned by usbcore */
57
58static inline void mark_active(struct usb_interface *f)
59{
60 f->dev.power.power_state.event = PM_EVENT_ON;
61}
62
63static inline void mark_quiesced(struct usb_interface *f)
64{
65 f->dev.power.power_state.event = PM_EVENT_FREEZE;
66}
67
68static inline int is_active(struct usb_interface *f)
69{
70 return f->dev.power.power_state.event == PM_EVENT_ON;
71}
72
73
Linus Torvalds1da177e2005-04-16 15:20:36 -070074/* for labeling diagnostics */
75extern const char *usbcore_name;
76
77/* usbfs stuff */
Alan Stern4a2a8a22006-07-01 22:05:01 -040078extern struct mutex usbfs_mutex;
Linus Torvalds1da177e2005-04-16 15:20:36 -070079extern struct usb_driver usbfs_driver;
80extern struct file_operations usbfs_devices_fops;
81extern struct file_operations usbfs_device_file_operations;
82extern void usbfs_conn_disc_event(void);
83
Kay Sieversfbf82fd2005-07-31 01:05:53 +020084extern int usbdev_init(void);
85extern void usbdev_cleanup(void);
Greg KH6d5e8252005-04-18 17:39:24 -070086
Linus Torvalds1da177e2005-04-16 15:20:36 -070087struct dev_state {
88 struct list_head list; /* state list */
89 struct usb_device *dev;
90 struct file *file;
91 spinlock_t lock; /* protects the async urb lists */
92 struct list_head async_pending;
93 struct list_head async_completed;
94 wait_queue_head_t wait; /* wake up if a request completed */
95 unsigned int discsignr;
Linus Torvaldsd7dd8a72005-10-10 16:31:30 -070096 pid_t disc_pid;
97 uid_t disc_uid, disc_euid;
Linus Torvalds1da177e2005-04-16 15:20:36 -070098 void __user *disccontext;
99 unsigned long ifclaimed;
David Quigley7a019552006-06-30 01:55:48 -0700100 u32 secid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101};
102
Greg Kroah-Hartman3099e752005-06-20 21:15:16 -0700103/* internal notify stuff */
104extern void usb_notify_add_device(struct usb_device *udev);
105extern void usb_notify_remove_device(struct usb_device *udev);
106extern void usb_notify_add_bus(struct usb_bus *ubus);
107extern void usb_notify_remove_bus(struct usb_bus *ubus);
108