本文章是我在写驱动代码时候出现的错误积累,在此记录。
错误一:xxx未在这里声明
error: ‘of_match_name’ undeclared here (not in a function)of_match_name = beep_of_mach, //设备树匹配
解决方法:找到出现错误的那一行代码,检查xxx是否写错。
错误二:结构体出错
42:19: error: ‘struct device’ has no member named ‘dev’miscbeep.nd = dev->dev.of_node;
解决方法:结构体出错,都怪这个只能填补
正确的函数名称:
static int miscbeep_probe(struct platform_device *dev)
但是我的函数名称参数是这样的
static int miscbeep_probe(struct device *dev)
害,我还是直接搜索错误中的’struct device’才发现的。建议有这个错误的可以CTRL+F 搜索报错的’xxx’
错误三:解除对不完整类型的指针的引用
41:6: error: dereferencing pointer to incomplete type
filp->private_data = &miscbeep;
^
出现问题的地方:在智能补全的插件下,我是学习了不少的错误
正确的写法:static int miscbeep_open(struct inode *inode, struct file *filp)
解决方法:把后面的struct filp *filp改回struct file *filp
错误四: 缺少;
69:1: error: expected ‘,’ or ‘;’ before ‘static’
static int miscbeep_probe(struct platform_device</