ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

u-boot lists_bind_fdt函数

2022-02-24 12:37:10  阅读:195  来源: 互联网

标签:compat name bind boot driver ret compatible fdt entry


函数位置driver/core/lists.c文件

int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp,
           bool pre_reloc_only)
{
    struct driver *driver = ll_entry_start(struct driver, driver);
    const int n_ents = ll_entry_count(struct driver, driver);
    const struct udevice_id *id;
    struct driver *entry;
    struct udevice *dev;
    bool found = false;
    const char *name, *compat_list, *compat;
    int compat_length, i;
    int result = 0;
    int ret = 0;
//链表添加的父节点是root
    if (devp)
        *devp = NULL;
//获得节点的名称 name = ofnode_get_name(node); log_debug("bind node %s\n", name); //获得节点属性compatible的属性列表指针和长度 compat_list = ofnode_get_property(node, "compatible", &compat_length);
//无compatible属性返回处理 if (!compat_list) { if (compat_length == -FDT_ERR_NOTFOUND) { log_debug("Device '%s' has no compatible string\n", name); return 0; } dm_warn("Device tree error at node '%s'\n", name); return compat_length; } /* * Walk through the compatible string list, attempting to match each * compatible string in order such that we match in order of priority * from the first string to the last. */
//compatible属性匹配
for (i = 0; i < compat_length; i += strlen(compat) + 1) { compat = compat_list + i; log_debug(" - attempt to match compatible string '%s'\n", compat); for (entry = driver; entry != driver + n_ents; entry++) { ret = driver_check_compatible(entry->of_match, &id, compat); if (!ret) break; } if (entry == driver + n_ents) continue; //判断是否预先加载:1,pre_reloc_only为真,直接加载。2,fdt节点属性设置 if (pre_reloc_only) { if (!ofnode_pre_reloc(node) && !(entry->flags & DM_FLAG_PRE_RELOC)) { log_debug("Skipping device pre-relocation\n"); return 0; } } log_debug(" - found match at '%s': '%s' matches '%s'\n", entry->name, entry->of_match->compatible, id->compatible); ret = device_bind_with_driver_data(parent, entry, name, id->data, node, &dev); if (ret == -ENODEV) { log_debug("Driver '%s' refuses to bind\n", entry->name); continue; } if (ret) { dm_warn("Error binding driver '%s': %d\n", entry->name, ret); return log_msg_ret("bind", ret); } else { found = true; if (devp) *devp = dev; } break; } if (!found && !result && ret != -ENODEV) log_debug("No match for node '%s'\n", name); return result; }

 

标签:compat,name,bind,boot,driver,ret,compatible,fdt,entry
来源: https://www.cnblogs.com/liujunhuasd/p/15914863.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有