1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>usb_sg_init</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="The Linux-USB Host Side API"><link rel="up" href="usbcore.html" title="Chapter&#160;5.&#160;USB Core APIs"><link rel="prev" href="API-usb-bulk-msg.html" title="usb_bulk_msg"><link rel="next" href="API-usb-sg-wait.html" title="usb_sg_wait"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center"><span class="phrase">usb_sg_init</span></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="API-usb-bulk-msg.html">Prev</a>&#160;</td><th width="60%" align="center">Chapter&#160;5.&#160;USB Core APIs</th><td width="20%" align="right">&#160;<a accesskey="n" href="API-usb-sg-wait.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="API-usb-sg-init"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>usb_sg_init &#8212; 
2     initializes scatterlist-based bulk/interrupt I/O request
3 </p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">usb_sg_init </b>(</code></td><td>struct usb_sg_request * <var class="pdparam">io</var>, </td></tr><tr><td>&#160;</td><td>struct usb_device * <var class="pdparam">dev</var>, </td></tr><tr><td>&#160;</td><td>unsigned <var class="pdparam">pipe</var>, </td></tr><tr><td>&#160;</td><td>unsigned <var class="pdparam">period</var>, </td></tr><tr><td>&#160;</td><td>struct scatterlist * <var class="pdparam">sg</var>, </td></tr><tr><td>&#160;</td><td>int <var class="pdparam">nents</var>, </td></tr><tr><td>&#160;</td><td>size_t <var class="pdparam">length</var>, </td></tr><tr><td>&#160;</td><td>gfp_t <var class="pdparam">mem_flags</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer">&#160;</div></div></div><div class="refsect1"><a name="idp1116170356"></a><h2>Arguments</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="parameter"><code>io</code></em></span></dt><dd><p>
4     request block being initialized.  until <code class="function">usb_sg_wait</code> returns,
5     treat this as a pointer to an opaque block of memory,
6    </p></dd><dt><span class="term"><em class="parameter"><code>dev</code></em></span></dt><dd><p>
7     the usb device that will send or receive the data
8    </p></dd><dt><span class="term"><em class="parameter"><code>pipe</code></em></span></dt><dd><p>
9     endpoint <span class="quote">&#8220;<span class="quote">pipe</span>&#8221;</span> used to transfer the data
10    </p></dd><dt><span class="term"><em class="parameter"><code>period</code></em></span></dt><dd><p>
11     polling rate for interrupt endpoints, in frames or
12     (for high speed endpoints) microframes; ignored for bulk
13    </p></dd><dt><span class="term"><em class="parameter"><code>sg</code></em></span></dt><dd><p>
14     scatterlist entries
15    </p></dd><dt><span class="term"><em class="parameter"><code>nents</code></em></span></dt><dd><p>
16     how many entries in the scatterlist
17    </p></dd><dt><span class="term"><em class="parameter"><code>length</code></em></span></dt><dd><p>
18     how many bytes to send from the scatterlist, or zero to
19     send every byte identified in the list.
20    </p></dd><dt><span class="term"><em class="parameter"><code>mem_flags</code></em></span></dt><dd><p>
21     SLAB_* flags affecting memory allocations in this call
22    </p></dd></dl></div></div><div class="refsect1"><a name="idp1116179716"></a><h2>Description</h2><p>
23   This initializes a scatter/gather request, allocating resources such as
24   I/O mappings and urb memory (except maybe memory used by USB controller
25   drivers).
26   </p><p>
27
28   The request must be issued using <code class="function">usb_sg_wait</code>, which waits for the I/O to
29   complete (or to be canceled) and then cleans up all resources allocated by
30   <code class="function">usb_sg_init</code>.
31   </p><p>
32
33   The request may be canceled with <code class="function">usb_sg_cancel</code>, either before or after
34   <code class="function">usb_sg_wait</code> is called.
35</p></div><div class="refsect1"><a name="idp1116182228"></a><h2>Return</h2><p>
36   Zero for success, else a negative errno value.
37</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="API-usb-bulk-msg.html">Prev</a>&#160;</td><td width="20%" align="center"><a accesskey="u" href="usbcore.html">Up</a></td><td width="40%" align="right">&#160;<a accesskey="n" href="API-usb-sg-wait.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="phrase">usb_bulk_msg</span>&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;<span class="phrase">usb_sg_wait</span></td></tr></table></div></body></html>
38