Only one device can be seen in/proc/devices. Why?
# Include <Linux/module. h>
# Include <Linux/types. h>
# Include <Linux/init. h>
# Include <Linux/fs. h>
# Include <Linux/cdev. h>
# Include <Linux/kdev_t.h>
# Include <Linux/string. h>
# Define device_name "chardev"
# Define device_num 5
Static dev_t devno;
Static int _ init test_init (void)
{
Int ret;
Ret = alloc_chrdev_region (& devno, 0, device_num, device_name );
If (Ret <0)
Goto err;
Err:
Return ret;
}
Static void _ exit test_exit (void)
{
Unregister_chrdev_region (devno, 5 );
}
Module_license ("GPL ");
Module_init (test_init );
Module_exit (test_exit );
Your alloc_chrdev_region (& devno, 0, device_num, device_name); generates five device numbers under a master device number, which is equivalent to sharing one master device number with five similar devices, each device has its own device number, and only the master device number is displayed in/proc/devices!