MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / ofw_alias_scan

Function ofw_alias_scan

components/drivers/ofw/base.c:1044–1102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1042}
1043
1044rt_err_t ofw_alias_scan(void)
1045{
1046 rt_err_t err = RT_EOK;
1047 struct rt_ofw_prop *prop;
1048 struct rt_ofw_node *np = ofw_node_aliases, *tmp;
1049
1050 rt_ofw_foreach_prop(np, prop)
1051 {
1052 int id = 0;
1053 struct alias_info *info;
1054 const char *name = prop->name, *end, *id_start;
1055
1056 /* Maybe the bootloader will set the name, or other nodes reference the aliases */
1057 if (!rt_strcmp(name, "name") || !rt_strcmp(name, "phandle"))
1058 {
1059 continue;
1060 }
1061
1062 if (!(tmp = rt_ofw_find_node_by_path(prop->value)))
1063 {
1064 continue;
1065 }
1066
1067 end = name + rt_strlen(name);
1068
1069 while (*(end - 1) && (*(end - 1) >= '0' && *(end - 1) <= '9') && end > name)
1070 {
1071 --end;
1072 }
1073
1074 id_start = end;
1075 while (*id_start && (*id_start >= '0' && *id_start <= '9'))
1076 {
1077 id *= 10;
1078 id += (*id_start - '0');
1079
1080 ++id_start;
1081 }
1082
1083 info = rt_malloc(sizeof(*info));
1084
1085 if (!info)
1086 {
1087 err = -RT_ENOMEM;
1088 break;
1089 }
1090
1091 rt_list_init(&info->list);
1092
1093 info->id = id;
1094 info->tag = name;
1095 info->tag_len = end - name;
1096 info->np = tmp;
1097
1098 rt_list_insert_after(&_aliases_nodes, &info->list);
1099 }
1100
1101 return err;

Callers 1

rt_fdt_unflattenFunction · 0.85

Calls 6

rt_strcmpFunction · 0.85
rt_ofw_find_node_by_pathFunction · 0.85
rt_strlenFunction · 0.85
rt_mallocFunction · 0.85
rt_list_initFunction · 0.85
rt_list_insert_afterFunction · 0.85

Tested by

no test coverage detected