usb.h 5.0 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,
		bool reset_hardware);
20
extern void usb_disable_interface(struct usb_device *dev,
21
		struct usb_interface *intf, bool reset_hardware);
L
Linus Torvalds 已提交
22
extern void usb_release_interface_cache(struct kref *ref);
23 24 25
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 *);
26
extern void usb_detect_quirks(struct usb_device *udev);
L
Linus Torvalds 已提交
27 28 29

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

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

40 41 42 43 44 45 46
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 已提交
47 48
#ifdef	CONFIG_PM

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

A
Alan Stern 已提交
52
extern void usb_autosuspend_work(struct work_struct *work);
53
extern void usb_autoresume_work(struct work_struct *work);
A
Alan Stern 已提交
54 55
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);
56 57
extern int usb_external_suspend_device(struct usb_device *udev,
		pm_message_t msg);
A
Alan Stern 已提交
58 59
extern int usb_external_resume_device(struct usb_device *udev,
		pm_message_t msg);
60

61 62 63 64 65 66 67 68 69 70
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 已提交
71 72
#else

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

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

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

#endif

88 89
#ifdef CONFIG_USB_SUSPEND

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

#else

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

#endif

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

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

/* 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;
}
123

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

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

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

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


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

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

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

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);