| 1034 | } |
| 1035 | |
| 1036 | struct rt_ofw_node *rt_fdt_unflatten_single(void *fdt) |
| 1037 | { |
| 1038 | int root_off; |
| 1039 | struct fdt_info *header; |
| 1040 | struct rt_ofw_node *root = RT_NULL; |
| 1041 | |
| 1042 | if (fdt && (root_off = fdt_path_offset(fdt, "/")) >= 0) |
| 1043 | { |
| 1044 | root = rt_calloc(1, sizeof(struct fdt_info) + sizeof(struct rt_ofw_node)); |
| 1045 | } |
| 1046 | |
| 1047 | if (root) |
| 1048 | { |
| 1049 | header = (void *)root + sizeof(struct rt_ofw_node); |
| 1050 | |
| 1051 | rt_strncpy(header->name, "/", sizeof("/")); |
| 1052 | |
| 1053 | header->fdt = fdt; |
| 1054 | |
| 1055 | header->rsvmap = (struct fdt_reserve_entry *)((void *)fdt + fdt_off_mem_rsvmap(fdt)); |
| 1056 | header->rsvmap_nr = fdt_num_mem_rsv(fdt); |
| 1057 | |
| 1058 | if (!fdt_unflatten_single(root, root_off)) |
| 1059 | { |
| 1060 | root->name = (const char *)header; |
| 1061 | } |
| 1062 | else |
| 1063 | { |
| 1064 | rt_ofw_node_destroy(root); |
| 1065 | |
| 1066 | root = RT_NULL; |
| 1067 | } |
| 1068 | } |
| 1069 | |
| 1070 | return root; |
| 1071 | } |
no test coverage detected