simple example of ready-to-load miscdevice module on ubuntu 10.04?

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

 



  (i'm sure i can eventually track this down, but maybe someone can
save me the time.)

  while i was writing some lessons on how to write a simple character
driver using the old-style "struct cdev" structure (as described in
the "LDD3" book), gregkh pointed out that there was a much better way
to do it using the newer(?) "struct miscdevice" which added the
ability to dynamically allocate the "minor" device number.

  i've very briefly checked the header and source files for "misc"
devices and i can see from the header file <linux/miscdevice.h> that
there are a number of allocated minor numbers thusly:

... snip ...
#define MICROCODE_MINOR         184
#define TUN_MINOR               200
#define MWAVE_MINOR             219     /* ACP/Mwave Modem */
#define MPT_MINOR               220
#define MPT2SAS_MINOR           221
#define HPET_MINOR              228
#define FUSE_MINOR              229
#define KVM_MINOR               232
#define BTRFS_MINOR             234
#define AUTOFS_MINOR            235
#define MISC_DYNAMIC_MINOR      255

  since miscdevice-based char drivers clearly use major number 10, i
can see that if i, for example (on my ubuntu 10.04 system):

  $ sudo modprobe btrfs

i should not only get that module loaded, but miscdevice-based drivers
apparently also use "udev" to create the device file for it
automatically, so i suddenly get:

$ ls -l /dev/btrfs*
crw-rw---- 1 root root 10, 234 2010-07-23 08:08 /dev/btrfs-control
$

  fair enough.  now, however, i'd like to find (again, on my ubuntu
10.04 system) an example driver that uses dynamic minor number
allocation and that's *not* built into the kernel so i can use that as
a demo of what happens when one loads such a driver.  and, so far, i
haven't found an example like that yet -- every driver that does that
is, on this system, configured to be built into the kernel.

  anyone know of such an example?  i briefly grep'ped thru drivers/
for the macro MISC_DYNAMIC_MINOR but every example i saw was, on this
system, configured to be built into the kernel.

  any suggestions?  i'm sure i can keep scanning and i'll eventually
find one, but if someone knows of one, that would be great.
(obviously, that would be a distro-specific thing.)

rday


-- 

========================================================================
Robert P. J. Day                               Waterloo, Ontario, CANADA

        Top-notch, inexpensive online Linux/OSS/kernel courses
                        http://crashcourse.ca

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

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ



[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