All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* miscdevice and default attributes
@ 2015-06-08  3:13 David Bakin
  2015-06-08 14:24 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: David Bakin @ 2015-06-08  3:13 UTC (permalink / raw
  To: kernelnewbies

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
<http://kroah.com/log/blog/2013/06/26/how-to-create-a-sysfs-file-correctly/>
(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
<http://lists.kernelnewbies.org/pipermail/kernelnewbies/2015-April/013894.html>
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20150607/cf4465be/attachment.html 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* miscdevice and default attributes
  2015-06-08  3:13 miscdevice and default attributes David Bakin
@ 2015-06-08 14:24 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2015-06-08 14:24 UTC (permalink / raw
  To: kernelnewbies

On Sun, Jun 07, 2015 at 08:13:37PM -0700, David Bakin wrote:
> 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;
> };

Look at 4.1-rc1, this structure has changed to solve this issue.

Hope this helps,

greg k-h

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-06-08 14:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-08  3:13 miscdevice and default attributes David Bakin
2015-06-08 14:24 ` Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.