1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>allocate_resource</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="The Linux Kernel API"><link rel="up" href="ch09s03.html" title="Resources Management"><link rel="prev" href="API-release-resource.html" title="release_resource"><link rel="next" href="API-adjust-resource.html" title="adjust_resource"></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">allocate_resource</span></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="API-release-resource.html">Prev</a> </td><th width="60%" align="center">Resources Management</th><td width="20%" align="right"> <a accesskey="n" href="API-adjust-resource.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="API-allocate-resource"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>allocate_resource — 2 allocate empty slot in the resource tree given range & alignment. The resource will be reallocated with a new size if it was already allocated 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">allocate_resource </b>(</code></td><td>struct resource * <var class="pdparam">root</var>, </td></tr><tr><td> </td><td>struct resource * <var class="pdparam">new</var>, </td></tr><tr><td> </td><td>resource_size_t <var class="pdparam">size</var>, </td></tr><tr><td> </td><td>resource_size_t <var class="pdparam">min</var>, </td></tr><tr><td> </td><td>resource_size_t <var class="pdparam">max</var>, </td></tr><tr><td> </td><td>resource_size_t <var class="pdparam">align</var>, </td></tr><tr><td> </td><td>resource_size_t (*<var class="pdparam">alignf</var>) 4 <code>(</code>void *, const struct resource *, resource_size_t, resource_size_t<code>)</code>, </td></tr><tr><td> </td><td>void * <var class="pdparam">alignf_data</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div></div><div class="refsect1"><a name="idp1125958916"></a><h2>Arguments</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="parameter"><code>root</code></em></span></dt><dd><p> 5 root resource descriptor 6 </p></dd><dt><span class="term"><em class="parameter"><code>new</code></em></span></dt><dd><p> 7 resource descriptor desired by caller 8 </p></dd><dt><span class="term"><em class="parameter"><code>size</code></em></span></dt><dd><p> 9 requested resource region size 10 </p></dd><dt><span class="term"><em class="parameter"><code>min</code></em></span></dt><dd><p> 11 minimum boundary to allocate 12 </p></dd><dt><span class="term"><em class="parameter"><code>max</code></em></span></dt><dd><p> 13 maximum boundary to allocate 14 </p></dd><dt><span class="term"><em class="parameter"><code>align</code></em></span></dt><dd><p> 15 alignment requested, in bytes 16 </p></dd><dt><span class="term"><em class="parameter"><code>alignf</code></em></span></dt><dd><p> 17 alignment function, optional, called if not NULL 18 </p></dd><dt><span class="term"><em class="parameter"><code>alignf_data</code></em></span></dt><dd><p> 19 arbitrary data to pass to the <em class="parameter"><code>alignf</code></em> function 20 </p></dd></dl></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="API-release-resource.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch09s03.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="API-adjust-resource.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="phrase">release_resource</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">adjust_resource</span></td></tr></table></div></body></html> 21