1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>device_register</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-add.html" title="device_add"><link rel="next" href="API-get-device.html" title="get_device"></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_register</span></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="API-device-add.html">Prev</a> </td><th width="60%" align="center">Device Drivers Base</th><td width="20%" align="right"> <a accesskey="n" href="API-get-device.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="API-device-register"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>device_register — 2 register a device with the system. 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">device_register </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="idp1109320852"></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 pointer to the device structure 5 </p></dd></dl></div></div><div class="refsect1"><a name="idp1109322460"></a><h2>Description</h2><p> 6 This happens in two clean steps - initialize the device 7 and add it to the system. The two steps can be called 8 separately, but this is the easiest and most common. 9 I.e. you should only call the two helpers separately if 10 have a clearly defined need to use and refcount the device 11 before it is added to the hierarchy. 12 </p><p> 13 14 For more information, see the kerneldoc for <code class="function">device_initialize</code> 15 and <code class="function">device_add</code>. 16</p></div><div class="refsect1"><a name="idp1109324292"></a><h2>NOTE</h2><p> 17 _Never_ directly free <em class="parameter"><code>dev</code></em> after calling this function, even 18 if it returned an error! Always use <code class="function">put_device</code> to give up the 19 reference initialized in this function instead. 20</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-add.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-get-device.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="phrase">device_add</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">get_device</span></td></tr></table></div></body></html> 21