usb.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /* Functions local to drivers/usb/core/ */
  2. extern int usb_create_sysfs_dev_files (struct usb_device *dev);
  3. extern void usb_remove_sysfs_dev_files (struct usb_device *dev);
  4. extern int usb_create_sysfs_intf_files (struct usb_interface *intf);
  5. extern void usb_remove_sysfs_intf_files (struct usb_interface *intf);
  6. extern int usb_create_ep_files(struct device *parent, struct usb_host_endpoint *endpoint,
  7. struct usb_device *udev);
  8. extern void usb_remove_ep_files(struct usb_host_endpoint *endpoint);
  9. extern void usb_disable_endpoint (struct usb_device *dev, unsigned int epaddr);
  10. extern void usb_disable_interface (struct usb_device *dev,
  11. struct usb_interface *intf);
  12. extern void usb_release_interface_cache(struct kref *ref);
  13. extern void usb_disable_device (struct usb_device *dev, int skip_ep0);
  14. extern int usb_get_device_descriptor(struct usb_device *dev,
  15. unsigned int size);
  16. extern char *usb_cache_string(struct usb_device *udev, int index);
  17. extern int usb_set_configuration(struct usb_device *dev, int configuration);
  18. extern void usb_kick_khubd(struct usb_device *dev);
  19. extern void usb_resume_root_hub(struct usb_device *dev);
  20. extern int usb_hub_init(void);
  21. extern void usb_hub_cleanup(void);
  22. extern int usb_major_init(void);
  23. extern void usb_major_cleanup(void);
  24. extern int usb_host_init(void);
  25. extern void usb_host_cleanup(void);
  26. #ifdef CONFIG_PM
  27. extern int usb_suspend_both(struct usb_device *udev, pm_message_t msg);
  28. extern int usb_resume_both(struct usb_device *udev);
  29. extern int usb_port_suspend(struct usb_device *dev);
  30. extern int usb_port_resume(struct usb_device *dev);
  31. static inline void usb_pm_lock(struct usb_device *udev)
  32. {
  33. mutex_lock_nested(&udev->pm_mutex, udev->level);
  34. }
  35. static inline void usb_pm_unlock(struct usb_device *udev)
  36. {
  37. mutex_unlock(&udev->pm_mutex);
  38. }
  39. #else
  40. #define usb_suspend_both(udev, msg) 0
  41. static inline int usb_resume_both(struct usb_device *udev)
  42. {
  43. return 0;
  44. }
  45. #define usb_port_suspend(dev) 0
  46. #define usb_port_resume(dev) 0
  47. static inline void usb_pm_lock(struct usb_device *udev) {}
  48. static inline void usb_pm_unlock(struct usb_device *udev) {}
  49. #endif
  50. #ifdef CONFIG_USB_SUSPEND
  51. #define USB_AUTOSUSPEND_DELAY (HZ*2)
  52. extern void usb_autosuspend_device(struct usb_device *udev);
  53. extern int usb_autoresume_device(struct usb_device *udev);
  54. #else
  55. #define usb_autosuspend_device(udev) do {} while (0)
  56. static inline int usb_autoresume_device(struct usb_device *udev)
  57. {
  58. return 0;
  59. }
  60. #endif
  61. extern struct workqueue_struct *ksuspend_usb_wq;
  62. extern struct bus_type usb_bus_type;
  63. extern struct usb_device_driver usb_generic_driver;
  64. /* Here's how we tell apart devices and interfaces. Luckily there's
  65. * no such thing as a platform USB device, so we can steal the use
  66. * of the platform_data field. */
  67. static inline int is_usb_device(const struct device *dev)
  68. {
  69. return dev->platform_data == &usb_generic_driver;
  70. }
  71. /* Do the same for device drivers and interface drivers. */
  72. static inline int is_usb_device_driver(struct device_driver *drv)
  73. {
  74. return container_of(drv, struct usbdrv_wrap, driver)->
  75. for_devices;
  76. }
  77. /* Interfaces and their "power state" are owned by usbcore */
  78. static inline void mark_active(struct usb_interface *f)
  79. {
  80. f->is_active = 1;
  81. }
  82. static inline void mark_quiesced(struct usb_interface *f)
  83. {
  84. f->is_active = 0;
  85. }
  86. static inline int is_active(const struct usb_interface *f)
  87. {
  88. return f->is_active;
  89. }
  90. /* for labeling diagnostics */
  91. extern const char *usbcore_name;
  92. /* usbfs stuff */
  93. extern struct mutex usbfs_mutex;
  94. extern struct usb_driver usbfs_driver;
  95. extern const struct file_operations usbfs_devices_fops;
  96. extern const struct file_operations usbfs_device_file_operations;
  97. extern void usbfs_conn_disc_event(void);
  98. extern int usbdev_init(void);
  99. extern void usbdev_cleanup(void);
  100. struct dev_state {
  101. struct list_head list; /* state list */
  102. struct usb_device *dev;
  103. struct file *file;
  104. spinlock_t lock; /* protects the async urb lists */
  105. struct list_head async_pending;
  106. struct list_head async_completed;
  107. wait_queue_head_t wait; /* wake up if a request completed */
  108. unsigned int discsignr;
  109. struct pid *disc_pid;
  110. uid_t disc_uid, disc_euid;
  111. void __user *disccontext;
  112. unsigned long ifclaimed;
  113. u32 secid;
  114. };
  115. /* internal notify stuff */
  116. extern void usb_notify_add_device(struct usb_device *udev);
  117. extern void usb_notify_remove_device(struct usb_device *udev);
  118. extern void usb_notify_add_bus(struct usb_bus *ubus);
  119. extern void usb_notify_remove_bus(struct usb_bus *ubus);