Linux Device Driver 3th 中的一些坑
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 中的一些坑的更多相关文章
- Linux Device Driver 学习(1)
Linux Device Driver 学习(1) 一.搭建虚拟机开发环境 1.选择虚拟机VirtualBox,官网下载.deb包安装: VirtualBox Linux 5.1.6 下载fedora ...
- linux device driver —— 环形缓冲区的实现
还是没有接触到怎么控制硬件,但是在书里看到了一个挺巧妙的环形缓冲区实现. 此环形缓冲区实际为一个大小为bufsize的一维数组,有一个rp的读指针,一个wp的写指针. 在数据满时写进程会等待读进程读取 ...
- 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 ...
- Linux Device Driver && Device File
catalog . 设备驱动程序简介 . I/O体系结构 . 访问设备 . 与文件系统关联 . 字符设备操作 . 块设备操作 . 资源分配 . 总线系统 1. 设备驱动程序简介 设备驱动程序是内核的关 ...
- How to learn linux device driver
To learn device driver development, like any other new knowledge, the bestapproach for me is to lear ...
- linux device driver —— ioctl
实现了应用程序和设备驱动通过ioctl通信.还是对设备驱动没什么感觉,贴一下代码吧. 在Ubuntu 16.04 64bit中测试通过 ioctldemo.c #include <linux/m ...
- <<linux device driver,third edition>> Chapter 4:Debugging Techniques
Debugging by Printing printk lets you classify messages accoring to their severity by associating di ...
- <<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 ...
- linux device driver —— 字符设备
现在对linux设备驱动还没有什么认识,跟着书上敲了一个字符驱动,这里把代码贴一下. 测试环境是 Ubuntu 16.04 64bit 驱动程序: #include <linux/fs.h> ...
随机推荐
- 掌握C++基础
以下是笔者在ubuntu系统下编译运行通过的一些反应c++基础特性的例子,包括类,结构体,构造函数,析构函数,函数的重载,this指针,类的继承,虚函数,函数的覆盖和隐藏等.(由于格式问题代码中的乱码 ...
- C#隐私信息(银行账户,身份证号码,名字)中间部分特殊字符替换(*)
最近做到一个关于银行的一个功能模块,需要将隐私信息银行账号中间部分用*代替,于是写下了,如下代码: /// <summary> /// 将传入的字符串中间部分字符替换成特殊字符 /// & ...
- mysql左联右联内联
在MySQL中由于性能的关系,常常要将子查询(Sub-Queries)用连接(join)来却而代之,能够更好地使用表中索引提高查询效率. 下面介绍各种join的使用,先上图: 我们MySQL常用的为左 ...
- Android中的音频处理------SoundPool,MediaRecorder,MediaPlayer以及RingStone总结
用Soundpool可以播一些短的反应速度要求高的声音, 比如游戏中的爆破声, 而Mediaplayer适合播放长点的. MediaRecorder主要用来录音. SoundPool载入音乐文件使用了 ...
- Android网络框架Volley(实战篇)
之前讲了ym—— Android网络框架Volley(体验篇),大家应该了解了volley的使用,接下来我们要看看如何把volley使用到实战项目里面,我们先考虑下一些问题: 从上一篇来看 mQu ...
- poj3373
其实这道题只告诉了一个事当出现多个满足答案约束条件是,我们可以求一个再求一个,不要一下子全求完前两个条件怎么弄之前已经做过类似的了于是我们可以用记忆化搜索找出最小差异然后配合最小差异来剪枝,搜索出最小 ...
- 网络流CodeForces. Original 589F:Gourmet and Banquet
A gourmet came into the banquet hall, where the cooks suggested n dishes for guests. The gourmet kno ...
- Unity之Avatar原理
今天花了一些时间理了理Unity的动画系统. 之前给不同模型配动画时没怎么在意,只知道用Avatar可以让一个模型使用另一个模型的动画.由于用的基本上都是人物模型,基本上没出现什么错误. 不过在用到异 ...
- msql修改字符
我申请了一个jsp空间,把数据库传上去,编码如下mysql> show variables like '%char%';+--------------------------+--------- ...
- [git] git 的基本认知
版本管理 ( Version Control ) 版本管理系统是一个记录文件变更的系统,让你在一段时间后可以恢复指定版本的文件.版本管理系统大致可分为三类:独立的本地版本管理系统.中心化版本管理系统. ...