| 373 | } |
| 374 | |
| 375 | int dtb_node_write_prop(const struct dtb_node *node, const char *propname, int len, |
| 376 | const void *value) |
| 377 | { |
| 378 | struct dtb_property *pp; |
| 379 | struct dtb_property *pp_last = NULL; |
| 380 | struct dtb_property *new; |
| 381 | |
| 382 | if (!dtb_node_active()) |
| 383 | return -ENOSYS; |
| 384 | |
| 385 | if (!node) |
| 386 | return -EINVAL; |
| 387 | |
| 388 | for (pp = node->properties; pp; pp = pp->next) |
| 389 | { |
| 390 | if (strcmp(pp->name, propname) == 0) |
| 391 | { |
| 392 | /* Property exists -> change value */ |
| 393 | pp->value = (void *)value; |
| 394 | pp->size = len; |
| 395 | return 0; |
| 396 | } |
| 397 | pp_last = pp; |
| 398 | } |
| 399 | |
| 400 | if (!pp_last) |
| 401 | return -ENOENT; |
| 402 | |
| 403 | /* Property does not exist -> append new property */ |
| 404 | new = (struct dtb_property *)malloc(sizeof(struct dtb_property)); |
| 405 | if (!new) |
| 406 | return -ENOMEM; |
| 407 | |
| 408 | new->name = strdup(propname); |
| 409 | if (!new->name) |
| 410 | { |
| 411 | free(new); |
| 412 | return -ENOMEM; |
| 413 | } |
| 414 | |
| 415 | new->value = (void *)value; |
| 416 | new->size = len; |
| 417 | new->next = NULL; |
| 418 | |
| 419 | pp_last->next = new; |
| 420 | |
| 421 | return 0; |
| 422 | } |
| 423 | |
| 424 | int dtb_node_write_string(const struct dtb_node *node, const char *propname, const char *value) |
| 425 | { |
no test coverage detected