diff options
Diffstat (limited to 'drivers/of')
-rw-r--r-- | drivers/of/base.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c index cf04d4dd4a53..cd17092b82bd 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c | |||
@@ -499,8 +499,8 @@ EXPORT_SYMBOL_GPL(of_modalias_node); | |||
499 | * @list_name: property name that contains a list | 499 | * @list_name: property name that contains a list |
500 | * @cells_name: property name that specifies phandles' arguments count | 500 | * @cells_name: property name that specifies phandles' arguments count |
501 | * @index: index of a phandle to parse out | 501 | * @index: index of a phandle to parse out |
502 | * @out_node: pointer to device_node struct pointer (will be filled) | 502 | * @out_node: optional pointer to device_node struct pointer (will be filled) |
503 | * @out_args: pointer to arguments pointer (will be filled) | 503 | * @out_args: optional pointer to arguments pointer (will be filled) |
504 | * | 504 | * |
505 | * This function is useful to parse lists of phandles and their arguments. | 505 | * This function is useful to parse lists of phandles and their arguments. |
506 | * Returns 0 on success and fills out_node and out_args, on error returns | 506 | * Returns 0 on success and fills out_node and out_args, on error returns |
@@ -534,7 +534,7 @@ int of_parse_phandles_with_args(struct device_node *np, const char *list_name, | |||
534 | int size; | 534 | int size; |
535 | int cur_index = 0; | 535 | int cur_index = 0; |
536 | struct device_node *node = NULL; | 536 | struct device_node *node = NULL; |
537 | const void *args; | 537 | const void *args = NULL; |
538 | 538 | ||
539 | list = of_get_property(np, list_name, &size); | 539 | list = of_get_property(np, list_name, &size); |
540 | if (!list) { | 540 | if (!list) { |
@@ -580,16 +580,26 @@ next: | |||
580 | 580 | ||
581 | of_node_put(node); | 581 | of_node_put(node); |
582 | node = NULL; | 582 | node = NULL; |
583 | args = NULL; | ||
583 | cur_index++; | 584 | cur_index++; |
584 | } | 585 | } |
585 | 586 | ||
586 | if (!node) { | 587 | if (!node) { |
587 | ret = -ENOENT; | 588 | /* |
589 | * args w/o node indicates that the loop above has stopped at | ||
590 | * the 'hole' cell. Report this differently. | ||
591 | */ | ||
592 | if (args) | ||
593 | ret = -EEXIST; | ||
594 | else | ||
595 | ret = -ENOENT; | ||
588 | goto err0; | 596 | goto err0; |
589 | } | 597 | } |
590 | 598 | ||
591 | *out_node = node; | 599 | if (out_node) |
592 | *out_args = args; | 600 | *out_node = node; |
601 | if (out_args) | ||
602 | *out_args = args; | ||
593 | 603 | ||
594 | return 0; | 604 | return 0; |
595 | err1: | 605 | err1: |