Thread: Allocation of major number and minor number linux

  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    11

    Question Allocation of major number and minor number linux

    HI
    1.How do i allocate major mumber and minor numbers in linux 2.6.8 version.
    Any idea.

    2. Can we allocate Major numbers and minor numbers Dynamically?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    If you're up to the stage of being able to write Linux device drivers, would you be
    a) asking such questions.
    b) be incapable of reading the relevant HOWTO to find out.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Nov 2007
    Posts
    11

    Talking reply to

    HI

    Quote: Salem
    Its a problem i a facing. I am facing this problem from a hour .if u can solve my problem then fine otherwise pls do not pass comments. This is a request.

    Thanks,

  4. #4
    Registered User
    Join Date
    Nov 2007
    Posts
    11

    Smile will this code work?\code

    Will this code work for alocating minor and major numbers
    insert
    Code:
    if(skull_major)
       {
            /* Legacy support for direct assignment */
            dev = MKDEV(skull_major, skull_minor);
            result = register_chrdev_region(dev, scull_nr_devs, "skull");
       }
       else
       {
            /* Dynamic allocation support */
            result = alloc_chrdev_region(&dev, skull_minor, skull_nr_devs, "skull");
            skull_major = MAJOR(dev));
       }
            
       /* Allocation/assignment failure notice */
       (result < 0)?(printk(KERN_WARNING "skull: can't get major %d\n", 
    skull_major);

  5. #5
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    Here's something from an older book on the subject:
    http://www.xml.com/ldd/chapter/book/ch03.html#t2

    gg

Popular pages Recent additions subscribe to a feed