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