How to create node in /dev

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

 



hi all,

in my testing module I have this part of code:

static int __init my_init(void) {
    int err = 0;
    if (alloc_chrdev_region(&dev, 0, 1, "my_device") != 0) {
        printk("<1>error: alloc_chrdev_region failed!");
        return -1;
    }
    cdev_init(&amp;my_cdev, &amp;fops);
    err = cdev_add(&amp;my_cdev, &amp;dev, 1);
    if (err) {
        printk(KERN_NOTICE "error: cdev_add failed, error: %d\n", err);
        unregister_chrdev_region(dev, 1);
        return err;
    }
    printk("<1>Everything is OK\n");
    printk("<1>Major number: %d minor number: %d\n", MAJOR(dev), MINOR(dev));
    return 0;
}

then I add this line to the /etc/udev/udev.rules:
KERNEL=="my_device"        NAME="my_device"

But device /dev/my_device is not created in /dev after loading module to the kernel. 
Why? 

thanks

martin






--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           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