| 1414 | } |
| 1415 | |
| 1416 | rt_err_t rt_ofw_append_prop(struct rt_ofw_node *np, const char *name, int length, void *value) |
| 1417 | { |
| 1418 | rt_err_t err = RT_EOK; |
| 1419 | |
| 1420 | if (np && name && ((length && value) || (!length && !value))) |
| 1421 | { |
| 1422 | struct rt_ofw_prop *prop = rt_malloc(sizeof(*prop)), *last_prop; |
| 1423 | |
| 1424 | if (prop) |
| 1425 | { |
| 1426 | prop->name = name; |
| 1427 | prop->length = length; |
| 1428 | prop->value = value; |
| 1429 | prop->next = RT_NULL; |
| 1430 | |
| 1431 | if (np->props) |
| 1432 | { |
| 1433 | rt_ofw_foreach_prop(np, last_prop) |
| 1434 | { |
| 1435 | if (!last_prop->next) |
| 1436 | { |
| 1437 | last_prop->next = prop; |
| 1438 | break; |
| 1439 | } |
| 1440 | } |
| 1441 | } |
| 1442 | else |
| 1443 | { |
| 1444 | np->props = prop; |
| 1445 | } |
| 1446 | } |
| 1447 | else |
| 1448 | { |
| 1449 | err = -RT_ENOMEM; |
| 1450 | } |
| 1451 | } |
| 1452 | else |
| 1453 | { |
| 1454 | err = -RT_EINVAL; |
| 1455 | } |
| 1456 | |
| 1457 | return err; |
| 1458 | } |
| 1459 | |
| 1460 | struct rt_ofw_node *rt_ofw_parse_phandle(const struct rt_ofw_node *np, const char *phandle_name, int index) |
| 1461 | { |
no test coverage detected