第六章 第一个Linux驱动程序:统计单词个数

本章是第一个linux驱动程序,统计单词个数。
编写linux驱动程序的步骤,步骤如下:

1建立linux驱动骨架。

Module_init 和module_exit宏制定

2注册和注销设备文件

Misc_register mics_deregister

3.指定驱动相关信息

Module_author module_license module_alias module_description

4.制定回调函数

5.编写业务逻辑

6.编写makefile文件

7.编译linux驱动程序

8.安装和卸载linux驱动

#include <stdio.h>
/* count lines in input */
main()
{
int c, nl;
nl = 0;
while ((c = getchar()) != EOF)
if (c == '\n')
++nl;
printf("%d\n", nl);
}

posted @ 2016-06-05 19:41  软件1311班47  阅读(82)  评论(0编辑  收藏  举报