diff options
Diffstat (limited to 'include/linux/usb.h')
-rw-r--r-- | include/linux/usb.h | 114 |
1 files changed, 60 insertions, 54 deletions
diff --git a/include/linux/usb.h b/include/linux/usb.h index a34fa89f1474..739f1fd1cc15 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 */ |
@@ -192,6 +189,7 @@ struct usb_interface { | |||
192 | unsigned needs_altsetting0:1; /* switch to altsetting 0 is pending */ | 189 | unsigned needs_altsetting0:1; /* switch to altsetting 0 is pending */ |
193 | unsigned needs_binding:1; /* needs delayed unbind/rebind */ | 190 | unsigned needs_binding:1; /* needs delayed unbind/rebind */ |
194 | unsigned reset_running:1; | 191 | unsigned reset_running:1; |
192 | unsigned resetting_device:1; /* true: bandwidth alloc after reset */ | ||
195 | 193 | ||
196 | struct device dev; /* interface specific device info */ | 194 | struct device dev; /* interface specific device info */ |
197 | struct device *usb_dev; | 195 | struct device *usb_dev; |
@@ -331,12 +329,14 @@ struct usb_bus { | |||
331 | u8 otg_port; /* 0, or number of OTG/HNP port */ | 329 | u8 otg_port; /* 0, or number of OTG/HNP port */ |
332 | unsigned is_b_host:1; /* true during some HNP roleswitches */ | 330 | unsigned is_b_host:1; /* true during some HNP roleswitches */ |
333 | unsigned b_hnp_enable:1; /* OTG: did A-Host enable HNP? */ | 331 | unsigned b_hnp_enable:1; /* OTG: did A-Host enable HNP? */ |
332 | unsigned sg_tablesize; /* 0 or largest number of sg list entries */ | ||
334 | 333 | ||
335 | int devnum_next; /* Next open device number in | 334 | int devnum_next; /* Next open device number in |
336 | * round-robin allocation */ | 335 | * round-robin allocation */ |
337 | 336 | ||
338 | struct usb_devmap devmap; /* device address allocation map */ | 337 | struct usb_devmap devmap; /* device address allocation map */ |
339 | 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 */ | ||
340 | struct list_head bus_list; /* list of busses */ | 340 | struct list_head bus_list; /* list of busses */ |
341 | 341 | ||
342 | int bandwidth_allocated; /* on this bus: how much of the time | 342 | int bandwidth_allocated; /* on this bus: how much of the time |
@@ -398,7 +398,6 @@ struct usb_tt; | |||
398 | * @portnum: parent port number (origin 1) | 398 | * @portnum: parent port number (origin 1) |
399 | * @level: number of USB hub ancestors | 399 | * @level: number of USB hub ancestors |
400 | * @can_submit: URBs may be submitted | 400 | * @can_submit: URBs may be submitted |
401 | * @discon_suspended: disconnected while suspended | ||
402 | * @persist_enabled: USB_PERSIST enabled for this device | 401 | * @persist_enabled: USB_PERSIST enabled for this device |
403 | * @have_langid: whether string_langid is valid | 402 | * @have_langid: whether string_langid is valid |
404 | * @authorized: policy has said we can use it; | 403 | * @authorized: policy has said we can use it; |
@@ -418,22 +417,15 @@ struct usb_tt; | |||
418 | * @usbfs_dentry: usbfs dentry entry for the device | 417 | * @usbfs_dentry: usbfs dentry entry for the device |
419 | * @maxchild: number of ports if hub | 418 | * @maxchild: number of ports if hub |
420 | * @children: child devices - USB devices that are attached to this hub | 419 | * @children: child devices - USB devices that are attached to this hub |
421 | * @pm_usage_cnt: usage counter for autosuspend | ||
422 | * @quirks: quirks of the whole device | 420 | * @quirks: quirks of the whole device |
423 | * @urbnum: number of URBs submitted for the whole device | 421 | * @urbnum: number of URBs submitted for the whole device |
424 | * @active_duration: total time device is not suspended | 422 | * @active_duration: total time device is not suspended |
425 | * @autosuspend: for delayed autosuspends | ||
426 | * @autoresume: for autoresumes requested while in_interrupt | ||
427 | * @pm_mutex: protects PM operations | ||
428 | * @last_busy: time of last use | 423 | * @last_busy: time of last use |
429 | * @autosuspend_delay: in jiffies | 424 | * @autosuspend_delay: in jiffies |
430 | * @connect_time: time device was first connected | 425 | * @connect_time: time device was first connected |
431 | * @auto_pm: autosuspend/resume in progress | ||
432 | * @do_remote_wakeup: remote wakeup should be enabled | 426 | * @do_remote_wakeup: remote wakeup should be enabled |
433 | * @reset_resume: needs reset instead of resume | 427 | * @reset_resume: needs reset instead of resume |
434 | * @autosuspend_disabled: autosuspend disabled by the user | 428 | * @autosuspend_disabled: autosuspend disabled by the user |
435 | * @autoresume_disabled: autoresume 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,27 +489,19 @@ 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; |
515 | 501 | ||
516 | unsigned auto_pm:1; | ||
517 | unsigned do_remote_wakeup:1; | 502 | unsigned do_remote_wakeup:1; |
518 | unsigned reset_resume:1; | 503 | unsigned reset_resume:1; |
519 | unsigned autosuspend_disabled:1; | 504 | unsigned autosuspend_disabled:1; |
520 | unsigned autoresume_disabled:1; | ||
521 | unsigned skip_sys_resume:1; | ||
522 | #endif | 505 | #endif |
523 | struct wusb_dev *wusb_dev; | 506 | struct wusb_dev *wusb_dev; |
524 | int slot_id; | 507 | int slot_id; |
@@ -529,9 +512,9 @@ extern struct usb_device *usb_get_dev(struct usb_device *dev); | |||
529 | extern void usb_put_dev(struct usb_device *dev); | 512 | extern void usb_put_dev(struct usb_device *dev); |
530 | 513 | ||
531 | /* USB device locking */ | 514 | /* USB device locking */ |
532 | #define usb_lock_device(udev) down(&(udev)->dev.sem) | 515 | #define usb_lock_device(udev) device_lock(&(udev)->dev) |
533 | #define usb_unlock_device(udev) up(&(udev)->dev.sem) | 516 | #define usb_unlock_device(udev) device_unlock(&(udev)->dev) |
534 | #define usb_trylock_device(udev) down_trylock(&(udev)->dev.sem) | 517 | #define usb_trylock_device(udev) device_trylock(&(udev)->dev) |
535 | extern int usb_lock_device_for_reset(struct usb_device *udev, | 518 | extern int usb_lock_device_for_reset(struct usb_device *udev, |
536 | const struct usb_interface *iface); | 519 | const struct usb_interface *iface); |
537 | 520 | ||
@@ -543,23 +526,15 @@ extern struct usb_device *usb_find_device(u16 vendor_id, u16 product_id); | |||
543 | 526 | ||
544 | /* USB autosuspend and autoresume */ | 527 | /* USB autosuspend and autoresume */ |
545 | #ifdef CONFIG_USB_SUSPEND | 528 | #ifdef CONFIG_USB_SUSPEND |
546 | extern int usb_autopm_set_interface(struct usb_interface *intf); | 529 | extern int usb_enable_autosuspend(struct usb_device *udev); |
530 | extern int usb_disable_autosuspend(struct usb_device *udev); | ||
531 | |||
547 | extern int usb_autopm_get_interface(struct usb_interface *intf); | 532 | extern int usb_autopm_get_interface(struct usb_interface *intf); |
548 | extern void usb_autopm_put_interface(struct usb_interface *intf); | 533 | extern void usb_autopm_put_interface(struct usb_interface *intf); |
549 | extern int usb_autopm_get_interface_async(struct usb_interface *intf); | 534 | extern int usb_autopm_get_interface_async(struct usb_interface *intf); |
550 | extern void usb_autopm_put_interface_async(struct usb_interface *intf); | 535 | extern void usb_autopm_put_interface_async(struct usb_interface *intf); |
551 | 536 | extern void usb_autopm_get_interface_no_resume(struct usb_interface *intf); | |
552 | static inline void usb_autopm_enable(struct usb_interface *intf) | 537 | extern void usb_autopm_put_interface_no_suspend(struct usb_interface *intf); |
553 | { | ||
554 | atomic_set(&intf->pm_usage_cnt, 0); | ||
555 | usb_autopm_set_interface(intf); | ||
556 | } | ||
557 | |||
558 | static inline void usb_autopm_disable(struct usb_interface *intf) | ||
559 | { | ||
560 | atomic_set(&intf->pm_usage_cnt, 1); | ||
561 | usb_autopm_set_interface(intf); | ||
562 | } | ||
563 | 538 | ||
564 | static inline void usb_mark_last_busy(struct usb_device *udev) | 539 | static inline void usb_mark_last_busy(struct usb_device *udev) |
565 | { | 540 | { |
@@ -568,12 +543,13 @@ static inline void usb_mark_last_busy(struct usb_device *udev) | |||
568 | 543 | ||
569 | #else | 544 | #else |
570 | 545 | ||
571 | static inline int usb_autopm_set_interface(struct usb_interface *intf) | 546 | static inline int usb_enable_autosuspend(struct usb_device *udev) |
547 | { return 0; } | ||
548 | static inline int usb_disable_autosuspend(struct usb_device *udev) | ||
572 | { return 0; } | 549 | { return 0; } |
573 | 550 | ||
574 | static inline int usb_autopm_get_interface(struct usb_interface *intf) | 551 | static inline int usb_autopm_get_interface(struct usb_interface *intf) |
575 | { return 0; } | 552 | { return 0; } |
576 | |||
577 | static inline int usb_autopm_get_interface_async(struct usb_interface *intf) | 553 | static inline int usb_autopm_get_interface_async(struct usb_interface *intf) |
578 | { return 0; } | 554 | { return 0; } |
579 | 555 | ||
@@ -581,9 +557,11 @@ static inline void usb_autopm_put_interface(struct usb_interface *intf) | |||
581 | { } | 557 | { } |
582 | static inline void usb_autopm_put_interface_async(struct usb_interface *intf) | 558 | static inline void usb_autopm_put_interface_async(struct usb_interface *intf) |
583 | { } | 559 | { } |
584 | static inline void usb_autopm_enable(struct usb_interface *intf) | 560 | static inline void usb_autopm_get_interface_no_resume( |
561 | struct usb_interface *intf) | ||
585 | { } | 562 | { } |
586 | static inline void usb_autopm_disable(struct usb_interface *intf) | 563 | static inline void usb_autopm_put_interface_no_suspend( |
564 | struct usb_interface *intf) | ||
587 | { } | 565 | { } |
588 | static inline void usb_mark_last_busy(struct usb_device *udev) | 566 | static inline void usb_mark_last_busy(struct usb_device *udev) |
589 | { } | 567 | { } |
@@ -626,6 +604,10 @@ extern struct usb_interface *usb_ifnum_to_if(const struct usb_device *dev, | |||
626 | unsigned ifnum); | 604 | unsigned ifnum); |
627 | extern struct usb_host_interface *usb_altnum_to_altsetting( | 605 | extern struct usb_host_interface *usb_altnum_to_altsetting( |
628 | const struct usb_interface *intf, unsigned int altnum); | 606 | const struct usb_interface *intf, unsigned int altnum); |
607 | extern struct usb_host_interface *usb_find_alt_setting( | ||
608 | struct usb_host_config *config, | ||
609 | unsigned int iface_num, | ||
610 | unsigned int alt_num); | ||
629 | 611 | ||
630 | 612 | ||
631 | /** | 613 | /** |
@@ -1073,7 +1055,8 @@ typedef void (*usb_complete_t)(struct urb *); | |||
1073 | * @number_of_packets: Lists the number of ISO transfer buffers. | 1055 | * @number_of_packets: Lists the number of ISO transfer buffers. |
1074 | * @interval: Specifies the polling interval for interrupt or isochronous | 1056 | * @interval: Specifies the polling interval for interrupt or isochronous |
1075 | * transfers. The units are frames (milliseconds) for full and low | 1057 | * transfers. The units are frames (milliseconds) for full and low |
1076 | * speed devices, and microframes (1/8 millisecond) for highspeed ones. | 1058 | * speed devices, and microframes (1/8 millisecond) for highspeed |
1059 | * and SuperSpeed devices. | ||
1077 | * @error_count: Returns the number of ISO transfers that reported errors. | 1060 | * @error_count: Returns the number of ISO transfers that reported errors. |
1078 | * @context: For use in completion functions. This normally points to | 1061 | * @context: For use in completion functions. This normally points to |
1079 | * request-specific driver context. | 1062 | * request-specific driver context. |
@@ -1102,7 +1085,7 @@ typedef void (*usb_complete_t)(struct urb *); | |||
1102 | * Alternatively, drivers may pass the URB_NO_xxx_DMA_MAP transfer flags, | 1085 | * Alternatively, drivers may pass the URB_NO_xxx_DMA_MAP transfer flags, |
1103 | * which tell the host controller driver that no such mapping is needed since | 1086 | * which tell the host controller driver that no such mapping is needed since |
1104 | * the device driver is DMA-aware. For example, a device driver might | 1087 | * the device driver is DMA-aware. For example, a device driver might |
1105 | * allocate a DMA buffer with usb_buffer_alloc() or call usb_buffer_map(). | 1088 | * allocate a DMA buffer with usb_alloc_coherent() or call usb_buffer_map(). |
1106 | * When these transfer flags are provided, host controller drivers will | 1089 | * When these transfer flags are provided, host controller drivers will |
1107 | * attempt to use the dma addresses found in the transfer_dma and/or | 1090 | * attempt to use the dma addresses found in the transfer_dma and/or |
1108 | * setup_dma fields rather than determining a dma address themselves. | 1091 | * setup_dma fields rather than determining a dma address themselves. |
@@ -1304,9 +1287,16 @@ static inline void usb_fill_bulk_urb(struct urb *urb, | |||
1304 | * | 1287 | * |
1305 | * Initializes a interrupt urb with the proper information needed to submit | 1288 | * Initializes a interrupt urb with the proper information needed to submit |
1306 | * it to a device. | 1289 | * it to a device. |
1307 | * Note that high speed interrupt endpoints use a logarithmic encoding of | 1290 | * |
1308 | * the endpoint interval, and express polling intervals in microframes | 1291 | * Note that High Speed and SuperSpeed interrupt endpoints use a logarithmic |
1309 | * (eight per millisecond) rather than in frames (one per millisecond). | 1292 | * encoding of the endpoint interval, and express polling intervals in |
1293 | * microframes (eight per millisecond) rather than in frames (one per | ||
1294 | * millisecond). | ||
1295 | * | ||
1296 | * Wireless USB also uses the logarithmic encoding, but specifies it in units of | ||
1297 | * 128us instead of 125us. For Wireless USB devices, the interval is passed | ||
1298 | * through to the host controller, rather than being translated into microframe | ||
1299 | * units. | ||
1310 | */ | 1300 | */ |
1311 | static inline void usb_fill_int_urb(struct urb *urb, | 1301 | static inline void usb_fill_int_urb(struct urb *urb, |
1312 | struct usb_device *dev, | 1302 | struct usb_device *dev, |
@@ -1323,7 +1313,7 @@ static inline void usb_fill_int_urb(struct urb *urb, | |||
1323 | urb->transfer_buffer_length = buffer_length; | 1313 | urb->transfer_buffer_length = buffer_length; |
1324 | urb->complete = complete_fn; | 1314 | urb->complete = complete_fn; |
1325 | urb->context = context; | 1315 | urb->context = context; |
1326 | if (dev->speed == USB_SPEED_HIGH) | 1316 | if (dev->speed == USB_SPEED_HIGH || dev->speed == USB_SPEED_SUPER) |
1327 | urb->interval = 1 << (interval - 1); | 1317 | urb->interval = 1 << (interval - 1); |
1328 | else | 1318 | else |
1329 | urb->interval = interval; | 1319 | urb->interval = interval; |
@@ -1376,11 +1366,23 @@ static inline int usb_urb_dir_out(struct urb *urb) | |||
1376 | return (urb->transfer_flags & URB_DIR_MASK) == URB_DIR_OUT; | 1366 | return (urb->transfer_flags & URB_DIR_MASK) == URB_DIR_OUT; |
1377 | } | 1367 | } |
1378 | 1368 | ||
1379 | void *usb_buffer_alloc(struct usb_device *dev, size_t size, | 1369 | void *usb_alloc_coherent(struct usb_device *dev, size_t size, |
1380 | gfp_t mem_flags, dma_addr_t *dma); | 1370 | gfp_t mem_flags, dma_addr_t *dma); |
1381 | void usb_buffer_free(struct usb_device *dev, size_t size, | 1371 | void usb_free_coherent(struct usb_device *dev, size_t size, |
1382 | void *addr, dma_addr_t dma); | 1372 | void *addr, dma_addr_t dma); |
1383 | 1373 | ||
1374 | /* Compatible macros while we switch over */ | ||
1375 | static inline void *usb_buffer_alloc(struct usb_device *dev, size_t size, | ||
1376 | gfp_t mem_flags, dma_addr_t *dma) | ||
1377 | { | ||
1378 | return usb_alloc_coherent(dev, size, mem_flags, dma); | ||
1379 | } | ||
1380 | static inline void usb_buffer_free(struct usb_device *dev, size_t size, | ||
1381 | void *addr, dma_addr_t dma) | ||
1382 | { | ||
1383 | return usb_free_coherent(dev, size, addr, dma); | ||
1384 | } | ||
1385 | |||
1384 | #if 0 | 1386 | #if 0 |
1385 | struct urb *usb_buffer_map(struct urb *urb); | 1387 | struct urb *usb_buffer_map(struct urb *urb); |
1386 | void usb_buffer_dmasync(struct urb *urb); | 1388 | void usb_buffer_dmasync(struct urb *urb); |
@@ -1584,14 +1586,18 @@ extern void usb_register_notify(struct notifier_block *nb); | |||
1584 | extern void usb_unregister_notify(struct notifier_block *nb); | 1586 | extern void usb_unregister_notify(struct notifier_block *nb); |
1585 | 1587 | ||
1586 | #ifdef DEBUG | 1588 | #ifdef DEBUG |
1587 | #define dbg(format, arg...) printk(KERN_DEBUG "%s: " format "\n" , \ | 1589 | #define dbg(format, arg...) \ |
1588 | __FILE__ , ## arg) | 1590 | printk(KERN_DEBUG "%s: " format "\n", __FILE__, ##arg) |
1589 | #else | 1591 | #else |
1590 | #define dbg(format, arg...) do {} while (0) | 1592 | #define dbg(format, arg...) \ |
1593 | do { \ | ||
1594 | if (0) \ | ||
1595 | printk(KERN_DEBUG "%s: " format "\n", __FILE__, ##arg); \ | ||
1596 | } while (0) | ||
1591 | #endif | 1597 | #endif |
1592 | 1598 | ||
1593 | #define err(format, arg...) printk(KERN_ERR KBUILD_MODNAME ": " \ | 1599 | #define err(format, arg...) \ |
1594 | format "\n" , ## arg) | 1600 | printk(KERN_ERR KBUILD_MODNAME ": " format "\n", ##arg) |
1595 | 1601 | ||
1596 | /* debugfs stuff */ | 1602 | /* debugfs stuff */ |
1597 | extern struct dentry *usb_debug_root; | 1603 | extern struct dentry *usb_debug_root; |