linux内核中的regmap是如何初始化的?
1. 内核版本
5.2.0
2. 请看devm_regmap_init_i2c (include/linux/regmap.h)
/**
* devm_regmap_init_i2c() - Initialise managed register map
*
* @i2c: Device that will be interacted with
* @config: Configuration for register map
*
* The return value will be an ERR_PTR() on error or a valid pointer
* to a struct regmap. The regmap will be automatically freed by the
* device management code.
*/
#define devm_regmap_init_i2c(i2c, config) \
__regmap_lockdep_wrapper(__devm_regmap_init_i2c, #config, \
i2c, config)
3. 看看__regmap_lockdep_wrapper
/*
* Wrapper for regmap_init macros to include a unique lockdep key and name
* for each call. No-op if CONFIG_LOCKDEP is not set.
*
* @fn: Real function to call (in the form __[*_]regmap_init[_*])
* @name: Config variable name (#config in the calling macro)
**/#define __regmap_lockdep_wrapper(fn, name, ...) \
( \
({ \
static struct lock_class_key _key; \
fn(__VA_ARGS__, &_key, \
KBUILD_BASENAME ":" \
__stringify(__LINE__) ":" \
"(" name ")->lock"); \
}) \
)
4. KBUILD_BASENAME的定义在哪里?
在编译时由编译选项-D提供,如此处为:
-DKBUILD_BASENAME='"regmap_i2c"'
5. 展开
假设__LINE__等于99行,那么
( \
({ \
static struct lock_class_key _key; \
__devm_regmap_init_i2c(__VA_ARGS__, &_key, \
"regmap_i2c:99:config->lock"); \
}) \
)
6. 看看__devm_regmap_init_i2c的执行路径
__devm_regmap_init_i2c
-> regmap_get_i2c_bus
-> __devm_regmap_init
-> devres_alloc
-> __regmap_init
7. 重点分析__regmap_init
map->dev = dev;
map->bus = bus;
map->bus_context = bus_context;
map->max_register = config->max_register;
map->wr_table = config->wr_table;
map->rd_table = config->rd_table;
map->volatile_table = config->volatile_table;
map->precious_table = config->precious_table;
map->wr_noinc_table = config->wr_noinc_table;
map->rd_noinc_table = config->rd_noinc_table;
map->writeable_reg = config->writeable_reg;
map->readable_reg = config->readable_reg;
map->volatile_reg = config->volatile_reg;
map->precious_reg = config->precious_reg;
map->writeable_noinc_reg = config->writeable_noinc_reg;
map->readable_noinc_reg = config->readable_noinc_reg;
map->cache_type = config->cache_type;
总结:
做的主要工作即为填充map结构体
linux内核中的regmap是如何初始化的?的更多相关文章
- linux内核中网络文件系统的注册初始化
针对内核3.9 系统开启时,会使用init/main.c,然后再里面调用kernel_init(),在里面会再调用do_basic_setup(),调用do_initcalls(),调用do_one_ ...
- Linux 内核中的 Device Mapper 机制
本文结合具体代码对 Linux 内核中的 device mapper 映射机制进行了介绍.Device mapper 是 Linux 2.6 内核中提供的一种从逻辑设备到物理设备的映射框架机制,在该机 ...
- 向linux内核中添加外部中断驱动模块
本文主要介绍外部中断驱动模块的编写,包括:1.linux模块的框架及混杂设备的注册.卸载.操作函数集.2.中断的申请及释放.3.等待队列的使用.4.工作队列的使用.5.定时器的使用.6.向linux内 ...
- Linux内核中双向链表的经典实现
概要 前面一章"介绍双向链表并给出了C/C++/Java三种实现",本章继续对双向链表进行探讨,介绍的内容是Linux内核中双向链表的经典实现和用法.其中,也会涉及到Linux内核 ...
- Linux内核中的GPIO系统之(3):pin controller driver代码分析
一.前言 对于一个嵌入式软件工程师,我们的软件模块经常和硬件打交道,pin control subsystem也不例外,被它驱动的硬件叫做pin controller(一般ARM soc的datash ...
- Linux内核中流量控制
linux内核中提供了流量控制的相关处理功能,相关代码在net/sched目录下:而应用层上的控制是通过iproute2软件包中的tc来实现, tc和sched的关系就好象iptables和netfi ...
- Linux内核中SPI/I2c子系统剖析
Linux内核中,SPI和I2C两个子系统的软件架构是一致的,且Linux内核的驱动模型都以bus,driver,device三种抽象对象为基本元素构建起来.下文的分析将主要用这三种抽象对象的创建过程 ...
- 【转】 Linux内核中读写文件数据的方法--不错
原文网址:http://blog.csdn.net/tommy_wxie/article/details/8193954 Linux内核中读写文件数据的方法 有时候需要在Linuxkernel--大 ...
- Linux内核中链表实现
关于双链表实现,一般教科书上定义一个双向链表节点的方法如下: struct list_node{ stuct list_node *pre; stuct list_node *next; ElemTy ...
随机推荐
- 解决windows 1903 alt + tab 切换卡顿
右击此电脑图标 选择管理 服务和应用程序 服务 禁用system interface foundation service
- linux内核构造skb发包-----raw、tcp网络编程
1. 内核raw发包 #include <linux/init.h>#include <linux/module.h> #include <linux/kernel.h& ...
- Sublime Text 解决 Unable to download XXX 问题
Sublime Text 安装插件报错: Package Control Unable to download XXX. Please view the console for more detail ...
- python在算法题中判断输入结束(EOF)
有些算法题是这样要求的,一行输入一行数据,然后没有规定我要输入多少行,你要自行判断文件结束EOF,否则是会runtime error的,因为oj内部都是用文件来进行读写的. 例如a+b,每一行输入a ...
- Python读excel——xlrd
Python读excel——xlrd Python读取Excel表格,相比xlwt来说,xlrd提供的接口比较多,但过程也有几个比较麻烦的问题,比如读取日期.读合并单元格内容.下面先看看基本的操作: ...
- 7 html-webpack-plugin的两个基本作用
html-webpack-plugin的作用: 1.在内存中根据我们的index模板页面,生成一个内存里面的首页 2.当使用html-webpack-plugin之后,我们不再需要手动处理bundle ...
- Vue中img的src属性绑定
正确:<img :src=" 'files/'+value.src "> 或 <img :src="value.src">错误:< ...
- python 虚拟环境相关命令
1.总是记不住一些关于创建虚拟环境得命令,特在自己得博客里记录一下自己常用得命令: virtualenv -p C:\Python36\python D:\virtual\Envs\AssetScan ...
- TDOA Delayed Tx 实现以及验证
在博文:https://www.cnblogs.com/tuzhuke/p/11638221.html 中描述了delayed tx实现方法,这里贴出全部delayed tx 代码以及对应验证代码 1 ...
- Vue动态创建注册component的实例代码
https://segmentfault.com/a/1190000015698278