摘要: klist.h #ifndef _KLIST_H_ #define _KLIST_H_ struct list_head { struct list_head *next, *prev; }; #define LIST_HEAD_INIT(name) { &(name), &(name) } #de 阅读全文
posted @ 2020-01-09 14:41 耶 阅读(187) 评论(0) 推荐(0)
摘要: #include <linux/module.h>#include <linux/init.h>#include <linux/platform_device.h>#include <linux/gpio.h>#include <linux/delay.h>#include <linux/regul 阅读全文
posted @ 2020-01-09 09:19 耶 阅读(233) 评论(0) 推荐(0)
摘要: 从内核中导出信息到用户空间有很多方法,今天介绍PROC文件系统。 proc_create函数会创建一个PROC entry,用户可以通过对文件系统中的该文件,和内核进行数据的交互。 典型应用:input.c 、misc.c 系统注册input设备(input_register_device),并将设 阅读全文
posted @ 2019-12-20 09:58 耶 阅读(1184) 评论(0) 推荐(0)
摘要: int_range.h #ifndef _INT_RANGE_H_ #define _INT_RANGE_H_ #include "file_reader.h" #include "buffer.h" #include "limits.h" #include "string.h" #ifdef __ 阅读全文
posted @ 2019-12-10 16:11 耶 阅读(131) 评论(0) 推荐(0)
摘要: 文件打开、关闭的统一管理。 打开文件 —— 处理文件 —— 关闭文件。 那么文件访问的结构体里必须包含文件名、处理方法。这次我们多加一个成员 —— 访问模式。于是 file_reader.h #ifndef _FILE_READER_H_ #define _FILE_READER_H_ #inclu 阅读全文
posted @ 2019-12-10 15:45 耶 阅读(155) 评论(0) 推荐(0)
摘要: test.c #include <stdio.h> #include <stdlib.h> #include <string.h> #include <limits.h> int main(int argc, char const *argv[]) { char *buf = NULL; int f 阅读全文
posted @ 2019-12-10 00:10 耶 阅读(153) 评论(0) 推荐(0)
摘要: 上一节file_reader.c中: int ret = processor(fp); 返回的处理结果是int型的值,如果需要返回非int值怎么办? typedef struct FileReaderContext{ const char *pFname; void (* const process 阅读全文
posted @ 2019-12-09 18:35 耶 阅读(137) 评论(0) 推荐(0)
摘要: range.h #ifndef _RANGE_H_#define _RANGE_H_ #ifdef __cplusplusextern "C" {#endif int range(const char *pFname); #ifdef __cplusplus}#endif #endif range. 阅读全文
posted @ 2019-12-09 17:11 耶 阅读(142) 评论(0) 推荐(0)
摘要: range.h #ifndef _RANGE_H_#define _RANGE_H_ #ifdef __cplusplusextern "C" {#endif int range(const char *pFname); #ifdef __cplusplus}#endif #endif range. 阅读全文
posted @ 2019-12-09 16:15 耶 阅读(148) 评论(0) 推荐(0)
摘要: cdplayer.h #ifndef _CDPLAYER_H_#define _CDPLAYER_H_ #ifdef __cplusplusextern "C" {#endif typedef struct State { const struct State *(* const stop)(con 阅读全文
posted @ 2019-12-09 10:56 耶 阅读(183) 评论(0) 推荐(0)