kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* question about misc char devices, and relationship with udev
@ 2011-04-23 13:45 Robert P. J. Day
  2011-04-23 15:09 ` Greg KH
  2011-05-05 14:43 ` onlyfever
  0 siblings, 2 replies; 3+ messages in thread
From: Robert P. J. Day @ 2011-04-23 13:45 UTC (permalink / raw)
  To: kernelnewbies


  (probably a question with a very simple answer, i just don't know
what it is.)

  i'm currently trying to document the use of the "misc" char driver
to quickly and conveniently create a character driver.  there's a
decent explanation of misc drivers in the book "essential linux device
drivers", as well as a nice example here:

  http://virtlog.com/2008/03/25/linux-miscdevice-sample/

but here's where i get confused.

  what a misc char driver does is combine a lot of what you'd normally
do in creating a regular char driver in a single call.  on page 160 of
ELDD, it's explained that a single call to misc_register() does all of
the following that you would normally have to do yourself for a
regular char driver:

  * allocates major/minor number via alloc_chrdev_region()
  * creates /dev and /sys nodes via call to class_device_create()
  * registers itself as a char driver using cdev_init() and cdev_add()

sure enough, i compiled that sample misc char driver (called
"mymisc"), loaded it and got an entry for that module both under /sys
and under /dev, where i now have the device file:

crw------- 1 root root 10, 56 2011-04-23 08:18 /dev/mymisc

but here's the confusing part.  who or what created that /dev entry?
i always thought that was the job of udev, but i never added any udev
rule for this new driver.  so how did that new /dev file come to be?
is there some sort of generic udev rule that would have handled this?

  also, the ELDD book claims that misc_register() calls the kernel
routine class_device_create().  i'm looking at the entire
kernel implementation for misc drivers in drivers/char/misc.c, and
what i see is a call to device_create() instead.  i suspect i should
start following the flow of control here, but i'm still curious as to
how that /dev file came into existence without any obvious help
from udev.

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================

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

end of thread, other threads:[~2011-05-05 14:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-23 13:45 question about misc char devices, and relationship with udev Robert P. J. Day
2011-04-23 15:09 ` Greg KH
2011-05-05 14:43 ` onlyfever

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).