1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>device_create_with_groups</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-create.html" title="device_create"><link rel="next" href="API-device-destroy.html" title="device_destroy"></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_create_with_groups</span></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="API-device-create.html">Prev</a>&#160;</td><th width="60%" align="center">Device Drivers Base</th><td width="20%" align="right">&#160;<a accesskey="n" href="API-device-destroy.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="API-device-create-with-groups"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>device_create_with_groups &#8212; 
2     creates a device and registers it with sysfs
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">struct device * <b class="fsfunc">device_create_with_groups </b>(</code></td><td>struct class * <var class="pdparam">class</var>, </td></tr><tr><td>&#160;</td><td>struct device * <var class="pdparam">parent</var>, </td></tr><tr><td>&#160;</td><td>dev_t <var class="pdparam">devt</var>, </td></tr><tr><td>&#160;</td><td>void * <var class="pdparam">drvdata</var>, </td></tr><tr><td>&#160;</td><td>const struct attribute_group ** <var class="pdparam">groups</var>, </td></tr><tr><td>&#160;</td><td>const char * <var class="pdparam">fmt</var>, </td></tr><tr><td>&#160;</td><td> <var class="pdparam">...</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer">&#160;</div></div></div><div class="refsect1"><a name="idp1109442652"></a><h2>Arguments</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="parameter"><code>class</code></em></span></dt><dd><p>
4     pointer to the struct class that this device should be registered to
5    </p></dd><dt><span class="term"><em class="parameter"><code>parent</code></em></span></dt><dd><p>
6     pointer to the parent struct device of this new device, if any
7    </p></dd><dt><span class="term"><em class="parameter"><code>devt</code></em></span></dt><dd><p>
8     the dev_t for the char device to be added
9    </p></dd><dt><span class="term"><em class="parameter"><code>drvdata</code></em></span></dt><dd><p>
10     the data to be added to the device for callbacks
11    </p></dd><dt><span class="term"><em class="parameter"><code>groups</code></em></span></dt><dd><p>
12     NULL-terminated list of attribute groups to be created
13    </p></dd><dt><span class="term"><em class="parameter"><code>fmt</code></em></span></dt><dd><p>
14     string for the device's name
15    </p></dd><dt><span class="term"><em class="parameter"><code>...</code></em></span></dt><dd><p>
16     variable arguments
17    </p></dd></dl></div></div><div class="refsect1"><a name="idp1109450556"></a><h2>Description</h2><p>
18   This function can be used by char device classes.  A struct device
19   will be created in sysfs, registered to the specified class.
20   Additional attributes specified in the groups parameter will also
21   be created automatically.
22   </p><p>
23
24   A <span class="quote">&#8220;<span class="quote">dev</span>&#8221;</span> file will be created, showing the dev_t for the device, if
25   the dev_t is not 0,0.
26   If a pointer to a parent struct device is passed in, the newly created
27   struct device will be a child of that device in sysfs.
28   The pointer to the struct device will be returned from the call.
29   Any further sysfs files that might be required can be created using this
30   pointer.
31   </p><p>
32
33   Returns <span class="structname">struct device</span> pointer on success, or <code class="function">ERR_PTR</code> on error.
34</p></div><div class="refsect1"><a name="idp1109452876"></a><h2>Note</h2><p>
35   the struct class passed to this function must have previously
36   been created with a call to <code class="function">class_create</code>.
37</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-create.html">Prev</a>&#160;</td><td width="20%" align="center"><a accesskey="u" href="ch02s02.html">Up</a></td><td width="40%" align="right">&#160;<a accesskey="n" href="API-device-destroy.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="phrase">device_create</span>&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;<span class="phrase">device_destroy</span></td></tr></table></div></body></html>
38