usb.h 4.6 KB

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