June 2017
Intermediate to advanced
478 pages
13h 14m
English
It's time to draw some threads together by looking at the code for a simple device driver. Here is a device driver named dummy, which creates four devices that are accessed through dev/dummy0 to /dev/dummy3. The complete source code for the driver follows: you will find the code in MELP/chapter_09/dummy-driver:
#include <linux/kernel.h> #include <linux/module.h> #include <linux/init.h> #include <linux/fs.h> #include <linux/device.h>#define DEVICE_NAME "dummy" #define MAJOR_NUM 42 #define NUM_DEVICES 4 static struct class *dummy_class; static int dummy_open(struct inode *inode, struct file *file) { pr_info("%s\n", __func__); return 0; } static int dummy_release(struct inode *inode, struct file *file) { ...Read now
Unlock full access