关于linux kernel对i2c总线架构设计实现的详细解说
int id;
int status;
if (adap->nr & ~MAX_ID_MASK)
return -EINVAL;
retry:
if (idr_pre_get(&i2c_adapter_idr, GFP_KERNEL) == 0)
return -ENOMEM;
mutex_lock(&core_lock);
/* "above" here means "above or equal to", sigh;
* we need the "equal to" result to force the result
*/
status = idr_get_new_above(&i2c_adapter_idr, adap, adap->nr, &id);
if (status == 0 && id != adap->nr) {
status = -EBUSY;
idr_remove(&i2c_adapter_idr, id);
}
mutex_unlock(&core_lock);
if (status == -EAGAIN)
goto retry;
if (status == 0)
status = i2c_register_adapter(adap);
return status;
}
对比一下就知道差别了,在这里它已经指定好了adapter->nr了.如果分配的id不和指定的相等,便返回错误.
过一步跟踪i2c_register_adapter().代码如下:
static int i2c_register_adapter(struct i2c_adapter *adap)
{
int res = 0, dummy;
mutex_init(&adap->bus_lock);
mutex_init(&adap->clist_lock);
INIT_LIST_HEAD(&adap->clients);
mutex_lock(&core_lock);
/* Add the adapter to the driver core.
* If the parent pointer is not set up,
* we add this adapter to the host bus.
Linux设备驱动之I2C架构分析时间_信息与通信_工程科技_专业资料。i2cI2C 适配器驱动原理分析设备模型建立过程: 设备模型建立过程: 设备模型建立过程 http://chxxxyg...
Linux设备驱动之I2C架构分析Linux设备驱动之I2C架构分析隐藏>> Linux 设备驱动之 I2C 架构分析一:前言 提出的外设总线.I2C 只有两条线,一条串行数据线:SDA,一条...
Linux2.6.25平台下的I2C驱动架构分析_兵器/核科学_工程科技_专业资料。Linux...2.3 用户接口层 设备驱动层为用户接口层,其为用户提供了通过 I2C 总线访问...
linux设备模型之uart驱动架构分析_计算机软件及应用_IT/计算机_专业资料。... 对Linux 设备驱动模型的... 13页 1下载券 Linux设备驱动之I2C架构... 37...
Linux I2C 驱动涉及的知识点还是挺多的,主要分为 Linux I2C 的总线驱动(I2C BUS Driver)和设备驱动(I2C Clients Driver),本文主要关注如何快速地完成一个具体的...
Linux I2C 结构分析 2.1 层次分析 1. I2C Core I2C Core用于维护Linux的I2C...(具体的实现在与I2C控制器相关的I2C adapter中实现),主要应用在I2C设备驱动中。...
Linux设备模型之tty驱动架构分析Linux设备模型之tty驱动架构分析隐藏>> Linux 设备模型之 tty 驱动架构分析一:前言 Tty 这个名称源于电传打字节的简称。在 linux ...
(&s3c24xx_i2c_driver); } 分析 platform_driver_register(&s3c24xx_i2c_...(&drv->driver); } 下图即为 Linux 2.6 中引入的设备驱动模型的结构图 (...
但通常情况是总线上有个带CPU的master,其他设备被master访问。 2 I2C总体架构在2.6的Linux内核中,I2C的驱动架构分为如下三个层次:硬件抽象层、平台依赖层和用户...
.aspx ) 谈到在 linux 系统下编写 I2C 驱动,目前主要有两种方式,一种是把 I2C 设备当作一个普 通的字符设备来处理,另一种是利用 linux I2C 驱动体系结构来...
热门文档