kernel component.c analyze

本文详细介绍了Linux内核中Component和Master机制在DRM子系统中的应用,重点讲解了component.c中的关键数据结构、匹配结构体以及相关函数的工作原理,如组件链表、主设备链表、匹配过程和绑定操作,阐述了如何通过这些机制建立主设备与从设备的关联。
摘要由CSDN通过智能技术生成

       在kernel中,component 和 master机制用来管理一个主设备,多个辅设备的subsystem,目前最典型的应用在DRM subsystem中。该机制的相关代码在drivers/base/component.c中, https://github.com/torvalds/linux/blob/master/drivers/base/component.c中有最新关于改文件的最新的详细的介绍。

  • component.c 中声明了3个静态全局变量:

       static DEFINE_MUTEX(component_mutex);
       static LIST_HEAD(component_list);
       static LIST_HEAD(masters); 

其中, 互斥锁component_mutex用于保证资源的互斥访问。component_list为双向链表头,最终kernel中所有的component会形成一个双向链表,而component_list为这个双向链表的表头。masters类似,最终kernel中所有的master会形成一个双向链表,而masters即为这个双向链表的表头。

  • match 结构体:

struct component_match {
    size_t alloc;
    size_t num;
    struct component_match_array *compare;
};

struct component_match_array {
    void *data;
    int (*compa

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值