usb.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /* Functions local to drivers/usb/core/ */
  2. extern void usb_create_sysfs_dev_files (struct usb_device *dev);
  3. extern void usb_remove_sysfs_dev_files (struct usb_device *dev);
  4. extern void usb_create_sysfs_intf_files (struct usb_interface *intf);
  5. extern void usb_remove_sysfs_intf_files (struct usb_interface *intf);
  6. extern void 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_suspend_root_hub(struct usb_device *hdev);
  20. extern void usb_resume_root_hub(struct usb_device *dev);
  21. extern int usb_hub_init(void);
  22. extern void usb_hub_cleanup(void);
  23. extern int usb_major_init(void);
  24. extern void usb_major_cleanup(void);
  25. extern int usb_host_init(void);
  26. extern void usb_host_cleanup(void);
  27. extern int usb_port_suspend(struct usb_device *dev);
  28. extern int usb_port_resume(struct usb_device *dev);
  29. extern struct bus_type usb_bus_type;
  30. extern struct usb_device_driver usb_generic_driver;
  31. /* Here's how we tell apart devices and interfaces. Luckily there's
  32. * no such thing as a platform USB device, so we can steal the use
  33. * of the platform_data field. */
  34. static inline int is_usb_device(struct device *dev)
  35. {
  36. return dev->platform_data == &usb_generic_driver;
  37. }
  38. /* Do the same for device drivers and interface drivers. */
  39. static inline int is_usb_device_driver(struct device_driver *drv)
  40. {
  41. return container_of(drv, struct usbdrv_wrap, driver)->
  42. for_devices;
  43. }
  44. /* Interfaces and their "power state" are owned by usbcore */
  45. static inline void mark_active(struct usb_interface *f)
  46. {
  47. f->dev.power.power_state.event = PM_EVENT_ON;
  48. }
  49. static inline void mark_quiesced(struct usb_interface *f)
  50. {
  51. f->dev.power.power_state.event = PM_EVENT_FREEZE;
  52. }
  53. static inline int is_active(struct usb_interface *f)
  54. {
  55. return f->dev.power.power_state.event == PM_EVENT_ON;
  56. }
  57. /* for labeling diagnostics */
  58. extern const char *usbcore_name;
  59. /* usbfs stuff */
  60. extern struct mutex usbfs_mutex;
  61. extern struct usb_driver usbfs_driver;
  62. extern struct file_operations usbfs_devices_fops;
  63. extern struct file_operations usbfs_device_file_operations;
  64. extern void usbfs_conn_disc_event(void);
  65. extern int usbdev_init(void);
  66. extern void usbdev_cleanup(void);
  67. struct dev_state {
  68. struct list_head list; /* state list */
  69. struct usb_device *dev;
  70. struct file *file;
  71. spinlock_t lock; /* protects the async urb lists */
  72. struct list_head async_pending;
  73. struct list_head async_completed;
  74. wait_queue_head_t wait; /* wake up if a request completed */
  75. unsigned int discsignr;
  76. pid_t disc_pid;
  77. uid_t disc_uid, disc_euid;
  78. void __user *disccontext;
  79. unsigned long ifclaimed;
  80. u32 secid;
  81. };
  82. /* internal notify stuff */
  83. extern void usb_notify_add_device(struct usb_device *udev);
  84. extern void usb_notify_remove_device(struct usb_device *udev);
  85. extern void usb_notify_add_bus(struct usb_bus *ubus);
  86. extern void usb_notify_remove_bus(struct usb_bus *ubus);