diff options
Diffstat (limited to 'include/linux/usb.h')
| -rw-r--r-- | include/linux/usb.h | 95 |
1 files changed, 51 insertions, 44 deletions
diff --git a/include/linux/usb.h b/include/linux/usb.h index 332eaea61021..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 */ |
| @@ -401,7 +398,6 @@ struct usb_tt; | |||
| 401 | * @portnum: parent port number (origin 1) | 398 | * @portnum: parent port number (origin 1) |
| 402 | * @level: number of USB hub ancestors | 399 | * @level: number of USB hub ancestors |
| 403 | * @can_submit: URBs may be submitted | 400 | * @can_submit: URBs may be submitted |
| 404 | * @discon_suspended: disconnected while suspended | ||
| 405 | * @persist_enabled: USB_PERSIST enabled for this device | 401 | * @persist_enabled: USB_PERSIST enabled for this device |
| 406 | * @have_langid: whether string_langid is valid | 402 | * @have_langid: whether string_langid is valid |
| 407 | * @authorized: policy has said we can use it; | 403 | * @authorized: policy has said we can use it; |
| @@ -421,20 +417,15 @@ struct usb_tt; | |||
| 421 | * @usbfs_dentry: usbfs dentry entry for the device | 417 | * @usbfs_dentry: usbfs dentry entry for the device |
| 422 | * @maxchild: number of ports if hub | 418 | * @maxchild: number of ports if hub |
| 423 | * @children: child devices - USB devices that are attached to this hub | 419 | * @children: child devices - USB devices that are attached to this hub |
| 424 | * @pm_usage_cnt: usage counter for autosuspend | ||
| 425 | * @quirks: quirks of the whole device | 420 | * @quirks: quirks of the whole device |
| 426 | * @urbnum: number of URBs submitted for the whole device | 421 | * @urbnum: number of URBs submitted for the whole device |
| 427 | * @active_duration: total time device is not suspended | 422 | * @active_duration: total time device is not suspended |
| 428 | * @autosuspend: for delayed autosuspends | ||
| 429 | * @autoresume: for autoresumes requested while in_interrupt | ||
| 430 | * @pm_mutex: protects PM operations | ||
| 431 | * @last_busy: time of last use | 423 | * @last_busy: time of last use |
| 432 | * @autosuspend_delay: in jiffies | 424 | * @autosuspend_delay: in jiffies |
| 433 | * @connect_time: time device was first connected | 425 | * @connect_time: time device was first connected |
| 434 | * @do_remote_wakeup: remote wakeup should be enabled | 426 | * @do_remote_wakeup: remote wakeup should be enabled |
| 435 | * @reset_resume: needs reset instead of resume | 427 | * @reset_resume: needs reset instead of resume |
| 436 | * @autosuspend_disabled: autosuspend disabled by the user | 428 | * @autosuspend_disabled: autosuspend disabled by the user |
| 437 | * @skip_sys_resume: skip the next system resume | ||
| 438 | * @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 |
| 439 | * specific data for the device. | 430 | * specific data for the device. |
| 440 | * @slot_id: Slot ID assigned by xHCI | 431 | * @slot_id: Slot ID assigned by xHCI |
| @@ -475,7 +466,6 @@ struct usb_device { | |||
| 475 | u8 level; | 466 | u8 level; |
| 476 | 467 | ||
| 477 | unsigned can_submit:1; | 468 | unsigned can_submit:1; |
| 478 | unsigned discon_suspended:1; | ||
| 479 | unsigned persist_enabled:1; | 469 | unsigned persist_enabled:1; |
| 480 | unsigned have_langid:1; | 470 | unsigned have_langid:1; |
| 481 | unsigned authorized:1; | 471 | unsigned authorized:1; |
| @@ -499,17 +489,12 @@ struct usb_device { | |||
| 499 | int maxchild; | 489 | int maxchild; |
| 500 | struct usb_device *children[USB_MAXCHILDREN]; | 490 | struct usb_device *children[USB_MAXCHILDREN]; |
| 501 | 491 | ||
| 502 | int pm_usage_cnt; | ||
| 503 | u32 quirks; | 492 | u32 quirks; |
| 504 | atomic_t urbnum; | 493 | atomic_t urbnum; |
| 505 | 494 | ||
| 506 | unsigned long active_duration; | 495 | unsigned long active_duration; |
| 507 | 496 | ||
| 508 | #ifdef CONFIG_PM | 497 | #ifdef CONFIG_PM |
| 509 | struct delayed_work autosuspend; | ||
| 510 | struct work_struct autoresume; | ||
| 511 | struct mutex pm_mutex; | ||
| 512 | |||
| 513 | unsigned long last_busy; | 498 | unsigned long last_busy; |
| 514 | int autosuspend_delay; | 499 | int autosuspend_delay; |
| 515 | unsigned long connect_time; | 500 | unsigned long connect_time; |
| @@ -517,7 +502,6 @@ struct usb_device { | |||
| 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 skip_sys_resume:1; | ||
| 521 | #endif | 505 | #endif |
| 522 | struct wusb_dev *wusb_dev; | 506 | struct wusb_dev *wusb_dev; |
| 523 | int slot_id; | 507 | int slot_id; |
| @@ -528,9 +512,9 @@ extern struct usb_device *usb_get_dev(struct usb_device *dev); | |||
| 528 | extern void usb_put_dev(struct usb_device *dev); | 512 | extern void usb_put_dev(struct usb_device *dev); |
| 529 | 513 | ||
| 530 | /* USB device locking */ | 514 | /* USB device locking */ |
| 531 | #define usb_lock_device(udev) down(&(udev)->dev.sem) | 515 | #define usb_lock_device(udev) device_lock(&(udev)->dev) |
| 532 | #define usb_unlock_device(udev) up(&(udev)->dev.sem) | 516 | #define usb_unlock_device(udev) device_unlock(&(udev)->dev) |
| 533 | #define usb_trylock_device(udev) down_trylock(&(udev)->dev.sem) | 517 | #define usb_trylock_device(udev) device_trylock(&(udev)->dev) |
| 534 | extern int usb_lock_device_for_reset(struct usb_device *udev, | 518 | extern int usb_lock_device_for_reset(struct usb_device *udev, |
| 535 | const struct usb_interface *iface); | 519 | const struct usb_interface *iface); |
| 536 | 520 | ||
| @@ -542,21 +526,15 @@ extern struct usb_device *usb_find_device(u16 vendor_id, u16 product_id); | |||
| 542 | 526 | ||
| 543 | /* USB autosuspend and autoresume */ | 527 | /* USB autosuspend and autoresume */ |
| 544 | #ifdef CONFIG_USB_SUSPEND | 528 | #ifdef CONFIG_USB_SUSPEND |
| 529 | extern int usb_enable_autosuspend(struct usb_device *udev); | ||
| 530 | extern int usb_disable_autosuspend(struct usb_device *udev); | ||
| 531 | |||
| 545 | extern int usb_autopm_get_interface(struct usb_interface *intf); | 532 | extern int usb_autopm_get_interface(struct usb_interface *intf); |
| 546 | extern void usb_autopm_put_interface(struct usb_interface *intf); | 533 | extern void usb_autopm_put_interface(struct usb_interface *intf); |
| 547 | extern int usb_autopm_get_interface_async(struct usb_interface *intf); | 534 | extern int usb_autopm_get_interface_async(struct usb_interface *intf); |
| 548 | extern void usb_autopm_put_interface_async(struct usb_interface *intf); | 535 | extern void usb_autopm_put_interface_async(struct usb_interface *intf); |
| 549 | 536 | extern void usb_autopm_get_interface_no_resume(struct usb_interface *intf); | |
| 550 | static inline void usb_autopm_get_interface_no_resume( | 537 | extern void usb_autopm_put_interface_no_suspend(struct usb_interface *intf); |
| 551 | struct usb_interface *intf) | ||
| 552 | { | ||
| 553 | atomic_inc(&intf->pm_usage_cnt); | ||
| 554 | } | ||
| 555 | static inline void usb_autopm_put_interface_no_suspend( | ||
| 556 | struct usb_interface *intf) | ||
| 557 | { | ||
| 558 | atomic_dec(&intf->pm_usage_cnt); | ||
| 559 | } | ||
| 560 | 538 | ||
| 561 | static inline void usb_mark_last_busy(struct usb_device *udev) | 539 | static inline void usb_mark_last_busy(struct usb_device *udev) |
| 562 | { | 540 | { |
| @@ -565,6 +543,11 @@ static inline void usb_mark_last_busy(struct usb_device *udev) | |||
| 565 | 543 | ||
| 566 | #else | 544 | #else |
| 567 | 545 | ||
| 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) | ||
| 549 | { return 0; } | ||
| 550 | |||
| 568 | static inline int usb_autopm_get_interface(struct usb_interface *intf) | 551 | static inline int usb_autopm_get_interface(struct usb_interface *intf) |
| 569 | { return 0; } | 552 | { return 0; } |
| 570 | 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) |
| @@ -1072,7 +1055,8 @@ typedef void (*usb_complete_t)(struct urb *); | |||
| 1072 | * @number_of_packets: Lists the number of ISO transfer buffers. | 1055 | * @number_of_packets: Lists the number of ISO transfer buffers. |
| 1073 | * @interval: Specifies the polling interval for interrupt or isochronous | 1056 | * @interval: Specifies the polling interval for interrupt or isochronous |
| 1074 | * transfers. The units are frames (milliseconds) for full and low | 1057 | * transfers. The units are frames (milliseconds) for full and low |
| 1075 | * speed devices, and microframes (1/8 millisecond) for highspeed ones. | 1058 | * speed devices, and microframes (1/8 millisecond) for highspeed |
| 1059 | * and SuperSpeed devices. | ||
| 1076 | * @error_count: Returns the number of ISO transfers that reported errors. | 1060 | * @error_count: Returns the number of ISO transfers that reported errors. |
| 1077 | * @context: For use in completion functions. This normally points to | 1061 | * @context: For use in completion functions. This normally points to |
| 1078 | * request-specific driver context. | 1062 | * request-specific driver context. |
| @@ -1101,7 +1085,7 @@ typedef void (*usb_complete_t)(struct urb *); | |||
| 1101 | * 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, |
| 1102 | * 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 |
| 1103 | * 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 |
| 1104 | * 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(). |
| 1105 | * When these transfer flags are provided, host controller drivers will | 1089 | * When these transfer flags are provided, host controller drivers will |
| 1106 | * 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 |
| 1107 | * setup_dma fields rather than determining a dma address themselves. | 1091 | * setup_dma fields rather than determining a dma address themselves. |
| @@ -1303,9 +1287,16 @@ static inline void usb_fill_bulk_urb(struct urb *urb, | |||
| 1303 | * | 1287 | * |
| 1304 | * Initializes a interrupt urb with the proper information needed to submit | 1288 | * Initializes a interrupt urb with the proper information needed to submit |
| 1305 | * it to a device. | 1289 | * it to a device. |
| 1306 | * Note that high speed interrupt endpoints use a logarithmic encoding of | 1290 | * |
| 1307 | * the endpoint interval, and express polling intervals in microframes | 1291 | * Note that High Speed and SuperSpeed interrupt endpoints use a logarithmic |
| 1308 | * (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. | ||
| 1309 | */ | 1300 | */ |
| 1310 | static inline void usb_fill_int_urb(struct urb *urb, | 1301 | static inline void usb_fill_int_urb(struct urb *urb, |
| 1311 | struct usb_device *dev, | 1302 | struct usb_device *dev, |
| @@ -1322,7 +1313,7 @@ static inline void usb_fill_int_urb(struct urb *urb, | |||
| 1322 | urb->transfer_buffer_length = buffer_length; | 1313 | urb->transfer_buffer_length = buffer_length; |
| 1323 | urb->complete = complete_fn; | 1314 | urb->complete = complete_fn; |
| 1324 | urb->context = context; | 1315 | urb->context = context; |
| 1325 | if (dev->speed == USB_SPEED_HIGH) | 1316 | if (dev->speed == USB_SPEED_HIGH || dev->speed == USB_SPEED_SUPER) |
| 1326 | urb->interval = 1 << (interval - 1); | 1317 | urb->interval = 1 << (interval - 1); |
| 1327 | else | 1318 | else |
| 1328 | urb->interval = interval; | 1319 | urb->interval = interval; |
| @@ -1375,11 +1366,23 @@ static inline int usb_urb_dir_out(struct urb *urb) | |||
| 1375 | return (urb->transfer_flags & URB_DIR_MASK) == URB_DIR_OUT; | 1366 | return (urb->transfer_flags & URB_DIR_MASK) == URB_DIR_OUT; |
| 1376 | } | 1367 | } |
| 1377 | 1368 | ||
| 1378 | void *usb_buffer_alloc(struct usb_device *dev, size_t size, | 1369 | void *usb_alloc_coherent(struct usb_device *dev, size_t size, |
| 1379 | gfp_t mem_flags, dma_addr_t *dma); | 1370 | gfp_t mem_flags, dma_addr_t *dma); |
| 1380 | void usb_buffer_free(struct usb_device *dev, size_t size, | 1371 | void usb_free_coherent(struct usb_device *dev, size_t size, |
| 1381 | void *addr, dma_addr_t dma); | 1372 | void *addr, dma_addr_t dma); |
| 1382 | 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 | |||
| 1383 | #if 0 | 1386 | #if 0 |
| 1384 | struct urb *usb_buffer_map(struct urb *urb); | 1387 | struct urb *usb_buffer_map(struct urb *urb); |
| 1385 | void usb_buffer_dmasync(struct urb *urb); | 1388 | void usb_buffer_dmasync(struct urb *urb); |
| @@ -1583,14 +1586,18 @@ extern void usb_register_notify(struct notifier_block *nb); | |||
| 1583 | extern void usb_unregister_notify(struct notifier_block *nb); | 1586 | extern void usb_unregister_notify(struct notifier_block *nb); |
| 1584 | 1587 | ||
| 1585 | #ifdef DEBUG | 1588 | #ifdef DEBUG |
| 1586 | #define dbg(format, arg...) printk(KERN_DEBUG "%s: " format "\n" , \ | 1589 | #define dbg(format, arg...) \ |
| 1587 | __FILE__ , ## arg) | 1590 | printk(KERN_DEBUG "%s: " format "\n", __FILE__, ##arg) |
| 1588 | #else | 1591 | #else |
| 1589 | #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) | ||
| 1590 | #endif | 1597 | #endif |
| 1591 | 1598 | ||
| 1592 | #define err(format, arg...) printk(KERN_ERR KBUILD_MODNAME ": " \ | 1599 | #define err(format, arg...) \ |
| 1593 | format "\n" , ## arg) | 1600 | printk(KERN_ERR KBUILD_MODNAME ": " format "\n", ##arg) |
| 1594 | 1601 | ||
| 1595 | /* debugfs stuff */ | 1602 | /* debugfs stuff */ |
| 1596 | extern struct dentry *usb_debug_root; | 1603 | extern struct dentry *usb_debug_root; |
