Dragon Boat Festival Homework 1

As long as the file exists, there will be a unique corresponding inode number, and there will be a struct inode structure accordingly. Opening a device file through open() at the application layer will generate an inode number, and the inode structure of the file can be found through the inode number

 

 

 Find the driver object structure according to the driver object structure pointer corresponding to the file in the inode structure

Find the operation method structure pointer in the driver object structure, define and initialize an operation method structure variable in the driver program, and realize specific functions such as opening and closing, reading and writing, etc.

 

The route of the open function callback to the open operation method in the driver:

open()--->sys_open()--->struct inode structure--->struct cdev structure--->struct file_operations structure--->mycdev_open

Registration and Cancellation Process

static int __init mycdev_init(void)
{ //1. Allocate object space //2. Initialize object //3. Apply for device number //4. Register character device driver object //5. Submit directory up //6. Up





static void __exit mycdev_exit(void)
{ //1. Destroy the device node //2. Release the directory space //3. Log out the character device driver object //4. Release the device number //5. Release the device space }





Submit device node information

Guess you like

Origin blog.csdn.net/weixin_73148834/article/details/131344114