1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>__register_chrdev</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="chrdev.html" title="Chapter 15. Char devices"><link rel="prev" href="API-alloc-chrdev-region.html" title="alloc_chrdev_region"><link rel="next" href="API-unregister-chrdev-region.html" title="unregister_chrdev_region"></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">__register_chrdev</span></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="API-alloc-chrdev-region.html">Prev</a> </td><th width="60%" align="center">Chapter 15. Char devices</th><td width="20%" align="right"> <a accesskey="n" href="API-unregister-chrdev-region.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="API---register-chrdev"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>__register_chrdev — 2 create and register a cdev occupying a range of minors 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">__register_chrdev </b>(</code></td><td>unsigned int <var class="pdparam">major</var>, </td></tr><tr><td> </td><td>unsigned int <var class="pdparam">baseminor</var>, </td></tr><tr><td> </td><td>unsigned int <var class="pdparam">count</var>, </td></tr><tr><td> </td><td>const char * <var class="pdparam">name</var>, </td></tr><tr><td> </td><td>const struct file_operations * <var class="pdparam">fops</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div></div><div class="refsect1"><a name="idp1129096532"></a><h2>Arguments</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="parameter"><code>major</code></em></span></dt><dd><p> 4 major device number or 0 for dynamic allocation 5 </p></dd><dt><span class="term"><em class="parameter"><code>baseminor</code></em></span></dt><dd><p> 6 first of the requested range of minor numbers 7 </p></dd><dt><span class="term"><em class="parameter"><code>count</code></em></span></dt><dd><p> 8 the number of minor numbers required 9 </p></dd><dt><span class="term"><em class="parameter"><code>name</code></em></span></dt><dd><p> 10 name of this range of devices 11 </p></dd><dt><span class="term"><em class="parameter"><code>fops</code></em></span></dt><dd><p> 12 file operations associated with this devices 13 </p></dd></dl></div></div><div class="refsect1"><a name="idp1129102340"></a><h2>Description</h2><p> 14 If <em class="parameter"><code>major</code></em> == 0 this functions will dynamically allocate a major and return 15 its number. 16 </p><p> 17 18 If <em class="parameter"><code>major</code></em> > 0 this function will attempt to reserve a device with the given 19 major number and will return zero on success. 20 </p><p> 21 22 Returns a -ve errno on failure. 23 </p><p> 24 25 The name of this device has nothing to do with the name of the device in 26 /dev. It only helps to keep track of the different owners of devices. If 27 your module name has only one type of devices it's ok to use e.g. the name 28 of the module here. 29</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="API-alloc-chrdev-region.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="chrdev.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="API-unregister-chrdev-region.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="phrase">alloc_chrdev_region</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">unregister_chrdev_region</span></td></tr></table></div></body></html> 30