I will paste and anlaysis a small character device driver in this paragraph.
#include <linux/module.h> #include <linux/init.h> #include <linux/fs.h> #include <linux/kernel.h> #include <linux/miscdevice.h> #include <asm/uaccess.h> #include <linux/unistd.h> #define DEVICE_NAME "wordcount2" #define TRUE -1 #define FALSE 0 static unsigned char mem[1024]; static int word_count = 0; static char is_spacewhite(char c) { if(c == ' ' || c == 9 || c == 13 || c == 10) return TRUE; else return FALSE; } static int get_world_count(const char *buf) { int n = 1; int i = 0; char c = ' '; char flag = 0; if(*buf == '