usb-compat.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #ifndef __USB_COMPAT_H__
  2. #define __USB_COMPAT_H__
  3. #include "usb.h"
  4. struct usb_hcd {
  5. void *hcd_priv;
  6. };
  7. struct usb_host_endpoint {
  8. struct usb_endpoint_descriptor desc;
  9. struct list_head urb_list;
  10. void *hcpriv;
  11. };
  12. /*
  13. * urb->transfer_flags:
  14. *
  15. * Note: URB_DIR_IN/OUT is automatically set in usb_submit_urb().
  16. */
  17. #define URB_SHORT_NOT_OK 0x0001 /* report short reads as errors */
  18. #define URB_ZERO_PACKET 0x0040 /* Finish bulk OUT with short packet */
  19. struct urb;
  20. typedef void (*usb_complete_t)(struct urb *);
  21. struct urb {
  22. void *hcpriv; /* private data for host controller */
  23. struct list_head urb_list; /* list head for use by the urb's
  24. * current owner */
  25. struct usb_device *dev; /* (in) pointer to associated device */
  26. struct usb_host_endpoint *ep; /* (internal) pointer to endpoint */
  27. unsigned int pipe; /* (in) pipe information */
  28. int status; /* (return) non-ISO status */
  29. unsigned int transfer_flags; /* (in) URB_SHORT_NOT_OK | ...*/
  30. void *transfer_buffer; /* (in) associated data buffer */
  31. dma_addr_t transfer_dma; /* (in) dma addr for transfer_buffer */
  32. u32 transfer_buffer_length; /* (in) data buffer length */
  33. u32 actual_length; /* (return) actual transfer length */
  34. unsigned char *setup_packet; /* (in) setup packet (control only) */
  35. int start_frame; /* (modify) start frame (ISO) */
  36. usb_complete_t complete; /* (in) completion routine */
  37. };
  38. #define usb_hcd_link_urb_to_ep(hcd, urb) ({ \
  39. int ret = 0; \
  40. list_add_tail(&urb->urb_list, &urb->ep->urb_list); \
  41. ret; })
  42. #define usb_hcd_unlink_urb_from_ep(hcd, urb) list_del_init(&urb->urb_list)
  43. static inline void usb_hcd_giveback_urb(struct usb_hcd *hcd,
  44. struct urb *urb,
  45. int status)
  46. {
  47. urb->status = status;
  48. if (urb->complete)
  49. urb->complete(urb);
  50. }
  51. static inline int usb_hcd_unmap_urb_for_dma(struct usb_hcd *hcd,
  52. struct urb *urb)
  53. {
  54. /* TODO: add cache invalidation here */
  55. return 0;
  56. }
  57. static inline u16 find_tt(struct usb_device *dev)
  58. {
  59. u8 chid;
  60. u8 hub;
  61. /* Find out the nearest parent which is high speed */
  62. while (dev->parent->parent != NULL)
  63. if (dev->parent->speed != USB_SPEED_HIGH)
  64. dev = dev->parent;
  65. else
  66. break;
  67. /* determine the port address at that hub */
  68. hub = dev->parent->devnum;
  69. for (chid = 0; chid < USB_MAXCHILDREN; chid++)
  70. if (dev->parent->children[chid] == dev)
  71. break;
  72. return (hub << 8) | chid;
  73. }
  74. #endif /* __USB_COMPAT_H__ */