<div dir="ltr"><div>Where do I set the default attributes for a device created with <font face="monospace,monospace">misc_register()</font>?</div><div><br></div><div>In kernel 3.19 <font face="monospace,monospace">struct miscdevice</font> looks like this:</div><div><br></div><div><font face="Courier New">struct miscdevice  {<br> int minor;<br> const char *name;<br> const struct file_operations *fops;<br> struct list_head list;<br> struct device *parent;<br> struct device *this_device;<br> const char *nodename;<br> umode_t mode;<br>};</font></div><div><font face="Courier New"><br></font></div><div><font face="arial,helvetica,sans-serif">No attributes there that I can see. I know that after calling <font face="monospace,monospace">misc_register()</font> the <font face="monospace,monospace">this_device</font> field is filled in and I can use <font face="monospace,monospace">device_create_file()</font> to make attributes with it.  But it is too late to use <font face="monospace,monospace">this_device</font>&#39;s own default attributes, right?  The device has already been created.</font></div><div><br></div><div>The reason this is puzzling me is because Greg KH, <a href="http://kroah.com/log/blog/2013/06/26/how-to-create-a-sysfs-file-correctly/">here</a> (in 2013), explains that the right time to set up attributes is when the device is created, using the device&#39;s, the driver&#39;s, the class&#39;s, or the bus&#39;s default attributes field - if you wait until later you run the risk of a losing a race against udev.</div><div><br></div><div>But maybe I&#39;m just confused (I&#39;m rather new here, after all), because <a href="http://lists.kernelnewbies.org/pipermail/kernelnewbies/2015-April/013894.html">here</a> Greg explains that all udev is doing is setting up permissions and symlinks, so maybe I don&#39;t care about the potential race (if I don&#39;t need different permissions).</div><div><br></div><div>I guess another way to ask this question is to ask:  What are the circumstances when I should be concerned about this race between the driver and udev?  In the case of a new misc device for my own private purposes ... it seems unlikely I&#39;d want to use udev to rename it in any particular way or modify permissions separately from the umode I give the kernel, so ... nothing to worry about, right?</div><div><br></div><div>Thanks! -- David</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div>