diff options
Diffstat (limited to 'include/linux/usb.h')
| -rw-r--r-- | include/linux/usb.h | 196 |
1 files changed, 119 insertions, 77 deletions
diff --git a/include/linux/usb.h b/include/linux/usb.h index 583e0481dfa0..c08689ea9b4b 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h | |||
| @@ -23,6 +23,7 @@ | |||
| 23 | 23 | ||
| 24 | struct usb_device; | 24 | struct usb_device; |
| 25 | struct usb_driver; | 25 | struct usb_driver; |
| 26 | struct wusb_dev; | ||
| 26 | 27 | ||
| 27 | /*-------------------------------------------------------------------------*/ | 28 | /*-------------------------------------------------------------------------*/ |
| 28 | 29 | ||
| @@ -341,103 +342,146 @@ struct usb_bus { | |||
| 341 | 342 | ||
| 342 | struct usb_tt; | 343 | struct usb_tt; |
| 343 | 344 | ||
| 344 | /* | 345 | /** |
| 345 | * struct usb_device - kernel's representation of a USB device | 346 | * struct usb_device - kernel's representation of a USB device |
| 346 | * | 347 | * @devnum: device number; address on a USB bus |
| 347 | * FIXME: Write the kerneldoc! | 348 | * @devpath: device ID string for use in messages (e.g., /port/...) |
| 348 | * | 349 | * @state: device state: configured, not attached, etc. |
| 350 | * @speed: device speed: high/full/low (or error) | ||
| 351 | * @tt: Transaction Translator info; used with low/full speed dev, highspeed hub | ||
| 352 | * @ttport: device port on that tt hub | ||
| 353 | * @toggle: one bit for each endpoint, with ([0] = IN, [1] = OUT) endpoints | ||
| 354 | * @parent: our hub, unless we're the root | ||
| 355 | * @bus: bus we're part of | ||
| 356 | * @ep0: endpoint 0 data (default control pipe) | ||
| 357 | * @dev: generic device interface | ||
| 358 | * @descriptor: USB device descriptor | ||
| 359 | * @config: all of the device's configs | ||
| 360 | * @actconfig: the active configuration | ||
| 361 | * @ep_in: array of IN endpoints | ||
| 362 | * @ep_out: array of OUT endpoints | ||
| 363 | * @rawdescriptors: raw descriptors for each config | ||
| 364 | * @bus_mA: Current available from the bus | ||
| 365 | * @portnum: parent port number (origin 1) | ||
| 366 | * @level: number of USB hub ancestors | ||
| 367 | * @can_submit: URBs may be submitted | ||
| 368 | * @discon_suspended: disconnected while suspended | ||
| 369 | * @persist_enabled: USB_PERSIST enabled for this device | ||
| 370 | * @have_langid: whether string_langid is valid | ||
| 371 | * @authorized: policy has said we can use it; | ||
| 372 | * (user space) policy determines if we authorize this device to be | ||
| 373 | * used or not. By default, wired USB devices are authorized. | ||
| 374 | * WUSB devices are not, until we authorize them from user space. | ||
| 375 | * FIXME -- complete doc | ||
| 376 | * @authenticated: Crypto authentication passed | ||
| 377 | * @wusb: device is Wireless USB | ||
| 378 | * @string_langid: language ID for strings | ||
| 379 | * @product: iProduct string, if present (static) | ||
| 380 | * @manufacturer: iManufacturer string, if present (static) | ||
| 381 | * @serial: iSerialNumber string, if present (static) | ||
| 382 | * @filelist: usbfs files that are open to this device | ||
| 383 | * @usb_classdev: USB class device that was created for usbfs device | ||
| 384 | * access from userspace | ||
| 385 | * @usbfs_dentry: usbfs dentry entry for the device | ||
| 386 | * @maxchild: number of ports if hub | ||
| 387 | * @children: child devices - USB devices that are attached to this hub | ||
| 388 | * @pm_usage_cnt: usage counter for autosuspend | ||
| 389 | * @quirks: quirks of the whole device | ||
| 390 | * @urbnum: number of URBs submitted for the whole device | ||
| 391 | * @active_duration: total time device is not suspended | ||
| 392 | * @autosuspend: for delayed autosuspends | ||
| 393 | * @pm_mutex: protects PM operations | ||
| 394 | * @last_busy: time of last use | ||
| 395 | * @autosuspend_delay: in jiffies | ||
| 396 | * @connect_time: time device was first connected | ||
| 397 | * @auto_pm: autosuspend/resume in progress | ||
| 398 | * @do_remote_wakeup: remote wakeup should be enabled | ||
| 399 | * @reset_resume: needs reset instead of resume | ||
| 400 | * @autosuspend_disabled: autosuspend disabled by the user | ||
| 401 | * @autoresume_disabled: autoresume disabled by the user | ||
| 402 | * @skip_sys_resume: skip the next system resume | ||
| 403 | * | ||
| 404 | * Notes: | ||
| 349 | * Usbcore drivers should not set usbdev->state directly. Instead use | 405 | * Usbcore drivers should not set usbdev->state directly. Instead use |
| 350 | * usb_set_device_state(). | 406 | * usb_set_device_state(). |
| 351 | * | ||
| 352 | * @authorized: (user space) policy determines if we authorize this | ||
| 353 | * device to be used or not. By default, wired USB | ||
| 354 | * devices are authorized. WUSB devices are not, until we | ||
| 355 | * authorize them from user space. FIXME -- complete doc | ||
| 356 | */ | 407 | */ |
| 357 | struct usb_device { | 408 | struct usb_device { |
| 358 | int devnum; /* Address on USB bus */ | 409 | int devnum; |
| 359 | char devpath [16]; /* Use in messages: /port/port/... */ | 410 | char devpath [16]; |
| 360 | enum usb_device_state state; /* configured, not attached, etc */ | 411 | enum usb_device_state state; |
| 361 | enum usb_device_speed speed; /* high/full/low (or error) */ | 412 | enum usb_device_speed speed; |
| 362 | 413 | ||
| 363 | struct usb_tt *tt; /* low/full speed dev, highspeed hub */ | 414 | struct usb_tt *tt; |
| 364 | int ttport; /* device port on that tt hub */ | 415 | int ttport; |
| 365 | 416 | ||
| 366 | unsigned int toggle[2]; /* one bit for each endpoint | 417 | unsigned int toggle[2]; |
| 367 | * ([0] = IN, [1] = OUT) */ | ||
| 368 | 418 | ||
| 369 | struct usb_device *parent; /* our hub, unless we're the root */ | 419 | struct usb_device *parent; |
| 370 | struct usb_bus *bus; /* Bus we're part of */ | 420 | struct usb_bus *bus; |
| 371 | struct usb_host_endpoint ep0; | 421 | struct usb_host_endpoint ep0; |
| 372 | 422 | ||
| 373 | struct device dev; /* Generic device interface */ | 423 | struct device dev; |
| 374 | 424 | ||
| 375 | struct usb_device_descriptor descriptor;/* Descriptor */ | 425 | struct usb_device_descriptor descriptor; |
| 376 | struct usb_host_config *config; /* All of the configs */ | 426 | struct usb_host_config *config; |
| 377 | 427 | ||
| 378 | struct usb_host_config *actconfig;/* the active configuration */ | 428 | struct usb_host_config *actconfig; |
| 379 | struct usb_host_endpoint *ep_in[16]; | 429 | struct usb_host_endpoint *ep_in[16]; |
| 380 | struct usb_host_endpoint *ep_out[16]; | 430 | struct usb_host_endpoint *ep_out[16]; |
| 381 | 431 | ||
| 382 | char **rawdescriptors; /* Raw descriptors for each config */ | 432 | char **rawdescriptors; |
| 383 | 433 | ||
| 384 | unsigned short bus_mA; /* Current available from the bus */ | 434 | unsigned short bus_mA; |
| 385 | u8 portnum; /* Parent port number (origin 1) */ | 435 | u8 portnum; |
| 386 | u8 level; /* Number of USB hub ancestors */ | 436 | u8 level; |
| 387 | 437 | ||
| 388 | unsigned can_submit:1; /* URBs may be submitted */ | 438 | unsigned can_submit:1; |
| 389 | unsigned discon_suspended:1; /* Disconnected while suspended */ | 439 | unsigned discon_suspended:1; |
| 390 | unsigned have_langid:1; /* whether string_langid is valid */ | 440 | unsigned persist_enabled:1; |
| 391 | unsigned authorized:1; /* Policy has said we can use it */ | 441 | unsigned have_langid:1; |
| 392 | unsigned wusb:1; /* Device is Wireless USB */ | 442 | unsigned authorized:1; |
| 393 | int string_langid; /* language ID for strings */ | 443 | unsigned authenticated:1; |
| 444 | unsigned wusb:1; | ||
| 445 | int string_langid; | ||
| 394 | 446 | ||
| 395 | /* static strings from the device */ | 447 | /* static strings from the device */ |
| 396 | char *product; /* iProduct string, if present */ | 448 | char *product; |
| 397 | char *manufacturer; /* iManufacturer string, if present */ | 449 | char *manufacturer; |
| 398 | char *serial; /* iSerialNumber string, if present */ | 450 | char *serial; |
| 399 | 451 | ||
| 400 | struct list_head filelist; | 452 | struct list_head filelist; |
| 401 | #ifdef CONFIG_USB_DEVICE_CLASS | 453 | #ifdef CONFIG_USB_DEVICE_CLASS |
| 402 | struct device *usb_classdev; | 454 | struct device *usb_classdev; |
| 403 | #endif | 455 | #endif |
| 404 | #ifdef CONFIG_USB_DEVICEFS | 456 | #ifdef CONFIG_USB_DEVICEFS |
| 405 | struct dentry *usbfs_dentry; /* usbfs dentry entry for the device */ | 457 | struct dentry *usbfs_dentry; |
| 406 | #endif | 458 | #endif |
| 407 | /* | ||
| 408 | * Child devices - these can be either new devices | ||
| 409 | * (if this is a hub device), or different instances | ||
| 410 | * of this same device. | ||
| 411 | * | ||
| 412 | * Each instance needs its own set of data structures. | ||
| 413 | */ | ||
| 414 | 459 | ||
| 415 | int maxchild; /* Number of ports if hub */ | 460 | int maxchild; |
| 416 | struct usb_device *children[USB_MAXCHILDREN]; | 461 | struct usb_device *children[USB_MAXCHILDREN]; |
| 417 | 462 | ||
| 418 | int pm_usage_cnt; /* usage counter for autosuspend */ | 463 | int pm_usage_cnt; |
| 419 | u32 quirks; /* quirks of the whole device */ | 464 | u32 quirks; |
| 420 | atomic_t urbnum; /* number of URBs submitted for | 465 | atomic_t urbnum; |
| 421 | the whole device */ | ||
| 422 | 466 | ||
| 423 | unsigned long active_duration; /* total time device is not suspended */ | 467 | unsigned long active_duration; |
| 424 | 468 | ||
| 425 | #ifdef CONFIG_PM | 469 | #ifdef CONFIG_PM |
| 426 | struct delayed_work autosuspend; /* for delayed autosuspends */ | 470 | struct delayed_work autosuspend; |
| 427 | struct mutex pm_mutex; /* protects PM operations */ | 471 | struct mutex pm_mutex; |
| 428 | 472 | ||
| 429 | unsigned long last_busy; /* time of last use */ | 473 | unsigned long last_busy; |
| 430 | int autosuspend_delay; /* in jiffies */ | 474 | int autosuspend_delay; |
| 431 | unsigned long connect_time; /* time device was first connected */ | 475 | unsigned long connect_time; |
| 432 | 476 | ||
| 433 | unsigned auto_pm:1; /* autosuspend/resume in progress */ | 477 | unsigned auto_pm:1; |
| 434 | unsigned do_remote_wakeup:1; /* remote wakeup should be enabled */ | 478 | unsigned do_remote_wakeup:1; |
| 435 | unsigned reset_resume:1; /* needs reset instead of resume */ | 479 | unsigned reset_resume:1; |
| 436 | unsigned persist_enabled:1; /* USB_PERSIST enabled for this dev */ | 480 | unsigned autosuspend_disabled:1; |
| 437 | unsigned autosuspend_disabled:1; /* autosuspend and autoresume */ | 481 | unsigned autoresume_disabled:1; |
| 438 | unsigned autoresume_disabled:1; /* disabled by the user */ | 482 | unsigned skip_sys_resume:1; |
| 439 | unsigned skip_sys_resume:1; /* skip the next system resume */ | ||
| 440 | #endif | 483 | #endif |
| 484 | struct wusb_dev *wusb_dev; | ||
| 441 | }; | 485 | }; |
| 442 | #define to_usb_device(d) container_of(d, struct usb_device, dev) | 486 | #define to_usb_device(d) container_of(d, struct usb_device, dev) |
| 443 | 487 | ||
| @@ -898,10 +942,11 @@ struct usbdrv_wrap { | |||
| 898 | * and should normally be the same as the module name. | 942 | * and should normally be the same as the module name. |
| 899 | * @probe: Called to see if the driver is willing to manage a particular | 943 | * @probe: Called to see if the driver is willing to manage a particular |
| 900 | * interface on a device. If it is, probe returns zero and uses | 944 | * interface on a device. If it is, probe returns zero and uses |
| 901 | * dev_set_drvdata() to associate driver-specific data with the | 945 | * usb_set_intfdata() to associate driver-specific data with the |
| 902 | * interface. It may also use usb_set_interface() to specify the | 946 | * interface. It may also use usb_set_interface() to specify the |
| 903 | * appropriate altsetting. If unwilling to manage the interface, | 947 | * appropriate altsetting. If unwilling to manage the interface, |
| 904 | * return a negative errno value. | 948 | * return -ENODEV, if genuine IO errors occured, an appropriate |
| 949 | * negative errno value. | ||
| 905 | * @disconnect: Called when the interface is no longer accessible, usually | 950 | * @disconnect: Called when the interface is no longer accessible, usually |
| 906 | * because its device has been (or is being) disconnected or the | 951 | * because its device has been (or is being) disconnected or the |
| 907 | * driver module is being unloaded. | 952 | * driver module is being unloaded. |
| @@ -916,10 +961,7 @@ struct usbdrv_wrap { | |||
| 916 | * @pre_reset: Called by usb_reset_composite_device() when the device | 961 | * @pre_reset: Called by usb_reset_composite_device() when the device |
| 917 | * is about to be reset. | 962 | * is about to be reset. |
| 918 | * @post_reset: Called by usb_reset_composite_device() after the device | 963 | * @post_reset: Called by usb_reset_composite_device() after the device |
| 919 | * has been reset, or in lieu of @resume following a reset-resume | 964 | * has been reset |
| 920 | * (i.e., the device is reset instead of being resumed, as might | ||
| 921 | * happen if power was lost). The second argument tells which is | ||
| 922 | * the reason. | ||
| 923 | * @id_table: USB drivers use ID table to support hotplugging. | 965 | * @id_table: USB drivers use ID table to support hotplugging. |
| 924 | * Export this with MODULE_DEVICE_TABLE(usb,...). This must be set | 966 | * Export this with MODULE_DEVICE_TABLE(usb,...). This must be set |
| 925 | * or your driver's probe function will never get called. | 967 | * or your driver's probe function will never get called. |
| @@ -1411,6 +1453,7 @@ extern int usb_submit_urb(struct urb *urb, gfp_t mem_flags); | |||
| 1411 | extern int usb_unlink_urb(struct urb *urb); | 1453 | extern int usb_unlink_urb(struct urb *urb); |
| 1412 | extern void usb_kill_urb(struct urb *urb); | 1454 | extern void usb_kill_urb(struct urb *urb); |
| 1413 | extern void usb_kill_anchored_urbs(struct usb_anchor *anchor); | 1455 | extern void usb_kill_anchored_urbs(struct usb_anchor *anchor); |
| 1456 | extern void usb_unlink_anchored_urbs(struct usb_anchor *anchor); | ||
| 1414 | extern void usb_anchor_urb(struct urb *urb, struct usb_anchor *anchor); | 1457 | extern void usb_anchor_urb(struct urb *urb, struct usb_anchor *anchor); |
| 1415 | extern void usb_unanchor_urb(struct urb *urb); | 1458 | extern void usb_unanchor_urb(struct urb *urb); |
| 1416 | extern int usb_wait_anchor_empty_timeout(struct usb_anchor *anchor, | 1459 | extern int usb_wait_anchor_empty_timeout(struct usb_anchor *anchor, |
| @@ -1661,13 +1704,12 @@ extern void usb_unregister_notify(struct notifier_block *nb); | |||
| 1661 | #define dbg(format, arg...) do {} while (0) | 1704 | #define dbg(format, arg...) do {} while (0) |
| 1662 | #endif | 1705 | #endif |
| 1663 | 1706 | ||
| 1664 | #define err(format, arg...) printk(KERN_ERR "%s: " format "\n" , \ | 1707 | #define err(format, arg...) printk(KERN_ERR KBUILD_MODNAME ": " \ |
| 1665 | __FILE__ , ## arg) | 1708 | format "\n" , ## arg) |
| 1666 | #define info(format, arg...) printk(KERN_INFO "%s: " format "\n" , \ | 1709 | #define info(format, arg...) printk(KERN_INFO KBUILD_MODNAME ": " \ |
| 1667 | __FILE__ , ## arg) | 1710 | format "\n" , ## arg) |
| 1668 | #define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n" , \ | 1711 | #define warn(format, arg...) printk(KERN_WARNING KBUILD_MODNAME ": " \ |
| 1669 | __FILE__ , ## arg) | 1712 | format "\n" , ## arg) |
| 1670 | |||
| 1671 | 1713 | ||
| 1672 | #endif /* __KERNEL__ */ | 1714 | #endif /* __KERNEL__ */ |
| 1673 | 1715 | ||
