diff options
author | Anton Vorontsov <avorontsov@ru.mvista.com> | 2008-12-05 03:15:46 -0500 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2008-12-20 22:21:14 -0500 |
commit | 7736a3db98bed028d0e5235f8958a730acfd822e (patch) | |
tree | 27ab46e431b71294c24dbbf721bdbc581f977f14 /drivers/of | |
parent | c1bb7c6d04ebdf48998649100c5267a9139debf5 (diff) |
of: of_parse_phandles_with_args() learns to differentiate 'hole' cells
Given this list (contains three gpio specifiers, one of which is a hole):
gpios = <&phandle1 1 2 3
0 /* a hole */
&phandle2 4 5 6>;
of_parse_phandles_with_args() would report -ENOENT for the `hole'
specifier item, the same error value is used to report the end of the
list, for example.
Sometimes we want to differentiate holes from real errors -- for
example when we want to count all the [syntax correct] specifiers.
With this patch of_parse_phandles_with_args() will report -EEXITS when
somebody requested to parse a hole.
Also, make the out_{node,args} arguments optional, when counting we
don't really need the out values.
Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
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: |