aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/usb.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/usb.h')
-rw-r--r--include/linux/usb.h60
1 files changed, 24 insertions, 36 deletions
diff --git a/include/linux/usb.h b/include/linux/usb.h
index d7ace1b80f09..8c9f053111bb 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -122,7 +122,6 @@ enum usb_interface_condition {
122 * number from the USB core by calling usb_register_dev(). 122 * number from the USB core by calling usb_register_dev().
123 * @condition: binding state of the interface: not bound, binding 123 * @condition: binding state of the interface: not bound, binding
124 * (in probe()), bound to a driver, or unbinding (in disconnect()) 124 * (in probe()), bound to a driver, or unbinding (in disconnect())
125 * @is_active: flag set when the interface is bound and not suspended.
126 * @sysfs_files_created: sysfs attributes exist 125 * @sysfs_files_created: sysfs attributes exist
127 * @ep_devs_created: endpoint child pseudo-devices exist 126 * @ep_devs_created: endpoint child pseudo-devices exist
128 * @unregistering: flag set when the interface is being unregistered 127 * @unregistering: flag set when the interface is being unregistered
@@ -135,8 +134,7 @@ enum usb_interface_condition {
135 * @dev: driver model's view of this device 134 * @dev: driver model's view of this device
136 * @usb_dev: if an interface is bound to the USB major, this will point 135 * @usb_dev: if an interface is bound to the USB major, this will point
137 * to the sysfs representation for that device. 136 * to the sysfs representation for that device.
138 * @pm_usage_cnt: PM usage counter for this interface; autosuspend is not 137 * @pm_usage_cnt: PM usage counter for this interface
139 * allowed unless the counter is 0.
140 * @reset_ws: Used for scheduling resets from atomic context. 138 * @reset_ws: Used for scheduling resets from atomic context.
141 * @reset_running: set to 1 if the interface is currently running a 139 * @reset_running: set to 1 if the interface is currently running a
142 * queued reset so that usb_cancel_queued_reset() doesn't try to 140 * queued reset so that usb_cancel_queued_reset() doesn't try to
@@ -184,7 +182,6 @@ struct usb_interface {
184 int minor; /* minor number this interface is 182 int minor; /* minor number this interface is
185 * bound to */ 183 * bound to */
186 enum usb_interface_condition condition; /* state of binding */ 184 enum usb_interface_condition condition; /* state of binding */
187 unsigned is_active:1; /* the interface is not suspended */
188 unsigned sysfs_files_created:1; /* the sysfs attributes exist */ 185 unsigned sysfs_files_created:1; /* the sysfs attributes exist */
189 unsigned ep_devs_created:1; /* endpoint "devices" exist */ 186 unsigned ep_devs_created:1; /* endpoint "devices" exist */
190 unsigned unregistering:1; /* unregistration is in progress */ 187 unsigned unregistering:1; /* unregistration is in progress */
@@ -339,6 +336,7 @@ struct usb_bus {
339 336
340 struct usb_devmap devmap; /* device address allocation map */ 337 struct usb_devmap devmap; /* device address allocation map */
341 struct usb_device *root_hub; /* Root hub */ 338 struct usb_device *root_hub; /* Root hub */
339 struct usb_bus *hs_companion; /* Companion EHCI bus, if any */
342 struct list_head bus_list; /* list of busses */ 340 struct list_head bus_list; /* list of busses */
343 341
344 int bandwidth_allocated; /* on this bus: how much of the time 342 int bandwidth_allocated; /* on this bus: how much of the time
@@ -400,7 +398,6 @@ struct usb_tt;
400 * @portnum: parent port number (origin 1) 398 * @portnum: parent port number (origin 1)
401 * @level: number of USB hub ancestors 399 * @level: number of USB hub ancestors
402 * @can_submit: URBs may be submitted 400 * @can_submit: URBs may be submitted
403 * @discon_suspended: disconnected while suspended
404 * @persist_enabled: USB_PERSIST enabled for this device 401 * @persist_enabled: USB_PERSIST enabled for this device
405 * @have_langid: whether string_langid is valid 402 * @have_langid: whether string_langid is valid
406 * @authorized: policy has said we can use it; 403 * @authorized: policy has said we can use it;
@@ -420,20 +417,15 @@ struct usb_tt;
420 * @usbfs_dentry: usbfs dentry entry for the device 417 * @usbfs_dentry: usbfs dentry entry for the device
421 * @maxchild: number of ports if hub 418 * @maxchild: number of ports if hub
422 * @children: child devices - USB devices that are attached to this hub 419 * @children: child devices - USB devices that are attached to this hub
423 * @pm_usage_cnt: usage counter for autosuspend
424 * @quirks: quirks of the whole device 420 * @quirks: quirks of the whole device
425 * @urbnum: number of URBs submitted for the whole device 421 * @urbnum: number of URBs submitted for the whole device
426 * @active_duration: total time device is not suspended 422 * @active_duration: total time device is not suspended
427 * @autosuspend: for delayed autosuspends
428 * @autoresume: for autoresumes requested while in_interrupt
429 * @pm_mutex: protects PM operations
430 * @last_busy: time of last use 423 * @last_busy: time of last use
431 * @autosuspend_delay: in jiffies 424 * @autosuspend_delay: in jiffies
432 * @connect_time: time device was first connected 425 * @connect_time: time device was first connected
433 * @do_remote_wakeup: remote wakeup should be enabled 426 * @do_remote_wakeup: remote wakeup should be enabled
434 * @reset_resume: needs reset instead of resume 427 * @reset_resume: needs reset instead of resume
435 * @autosuspend_disabled: autosuspend disabled by the user 428 * @autosuspend_disabled: autosuspend disabled by the user
436 * @skip_sys_resume: skip the next system resume
437 * @wusb_dev: if this is a Wireless USB device, link to the WUSB 429 * @wusb_dev: if this is a Wireless USB device, link to the WUSB
438 * specific data for the device. 430 * specific data for the device.
439 * @slot_id: Slot ID assigned by xHCI 431 * @slot_id: Slot ID assigned by xHCI
@@ -474,7 +466,6 @@ struct usb_device {
474 u8 level; 466 u8 level;
475 467
476 unsigned can_submit:1; 468 unsigned can_submit:1;
477 unsigned discon_suspended:1;
478 unsigned persist_enabled:1; 469 unsigned persist_enabled:1;
479 unsigned have_langid:1; 470 unsigned have_langid:1;
480 unsigned authorized:1; 471 unsigned authorized:1;
@@ -498,17 +489,12 @@ struct usb_device {
498 int maxchild; 489 int maxchild;
499 struct usb_device *children[USB_MAXCHILDREN]; 490 struct usb_device *children[USB_MAXCHILDREN];
500 491
501 int pm_usage_cnt;
502 u32 quirks; 492 u32 quirks;
503 atomic_t urbnum; 493 atomic_t urbnum;
504 494
505 unsigned long active_duration; 495 unsigned long active_duration;
506 496
507#ifdef CONFIG_PM 497#ifdef CONFIG_PM
508 struct delayed_work autosuspend;
509 struct work_struct autoresume;
510 struct mutex pm_mutex;
511
512 unsigned long last_busy; 498 unsigned long last_busy;
513 int autosuspend_delay; 499 int autosuspend_delay;
514 unsigned long connect_time; 500 unsigned long connect_time;
@@ -516,7 +502,6 @@ struct usb_device {
516 unsigned do_remote_wakeup:1; 502 unsigned do_remote_wakeup:1;
517 unsigned reset_resume:1; 503 unsigned reset_resume:1;
518 unsigned autosuspend_disabled:1; 504 unsigned autosuspend_disabled:1;
519 unsigned skip_sys_resume:1;
520#endif 505#endif
521 struct wusb_dev *wusb_dev; 506 struct wusb_dev *wusb_dev;
522 int slot_id; 507 int slot_id;
@@ -527,9 +512,9 @@ extern struct usb_device *usb_get_dev(struct usb_device *dev);
527extern void usb_put_dev(struct usb_device *dev); 512extern void usb_put_dev(struct usb_device *dev);
528 513
529/* USB device locking */ 514/* USB device locking */
530#define usb_lock_device(udev) down(&(udev)->dev.sem) 515#define usb_lock_device(udev) device_lock(&(udev)->dev)
531#define usb_unlock_device(udev) up(&(udev)->dev.sem) 516#define usb_unlock_device(udev) device_unlock(&(udev)->dev)
532#define usb_trylock_device(udev) down_trylock(&(udev)->dev.sem) 517#define usb_trylock_device(udev) device_trylock(&(udev)->dev)
533extern int usb_lock_device_for_reset(struct usb_device *udev, 518extern int usb_lock_device_for_reset(struct usb_device *udev,
534 const struct usb_interface *iface); 519 const struct usb_interface *iface);
535 520
@@ -541,21 +526,15 @@ extern struct usb_device *usb_find_device(u16 vendor_id, u16 product_id);
541 526
542/* USB autosuspend and autoresume */ 527/* USB autosuspend and autoresume */
543#ifdef CONFIG_USB_SUSPEND 528#ifdef CONFIG_USB_SUSPEND
529extern int usb_enable_autosuspend(struct usb_device *udev);
530extern int usb_disable_autosuspend(struct usb_device *udev);
531
544extern int usb_autopm_get_interface(struct usb_interface *intf); 532extern int usb_autopm_get_interface(struct usb_interface *intf);
545extern void usb_autopm_put_interface(struct usb_interface *intf); 533extern void usb_autopm_put_interface(struct usb_interface *intf);
546extern int usb_autopm_get_interface_async(struct usb_interface *intf); 534extern int usb_autopm_get_interface_async(struct usb_interface *intf);
547extern void usb_autopm_put_interface_async(struct usb_interface *intf); 535extern void usb_autopm_put_interface_async(struct usb_interface *intf);
548 536extern void usb_autopm_get_interface_no_resume(struct usb_interface *intf);
549static inline void usb_autopm_get_interface_no_resume( 537extern void usb_autopm_put_interface_no_suspend(struct usb_interface *intf);
550 struct usb_interface *intf)
551{
552 atomic_inc(&intf->pm_usage_cnt);
553}
554static inline void usb_autopm_put_interface_no_suspend(
555 struct usb_interface *intf)
556{
557 atomic_dec(&intf->pm_usage_cnt);
558}
559 538
560static inline void usb_mark_last_busy(struct usb_device *udev) 539static inline void usb_mark_last_busy(struct usb_device *udev)
561{ 540{
@@ -564,6 +543,11 @@ static inline void usb_mark_last_busy(struct usb_device *udev)
564 543
565#else 544#else
566 545
546static inline int usb_enable_autosuspend(struct usb_device *udev)
547{ return 0; }
548static inline int usb_disable_autosuspend(struct usb_device *udev)
549{ return 0; }
550
567static inline int usb_autopm_get_interface(struct usb_interface *intf) 551static inline int usb_autopm_get_interface(struct usb_interface *intf)
568{ return 0; } 552{ return 0; }
569static inline int usb_autopm_get_interface_async(struct usb_interface *intf) 553static inline int usb_autopm_get_interface_async(struct usb_interface *intf)
@@ -1582,14 +1566,18 @@ extern void usb_register_notify(struct notifier_block *nb);
1582extern void usb_unregister_notify(struct notifier_block *nb); 1566extern void usb_unregister_notify(struct notifier_block *nb);
1583 1567
1584#ifdef DEBUG 1568#ifdef DEBUG
1585#define dbg(format, arg...) printk(KERN_DEBUG "%s: " format "\n" , \ 1569#define dbg(format, arg...) \
1586 __FILE__ , ## arg) 1570 printk(KERN_DEBUG "%s: " format "\n", __FILE__, ##arg)
1587#else 1571#else
1588#define dbg(format, arg...) do {} while (0) 1572#define dbg(format, arg...) \
1573do { \
1574 if (0) \
1575 printk(KERN_DEBUG "%s: " format "\n", __FILE__, ##arg); \
1576} while (0)
1589#endif 1577#endif
1590 1578
1591#define err(format, arg...) printk(KERN_ERR KBUILD_MODNAME ": " \ 1579#define err(format, arg...) \
1592 format "\n" , ## arg) 1580 printk(KERN_ERR KBUILD_MODNAME ": " format "\n", ##arg)
1593 1581
1594/* debugfs stuff */ 1582/* debugfs stuff */
1595extern struct dentry *usb_debug_root; 1583extern struct dentry *usb_debug_root;