Re: Doubt regarding Minor Numbers and alloc_chrdev_region

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

 



On Tue, Feb 8, 2011 at 5:50 PM, Sankar P <sankar.curiosity@xxxxxxxxx> wrote:
> On Tue, Feb 8, 2011 at 5:36 PM, Daniel Baluta <daniel.baluta@xxxxxxxxx>
> wrote:
>>
>> > If I try to create a file using, 'mknod /dev/scull2 c 250 7' , the
>> > character device file gets created with a minor number of 7.
>>
>> You can create as much /dev/scull2 files using mknod as you
>> want, but they are not linked with your driver.
>>
>> [first_minor, count] pair passed to alloc_chrdev_region reserve
>> for you a range of minors that will be later used by your driver.
>>
>> Next step is to actually create the link between the node and your
>> driver using chrdev_add.
>>
>
> Ah okay. I understand this now. On reading a few more pages in the book, I
> see that the authors explain this phenomenon.
> However, It seems using register_chrdev is an old way of doing things and
> new code should use cdev. I just did a grep for cdev on the latest sources
> and not much seem to be using the cdev* apis.

The new way now is to find a class for a device and to use that class helpers.

Have a look at miscdev for a simple starter [1].

thanks,
Daniel.

[1] http://lxr.linux.no/linux+v2.6.37/include/linux/miscdevice.h

_______________________________________________
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