| 1313 | } |
| 1314 | |
| 1315 | rt_err_t rt_ofw_map_id(struct rt_ofw_node *np, rt_uint32_t id, const char *map_name, const char *map_mask_name, |
| 1316 | struct rt_ofw_node **ref_np, rt_uint32_t *out_id) |
| 1317 | { |
| 1318 | rt_err_t err; |
| 1319 | |
| 1320 | if (np && map_name && (ref_np || out_id)) |
| 1321 | { |
| 1322 | rt_ssize_t map_len; |
| 1323 | const fdt32_t *map = rt_ofw_prop_read_raw(np, map_name, &map_len); |
| 1324 | |
| 1325 | if (!map) |
| 1326 | { |
| 1327 | if (ref_np) |
| 1328 | { |
| 1329 | err = -RT_EEMPTY; |
| 1330 | } |
| 1331 | else |
| 1332 | { |
| 1333 | *out_id = id; |
| 1334 | } |
| 1335 | |
| 1336 | err = RT_EOK; |
| 1337 | } |
| 1338 | else if (!map_len || map_len % (4 * sizeof(*map))) |
| 1339 | { |
| 1340 | LOG_E("%s: Invalid %s length = %u", np->full_name, map_name, map_len); |
| 1341 | |
| 1342 | err = -RT_EINVAL; |
| 1343 | } |
| 1344 | else |
| 1345 | { |
| 1346 | err = ofw_map_id(np, id, map_name, map_mask_name, map, map_len, ref_np, out_id); |
| 1347 | } |
| 1348 | } |
| 1349 | else |
| 1350 | { |
| 1351 | err = -RT_EINVAL; |
| 1352 | } |
| 1353 | |
| 1354 | return err; |
| 1355 | } |
| 1356 | |
| 1357 | struct rt_ofw_node *rt_ofw_append_child(struct rt_ofw_node *parent, const char *full_name) |
| 1358 | { |
no test coverage detected