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

Function rt_ofw_append_prop

components/drivers/ofw/base.c:1416–1458  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1414}
1415
1416rt_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
1460struct rt_ofw_node *rt_ofw_parse_phandle(const struct rt_ofw_node *np, const char *phandle_name, int index)
1461{

Callers 1

rt_ofw_append_childFunction · 0.85

Calls 1

rt_mallocFunction · 0.85

Tested by

no test coverage detected