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 ...
随机推荐
- logstash可以考虑在项目中用起来
在用Node.js开发项目的时候,我们常用 log4js 模块来进行日志的记录,可以通过配置 log4js 的 Appenders 将日志输出到Console.File和GELF等不同的地方. log ...
- 1204 中间件以及cookie,session
目录 一 .cookie与session原理 1.cookie 操作 1.1 设置cookie set_cookie 1.2 获取cookie request.COOKIES.get('k1') 1. ...
- HTTP/TCP/IP UDP Socket等区别联系
1.TCP连接 手机能够使用联网功能是因为手机底层实现了TCP/IP协议,可以使手机终端通过无线网络建立TCP连接.TCP协议可以对上层网络提供接口,使上层网络数据的传输建立在“无差别”的网络之上. ...
- 【Java】聚合和组合的区别
组合:部分与整体是与生俱来的,部分的存在依赖于整体.比如人与人的某个器官,人一出生,器官就在,人死亡,器官也就没了意义. 聚合:你与你的电脑(或者其它物品),电脑是属于你的吧,但是你是一出生就拥有了电 ...
- Matplotlib模块的基本使用
一.折线绘图 import pandas as pd import matplotlib.pyplot as plt data = pd.read_csv("F:\\ml\\机器学习\\01 ...
- aiohttp 支持异步的网络请求模块
通常在进行网络数据采集时候我们会用到requests,urllib等模块,但是这些模块在使用中并不支持异步,所以今天我们介绍一个支持异步网络请求的模块aiohttp. 首先我们使用flask简单的搭一 ...
- 什么是 restful 规范?
一种软件架构风格.设计风格,而不是标准,只是提供了一组设计原则和约束条件. 一.协议 API与用户的通信协议,总是使用HTTPs协议. 什么是https协议 二.域名 应该尽量将API部署在专用域名之 ...
- Copy Books
Description Given n books and the i-th book has pages[i] pages. There are k persons to copy these bo ...
- Vue多语言支持
i18n插件实现多语言支持,本文以中英文为例记录一下配置过程. 1.配置 1.1安装:npm install vue-i18n --save 1.2创建中英文配置项文件 src/lang目录下创建以下 ...
- Linux监控系统概览
自从Linux系统诞生之始,监控系统就随之出现. 当然说到监控系统,我们就必须聊到SNMP协议,SNMP分为管理端(NMP)和被管理端. 管理端周期性的到被监控端采集数据,被监控端还需要有权限收集数据 ...