usb.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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 int usb_autoresume_device(struct usb_device *udev);
  56. #else
  57. #define usb_autosuspend_device(udev) do {} while (0)
  58. static inline int usb_autoresume_device(struct usb_device *udev)
  59. {
  60. return 0;
  61. }
  62. #endif
  63. extern struct workqueue_struct *ksuspend_usb_wq;
  64. extern struct bus_type usb_bus_type;
  65. extern struct usb_device_driver usb_generic_driver;
  66. /* Here's how we tell apart devices and interfaces. Luckily there's
  67. * no such thing as a platform USB device, so we can steal the use
  68. * of the platform_data field. */
  69. static inline int is_usb_device(const struct device *dev)
  70. {
  71. return dev->platform_data == &usb_generic_driver;
  72. }
  73. /* Do the same for device drivers and interface drivers. */
  74. static inline int is_usb_device_driver(struct device_driver *drv)
  75. {
  76. return container_of(drv, struct usbdrv_wrap, driver)->
  77. for_devices;
  78. }
  79. /* Interfaces and their "power state" are owned by usbcore */
  80. static inline void mark_active(struct usb_interface *f)
  81. {
  82. f->is_active = 1;
  83. }
  84. static inline void mark_quiesced(struct usb_interface *f)
  85. {
  86. f->is_active = 0;
  87. }
  88. static inline int is_active(const struct usb_interface *f)
  89. {
  90. return f->is_active;
  91. }
  92. /* for labeling diagnostics */
  93. extern const char *usbcore_name;
  94. /* usbfs stuff */
  95. extern struct mutex usbfs_mutex;
  96. extern struct usb_driver usbfs_driver;
  97. extern const struct file_operations usbfs_devices_fops;
  98. extern const struct file_operations usbfs_device_file_operations;
  99. extern void usbfs_conn_disc_event(void);
  100. extern int usbdev_init(void);
  101. extern void usbdev_cleanup(void);
  102. struct dev_state {
  103. struct list_head list; /* state list */
  104. struct usb_device *dev;
  105. struct file *file;
  106. spinlock_t lock; /* protects the async urb lists */
  107. struct list_head async_pending;
  108. struct list_head async_completed;
  109. wait_queue_head_t wait; /* wake up if a request completed */
  110. unsigned int discsignr;
  111. struct pid *disc_pid;
  112. uid_t disc_uid, disc_euid;
  113. void __user *disccontext;
  114. unsigned long ifclaimed;
  115. u32 secid;
  116. };
  117. /* internal notify stuff */
  118. extern void usb_notify_add_device(struct usb_device *udev);
  119. extern void usb_notify_remove_device(struct usb_device *udev);
  120. extern void usb_notify_add_bus(struct usb_bus *ubus);
  121. extern void usb_notify_remove_bus(struct usb_bus *ubus);