[drivers][ofw] fix ofw_alias_scan() bug (#8908)
* fix ofw_alias_scan() bug * fix tag_len
This commit is contained in:
parent
b421b4e1f4
commit
78bdf67ab2
|
@ -1051,9 +1051,9 @@ rt_err_t ofw_alias_scan(void)
|
||||||
|
|
||||||
rt_ofw_foreach_prop(np, prop)
|
rt_ofw_foreach_prop(np, prop)
|
||||||
{
|
{
|
||||||
int id = 0, rate = 1;
|
int id = 0;
|
||||||
struct alias_info *info;
|
struct alias_info *info;
|
||||||
const char *name = prop->name, *end;
|
const char *name = prop->name, *end, *id_start;
|
||||||
|
|
||||||
/* Maybe the bootloader will set the name, or other nodes reference the aliases */
|
/* Maybe the bootloader will set the name, or other nodes reference the aliases */
|
||||||
if (!rt_strcmp(name, "name") || !rt_strcmp(name, "phandle"))
|
if (!rt_strcmp(name, "name") || !rt_strcmp(name, "phandle"))
|
||||||
|
@ -1066,19 +1066,20 @@ rt_err_t ofw_alias_scan(void)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
end = name + rt_strlen(name) - 1;
|
end = name + rt_strlen(name);
|
||||||
|
|
||||||
while (*end && !(*end >= '0' && *end <= '9') && end > name)
|
while (*(end - 1) && (*(end - 1) >= '0' && *(end - 1) <= '9') && end > name)
|
||||||
{
|
{
|
||||||
--end;
|
--end;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (*end && (*end >= '0' && *end <= '9'))
|
id_start = end;
|
||||||
|
while (*id_start && (*id_start >= '0' && *id_start <= '9'))
|
||||||
{
|
{
|
||||||
id += (*end - '0') * rate;
|
id *= 10;
|
||||||
rate *= 10;
|
id += (*id_start - '0');
|
||||||
|
|
||||||
++end;
|
++id_start;
|
||||||
}
|
}
|
||||||
|
|
||||||
info = rt_malloc(sizeof(*info));
|
info = rt_malloc(sizeof(*info));
|
||||||
|
@ -1093,7 +1094,7 @@ rt_err_t ofw_alias_scan(void)
|
||||||
|
|
||||||
info->id = id;
|
info->id = id;
|
||||||
info->tag = name;
|
info->tag = name;
|
||||||
info->tag_len = end - name - 1;
|
info->tag_len = end - name;
|
||||||
info->np = tmp;
|
info->np = tmp;
|
||||||
|
|
||||||
rt_list_insert_after(&_aliases_nodes, &info->list);
|
rt_list_insert_after(&_aliases_nodes, &info->list);
|
||||||
|
|
Loading…
Reference in New Issue