linux设备驱动第三版由于年代比较久远,有很多东西已过时。开一贴记录自己发现的一些问题。


4.3.1.4. seq_file接口

此节最后提到用

struct proc_dir_entry* 
create_proc_entry(const char *name, mode_t *mode, struct proc_dir_entry *parent);

在/proc中创建实际的文件

此函数已过时,用以下函数替代:

#include <linux/proc_fs.h>
struct proc_dir_entry*
proc_create(const char *name, umode_t mode, struct proc_dir_entry *parent, const struct file_operations *proc_fops);

5.3.1. Linux旗标实现

此节中对于镖旗semaphore的初始化提到了

void sema_init(struct semaphore *sem, int val);
DECLARE_MUTEX(name) DECLARE_MUTEX_LOCKED(name);
void init_MUTEX(struct semaphore *sem);
void init_MUTEX_LOCKED(struct semaphore *sem);

这几个方法,但是在我的Ubuntu 16.04(4.4.0-47-generic)的linux/semaphore.h中只有

DEFINE_SEMAPHORE(name)
__SEMAPHORE_INITIALIZER(name, n)
void sema_init(struct semaphore *sem, int val)

这三个初始化的方法定义,没有查到具体的文献,但是书中提到的那些初始化方法在一些linux源码网站也只能在2.x版本的源码中能搜索到。


6.1. ioctl接口

此节中讲到驱动程序使用的ioctl方法定义为

int (*ioctl) (struction inode, struc file *filp, unsigned int cmd, unsigned long arg);

此方法为file_operations结构体里的一个函数指针,已过时
用以下函数替代:

#include <linux/fs.h>
long (*unlocked_ioctl) (struct file *filp, unsigned int cmd, unsigned long arg);
long (*compat_ioctl) (struct file *filp, unsigned int cmd, unsigned long arg);

详见What is the difference between ioctl(), unlocked_ioctl() and compat_ioctl()?


Linux Device Driver 3th 中的一些坑的更多相关文章

  1. Linux Device Driver 学习(1)

    Linux Device Driver 学习(1) 一.搭建虚拟机开发环境 1.选择虚拟机VirtualBox,官网下载.deb包安装: VirtualBox Linux 5.1.6 下载fedora ...

  2. linux device driver —— 环形缓冲区的实现

    还是没有接触到怎么控制硬件,但是在书里看到了一个挺巧妙的环形缓冲区实现. 此环形缓冲区实际为一个大小为bufsize的一维数组,有一个rp的读指针,一个wp的写指针. 在数据满时写进程会等待读进程读取 ...

  3. how to write your first linux device driver

    how to write your first linux device driver 0. environment-ubuntu 1804 64bit 1. apt-get install linu ...

  4. Linux Device Driver && Device File

    catalog . 设备驱动程序简介 . I/O体系结构 . 访问设备 . 与文件系统关联 . 字符设备操作 . 块设备操作 . 资源分配 . 总线系统 1. 设备驱动程序简介 设备驱动程序是内核的关 ...

  5. How to learn linux device driver

    To learn device driver development, like any other new knowledge, the bestapproach for me is to lear ...

  6. linux device driver —— ioctl

    实现了应用程序和设备驱动通过ioctl通信.还是对设备驱动没什么感觉,贴一下代码吧. 在Ubuntu 16.04 64bit中测试通过 ioctldemo.c #include <linux/m ...

  7. <<linux device driver,third edition>> Chapter 4:Debugging Techniques

    Debugging by Printing printk lets you classify messages accoring to their severity by associating di ...

  8. <<linux device driver,third edition>> Chapter 3:Char Drivers

    The Internal Representation of Device Numbers Within the kernel,the dev_t type(defined in linux/type ...

  9. linux device driver —— 字符设备

    现在对linux设备驱动还没有什么认识,跟着书上敲了一个字符驱动,这里把代码贴一下. 测试环境是 Ubuntu 16.04 64bit 驱动程序: #include <linux/fs.h> ...

随机推荐

  1. 【C语言】重定向和文件

    重定向和文件 一.相关基础知识 重定向:在计算机领域,重定向是大多数命令行解释器所具有的功能,包括各种可以将标准流重定向用户规定地点的Unix shells. 输入重定向:可以使程序能够使用文件代替键 ...

  2. Makefile的简单例子

    1.生成test可执行文件,源文件有prog.c prog.h cord.h test:prog.o code.o gcc -o test prog.o code.o prog.o:prog.c pr ...

  3. WCF SOAP

    WCF SOAP服务端解析 ASP.NET Core中间件(Middleware)进阶学习实现SOAP 解析. 本篇将介绍实现ASP.NET Core SOAP服务端解析,而不是ASP.NET Cor ...

  4. 手写js面向对象选项卡插件

    <!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8&qu ...

  5. bzoj 2002: [Hnoi2010]Bounce 弹飞绵羊 動態樹

    2002: [Hnoi2010]Bounce 弹飞绵羊 Time Limit: 10 Sec  Memory Limit: 259 MBSubmit: 4055  Solved: 2172[Submi ...

  6. Keil 程序调试窗口

    上一讲中我们学习了几种常用的程序调试方法,这一讲中将介绍Keil提供各种窗口如输出窗口.观察窗口.存储器窗口.反汇编窗口.串行窗口等的用途,以及这些窗口的使用方法,并通过实例介绍这些窗口在调试中的使用 ...

  7. C语言头文件的作用

    C99中规定, 所有顶层的默认存储类标志符都是extern ! 头文件中声明的函数,默认都是extern前缀.但是为了我们程序员方便,我们采取下面的手段: 我个人认为是extern催生了头文件的诞生. ...

  8. 嵌入式C语言头文件的建立与使用

    如何正确编写 C 语言头文件和与之相关联的 c 源程序文件,这首先就要了解它们的各自功能. 要理解 C 文件与头文件(即.h)有什么不同之处,首先需要弄明白编译器的工作过程. 一般说来编译器会做以下几 ...

  9. 51,PIC,AVR单片机它们的优点缺点都有哪些?

    我有幸接触了几款单片机,并用它们做了一些项目.现在想做个小总结,谈一下自己用各种单片机的感受.仅是个人意见,仁者见仁智者见智. 传统51,我想我就不多说了,适合菜鸟入门,容易上手,价格一般(从性价比方 ...

  10. 一起啃PRML - Preface 前言

    一起啃PRML - 前言 Preface @copyright 转载请注明出处 http://www.cnblogs.com/chxer/ PRML,Pattern Recognition and M ...