usb.h 5.1 KB
Newer Older
A
Alan Stern 已提交
1 2
#include <linux/pm.h>

L
Linus Torvalds 已提交
3 4
/* Functions local to drivers/usb/core/ */

5 6 7 8
extern int usb_create_sysfs_dev_files(struct usb_device *dev);
extern void usb_remove_sysfs_dev_files(struct usb_device *dev);
extern int usb_create_sysfs_intf_files(struct usb_interface *intf);
extern void usb_remove_sysfs_intf_files(struct usb_interface *intf);
A
Alan Stern 已提交
9
extern int usb_create_ep_devs(struct device *parent,
10
				struct usb_host_endpoint *endpoint,
11
				struct usb_device *udev);
A
Alan Stern 已提交
12
extern void usb_remove_ep_devs(struct usb_host_endpoint *endpoint);
L
Linus Torvalds 已提交
13

A
Alan Stern 已提交
14
extern void usb_enable_endpoint(struct usb_device *dev,
15 16 17
		struct usb_host_endpoint *ep, bool reset_toggle);
extern void usb_enable_interface(struct usb_device *dev,
		struct usb_interface *intf, bool reset_toggles);
18 19
extern void usb_disable_endpoint(struct usb_device *dev, unsigned int epaddr);
extern void usb_disable_interface(struct usb_device *dev,
L
Linus Torvalds 已提交
20 21
		struct usb_interface *intf);
extern void usb_release_interface_cache(struct kref *ref);
22 23 24
extern void usb_disable_device(struct usb_device *dev, int skip_ep0);
extern int usb_deauthorize_device(struct usb_device *);
extern int usb_authorize_device(struct usb_device *);
25
extern void usb_detect_quirks(struct usb_device *udev);
L
Linus Torvalds 已提交
26 27 28

extern int usb_get_device_descriptor(struct usb_device *dev,
		unsigned int size);
29
extern char *usb_cache_string(struct usb_device *udev, int index);
L
Linus Torvalds 已提交
30
extern int usb_set_configuration(struct usb_device *dev, int configuration);
31
extern int usb_choose_configuration(struct usb_device *udev);
L
Linus Torvalds 已提交
32 33

extern void usb_kick_khubd(struct usb_device *dev);
34 35
extern int usb_match_device(struct usb_device *dev,
			    const struct usb_device_id *id);
36 37
extern void usb_forced_unbind_intf(struct usb_interface *intf);
extern void usb_rebind_intf(struct usb_interface *intf);
L
Linus Torvalds 已提交
38

39 40 41 42 43 44 45
extern int  usb_hub_init(void);
extern void usb_hub_cleanup(void);
extern int usb_major_init(void);
extern void usb_major_cleanup(void);
extern int usb_host_init(void);
extern void usb_host_cleanup(void);

A
Alan Stern 已提交
46 47
#ifdef	CONFIG_PM

48
extern int usb_suspend(struct device *dev, pm_message_t msg);
A
Alan Stern 已提交
49
extern int usb_resume(struct device *dev, pm_message_t msg);
50

A
Alan Stern 已提交
51
extern void usb_autosuspend_work(struct work_struct *work);
52
extern void usb_autoresume_work(struct work_struct *work);
A
Alan Stern 已提交
53 54
extern int usb_port_suspend(struct usb_device *dev, pm_message_t msg);
extern int usb_port_resume(struct usb_device *dev, pm_message_t msg);
55 56
extern int usb_external_suspend_device(struct usb_device *udev,
		pm_message_t msg);
A
Alan Stern 已提交
57 58
extern int usb_external_resume_device(struct usb_device *udev,
		pm_message_t msg);
59

60 61 62 63 64 65 66 67 68 69
static inline void usb_pm_lock(struct usb_device *udev)
{
	mutex_lock_nested(&udev->pm_mutex, udev->level);
}

static inline void usb_pm_unlock(struct usb_device *udev)
{
	mutex_unlock(&udev->pm_mutex);
}

A
Alan Stern 已提交
70 71
#else

A
Alan Stern 已提交
72
static inline int usb_port_suspend(struct usb_device *udev, pm_message_t msg)
A
Alan Stern 已提交
73 74 75 76
{
	return 0;
}

A
Alan Stern 已提交
77
static inline int usb_port_resume(struct usb_device *udev, pm_message_t msg)
A
Alan Stern 已提交
78 79 80 81
{
	return 0;
}

82 83
static inline void usb_pm_lock(struct usb_device *udev) {}
static inline void usb_pm_unlock(struct usb_device *udev) {}
A
Alan Stern 已提交
84 85 86

#endif

87 88
#ifdef CONFIG_USB_SUSPEND

89
extern void usb_autosuspend_device(struct usb_device *udev);
90
extern void usb_try_autosuspend_device(struct usb_device *udev);
91
extern int usb_autoresume_device(struct usb_device *udev);
92 93 94

#else

95 96
#define usb_autosuspend_device(udev)		do {} while (0)
#define usb_try_autosuspend_device(udev)	do {} while (0)
97
static inline int usb_autoresume_device(struct usb_device *udev)
98 99 100
{
	return 0;
}
101 102 103

#endif

104
extern struct workqueue_struct *ksuspend_usb_wq;
105
extern struct bus_type usb_bus_type;
106 107
extern struct device_type usb_device_type;
extern struct device_type usb_if_device_type;
108 109
extern struct usb_device_driver usb_generic_driver;

110
static inline int is_usb_device(const struct device *dev)
111
{
112
	return dev->type == &usb_device_type;
113 114 115 116 117 118 119 120 121
}

/* Do the same for device drivers and interface drivers. */

static inline int is_usb_device_driver(struct device_driver *drv)
{
	return container_of(drv, struct usbdrv_wrap, driver)->
			for_devices;
}
122

D
David Brownell 已提交
123 124 125 126
/* Interfaces and their "power state" are owned by usbcore */

static inline void mark_active(struct usb_interface *f)
{
127
	f->is_active = 1;
D
David Brownell 已提交
128 129 130 131
}

static inline void mark_quiesced(struct usb_interface *f)
{
132
	f->is_active = 0;
D
David Brownell 已提交
133 134
}

135
static inline int is_active(const struct usb_interface *f)
D
David Brownell 已提交
136
{
137
	return f->is_active;
D
David Brownell 已提交
138 139 140
}


L
Linus Torvalds 已提交
141 142 143
/* for labeling diagnostics */
extern const char *usbcore_name;

144 145 146 147
/* sysfs stuff */
extern struct attribute_group *usb_device_groups[];
extern struct attribute_group *usb_interface_groups[];

L
Linus Torvalds 已提交
148
/* usbfs stuff */
149
extern struct mutex usbfs_mutex;
L
Linus Torvalds 已提交
150
extern struct usb_driver usbfs_driver;
151
extern const struct file_operations usbfs_devices_fops;
152
extern const struct file_operations usbdev_file_operations;
L
Linus Torvalds 已提交
153
extern void usbfs_conn_disc_event(void);
154
extern void usb_fs_classdev_common_remove(struct usb_device *udev);
L
Linus Torvalds 已提交
155

156 157
extern int usb_devio_init(void);
extern void usb_devio_cleanup(void);
158

159 160 161 162 163 164
/* internal notify stuff */
extern void usb_notify_add_device(struct usb_device *udev);
extern void usb_notify_remove_device(struct usb_device *udev);
extern void usb_notify_add_bus(struct usb_bus *ubus);
extern void usb_notify_remove_bus(struct usb_bus *ubus);