1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>spi_alloc_master</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="Linux Device Drivers"><link rel="up" href="spi.html" title="Chapter 9. Serial Peripheral Interface (SPI)"><link rel="prev" href="API-spi-finalize-current-message.html" title="spi_finalize_current_message"><link rel="next" href="API-spi-register-master.html" title="spi_register_master"></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">spi_alloc_master</span></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="API-spi-finalize-current-message.html">Prev</a> </td><th width="60%" align="center">Chapter 9. Serial Peripheral Interface (SPI)</th><td width="20%" align="right"> <a accesskey="n" href="API-spi-register-master.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="API-spi-alloc-master"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>spi_alloc_master — 2 allocate SPI master controller 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">struct spi_master * <b class="fsfunc">spi_alloc_master </b>(</code></td><td>struct device * <var class="pdparam">dev</var>, </td></tr><tr><td> </td><td>unsigned <var class="pdparam">size</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div></div><div class="refsect1"><a name="idp1115093844"></a><h2>Arguments</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="parameter"><code>dev</code></em></span></dt><dd><p> 4 the controller, possibly using the platform_bus 5 </p></dd><dt><span class="term"><em class="parameter"><code>size</code></em></span></dt><dd><p> 6 how much zeroed driver-private data to allocate; the pointer to this 7 memory is in the driver_data field of the returned device, 8 accessible with <code class="function">spi_master_get_devdata</code>. 9 </p></dd></dl></div></div><div class="refsect1"><a name="idp1115096996"></a><h2>Context</h2><p> 10 can sleep 11</p></div><div class="refsect1"><a name="idp1115097612"></a><h2>Description</h2><p> 12 This call is used only by SPI master controller drivers, which are the 13 only ones directly touching chip registers. It's how they allocate 14 an spi_master structure, prior to calling <code class="function">spi_register_master</code>. 15 </p><p> 16 17 This must be called from context that can sleep. It returns the SPI 18 master structure on success, else NULL. 19 </p><p> 20 21 The caller is responsible for assigning the bus number and initializing 22 the master's methods before calling <code class="function">spi_register_master</code>; and (after errors 23 adding the device) calling <code class="function">spi_master_put</code> to prevent a memory leak. 24</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="API-spi-finalize-current-message.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="spi.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="API-spi-register-master.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="phrase">spi_finalize_current_message</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> <span class="phrase">spi_register_master</span></td></tr></table></div></body></html> 25