<?xml version="1.0" encoding="ANSI_X3.4-1968" standalone="no"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><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.75.2" /><link rel="home" href="index.html" title="Linux Device Drivers" /><link rel="up" href="ch09.html" title="Chapter 9. Serial Peripheral Interface (SPI)" /><link rel="prev" href="re745.html" title="spi_new_device" /><link rel="next" href="re747.html" title="spi_register_master" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center"><span>spi_alloc_master</span></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="re745.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="re747.html">Next</a></td></tr></table><hr /></div><div class="refentry" title="spi_alloc_master"><a id="API-spi-alloc-master"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>spi_alloc_master — allocate SPI master controller </p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><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" title="Arguments"><a id="id2706867"></a><h2>Arguments</h2><div class="variablelist"><dl><dt><span class="term"><em class="parameter"><code>dev</code></em></span></dt><dd><p> the controller, possibly using the platform_bus </p></dd><dt><span class="term"><em class="parameter"><code>size</code></em></span></dt><dd><p> how much zeroed driver-private data to allocate; the pointer to this memory is in the driver_data field of the returned device, accessible with <code class="function">spi_master_get_devdata</code>. </p></dd></dl></div></div><div class="refsect1" title="Context"><a id="id2706919"></a><h2>Context</h2><p> can sleep </p></div><div class="refsect1" title="Description"><a id="id2706930"></a><h2>Description</h2><p> This call is used only by SPI master controller drivers, which are the only ones directly touching chip registers. It's how they allocate an spi_master structure, prior to calling <code class="function">spi_register_master</code>. </p><p> This must be called from context that can sleep. It returns the SPI master structure on success, else NULL. </p><p> The caller is responsible for assigning the bus number and initializing the master's methods before calling <code class="function">spi_register_master</code>; and (after errors adding the device) calling <code class="function">spi_master_put</code> to prevent a memory leak. </p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="re745.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch09.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="re747.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span>spi_new_device</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> <span>spi_register_master</span></td></tr></table></div></body></html>