Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| usb:usbperiphapi [2009/05/22 05:53] – AndrewThompson | usb:usbperiphapi [2009/05/22 06:14] (current) – AndrewThompson | ||
|---|---|---|---|
| Line 16: | Line 16: | ||
| void usb_pipe_close(struct usb_pipe **, int count); | void usb_pipe_close(struct usb_pipe **, int count); | ||
| void usb_clear_stall(struct usb_pipe *); | void usb_clear_stall(struct usb_pipe *); | ||
| - | struct usb_urb *usb_alloc_urb(struct usb_pipe *, int flags); | + | struct usb_urb *usb_get_urb(struct usb_pipe *, int flags); |
| int | int | ||
| int | int | ||
| Line 25: | Line 25: | ||
| </ | </ | ||
| + | |||
| + | ===== Structs ===== | ||
| + | ==== struct usb_pipe ==== | ||
| + | A queue for processing urb pointers. Has one dma map and will reload the dma if the current urb is different to the one previously loaded. The pipe has a private mutex for queueing and dequeueing, it does not need to share the mutex with the driver. | ||
| + | |||
| + | ==== struct usb_urb ==== | ||
| + | A data buffer. The memory can be preallocated (fixed size) or passed in from an external buffer. The urb has a single reference and does not need to be locked. | ||
| Notes: | Notes: | ||
| * usb_pipe_open() will preallocate the requested number of urb structures and keep on a free list | * usb_pipe_open() will preallocate the requested number of urb structures and keep on a free list | ||
| - | * usb_alloc_urb() will get a urb from the free list, or allocate if none available (bounds limited). | + | * usb_get_urb() will get a urb from the free list. |
| * usb_free_urb() does not actually free the memory, it puts the urb on the pipe free list | * usb_free_urb() does not actually free the memory, it puts the urb on the pipe free list | ||
| * usb_pipe_halt() cancels all pending urbs and sets the pipe to blocking | * usb_pipe_halt() cancels all pending urbs and sets the pipe to blocking | ||
| Line 70: | Line 77: | ||
| init() | init() | ||
| /* will return up to ' | /* will return up to ' | ||
| - | | + | |
| m = m_getcl(M_WAIT, | m = m_getcl(M_WAIT, | ||
| | | ||
| Line 84: | Line 91: | ||
| start(m) | start(m) | ||
| - | urb = usb_alloc_urb(sc-> | + | urb = usb_get_urb(sc-> |
| + | if (urb == NULL) | ||
| + | | ||
| | | ||
| | | ||
| Line 104: | Line 113: | ||
| m = usb_get_priv(urb); | m = usb_get_priv(urb); | ||
| mnew = m_getcl(M_DONTWAIT, | mnew = m_getcl(M_DONTWAIT, | ||
| - | if (mnew) { | + | if (!mnew) { |
| ifp-> | ifp-> | ||
| goto skip; | goto skip; | ||
| Line 148: | Line 157: | ||
| ttyopen() | ttyopen() | ||
| /* will return up to ' | /* will return up to ' | ||
| - | | + | |
| | | ||
| } | } | ||
| Line 159: | Line 168: | ||
| ttywakeup() | ttywakeup() | ||
| - | urb = usb_alloc_urb(sc-> | + | urb = usb_get_urb(sc-> |
| if (urb == NULL) | if (urb == NULL) | ||
| | | ||