1 打印相关
1.1 printk打印变种
- 打印函数名:%ps和%pS,例:
%ps:gc->set=bgpio_set_set
%pS:gc->set=bgpio_set_set+0x0/0x70,
2 网络相关
2.1 IP地址字符串转__be32
extern __be32 in_aton(const char *str); //很多文件没有引用linux/inet.h,直接声明
__be32 addr = in_aton("192.168.1.1");
得到的addr就可以在内核当成IP地址使用了,比如struct iphdr中的saddr和daddr
2.2 打印数值类型的IP地址
3 模块相关
3.1 uboot给模块传递参数
- uboot带入启动参数
比如参数为:console=ttySAC0,115200 ubi.mtd=3 root=ubi0:rootfs rootfstype=ubifs
- 模块定义参数处理函数
对于ubi模块来说,代码如下:
module_param_call(mtd, ubi_mtd_param_parse, NULL, NULL, 0400);
ubi_mtd_param_parse函数就会处理ubi.mtd=3参数。