miscdevice and default attributes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Where do I set the default attributes for a device created with misc_register()?

In kernel 3.19 struct miscdevice looks like this:

struct miscdevice  {
 int minor;
 const char *name;
 const struct file_operations *fops;
 struct list_head list;
 struct device *parent;
 struct device *this_device;
 const char *nodename;
 umode_t mode;
};

No attributes there that I can see. I know that after calling misc_register() the this_device field is filled in and I can use device_create_file() to make attributes with it.  But it is too late to use this_device's own default attributes, right?  The device has already been created.

The reason this is puzzling me is because Greg KH, here (in 2013), explains that the right time to set up attributes is when the device is created, using the device's, the driver's, the class's, or the bus's default attributes field - if you wait until later you run the risk of a losing a race against udev.

But maybe I'm just confused (I'm rather new here, after all), because here Greg explains that all udev is doing is setting up permissions and symlinks, so maybe I don't care about the potential race (if I don't need different permissions).

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'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?

Thanks! -- David






_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux