usb.h 4.9 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 9 10
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);
extern int usb_create_ep_files(struct device *parent,
				struct usb_host_endpoint *endpoint,
11 12
				struct usb_device *udev);
extern void usb_remove_ep_files(struct usb_host_endpoint *endpoint);
L
Linus Torvalds 已提交
13

A
Alan Stern 已提交
14 15
extern void usb_enable_endpoint(struct usb_device *dev,
		struct usb_host_endpoint *ep);
16 17
extern void usb_disable_endpoint(struct usb_device *dev, unsigned int epaddr);
extern void usb_disable_interface(struct usb_device *dev,
L
Linus Torvalds 已提交
18 19
		struct usb_interface *intf);
extern void usb_release_interface_cache(struct kref *ref);
20 21 22
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 *);
23
extern void usb_detect_quirks(struct usb_device *udev);
L
Linus Torvalds 已提交
24 25 26

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

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

37 38 39 40 41 42 43
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 已提交
44 45
#ifdef	CONFIG_PM

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

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

58 59 60 61 62 63 64 65 66 67
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 已提交
68 69
#else

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

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

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

#endif

85 86
#ifdef CONFIG_USB_SUSPEND

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

#else

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

#endif

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

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

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

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

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

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

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


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

142 143 144 145
/* sysfs stuff */
extern struct attribute_group *usb_device_groups[];
extern struct attribute_group *usb_interface_groups[];

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

154 155
extern int usb_devio_init(void);
extern void usb_devio_cleanup(void);
156

157 158 159 160 161 162
/* 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);