1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>device_initialize</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="ch02s02.html" title="Device Drivers Base"><link rel="prev" href="API-device-remove-bin-file.html" title="device_remove_bin_file"><link rel="next" href="API-dev-set-name.html" title="dev_set_name"></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">device_initialize</span></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="API-device-remove-bin-file.html">Prev</a> </td><th width="60%" align="center">Device Drivers Base</th><td width="20%" align="right"> <a accesskey="n" href="API-dev-set-name.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="API-device-initialize"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>device_initialize — 2 init device structure. 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">void <b class="fsfunc">device_initialize </b>(</code></td><td>struct device * <var class="pdparam">dev</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div></div><div class="refsect1"><a name="idp1109288652"></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 device. 5 </p></dd></dl></div></div><div class="refsect1"><a name="idp1109290236"></a><h2>Description</h2><p> 6 This prepares the device for use by other layers by initializing 7 its fields. 8 It is the first half of <code class="function">device_register</code>, if called by 9 that function, though it can also be called separately, so one 10 may use <em class="parameter"><code>dev</code></em>'s fields. In particular, <code class="function">get_device</code>/<code class="function">put_device</code> 11 may be used for reference counting of <em class="parameter"><code>dev</code></em> after calling this 12 function. 13 </p><p> 14 15 All fields in <em class="parameter"><code>dev</code></em> must be initialized by the caller to 0, except 16 for those explicitly set to some other value. The simplest 17 approach is to use <code class="function">kzalloc</code> to allocate the structure containing 18 <em class="parameter"><code>dev</code></em>. 19</p></div><div class="refsect1"><a name="idp1109294220"></a><h2>NOTE</h2><p> 20 Use <code class="function">put_device</code> to give up your reference instead of freeing 21 <em class="parameter"><code>dev</code></em> directly once you have called this function. 22</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="API-device-remove-bin-file.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch02s02.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="API-dev-set-name.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="phrase">device_remove_bin_file</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">dev_set_name</span></td></tr></table></div></body></html> 23