@@ -1423,11 +1423,12 @@ int of_phandle_iterator_args(struct of_phandle_iterator *it,
static int __of_parse_phandle_with_args(const struct device_node *np,
const char *list_name,
const char *cells_name,
- int cell_count, int index,
+ int cell_count, unsigned int index,
struct of_phandle_args *out_args)
{
struct of_phandle_iterator it;
- int rc, cur_index = 0;
+ unsigned int cur_index = 0;
+ int rc;
/* Loop over the phandles until all the requested entry is found */
of_for_each_phandle(&it, rc, np, list_name, cells_name, cell_count) {
@@ -1483,13 +1484,11 @@ static int __of_parse_phandle_with_args(const struct device_node *np,
* of_node_put() on it when done.
*/
struct device_node *of_parse_phandle(const struct device_node *np,
- const char *phandle_name, int index)
+ const char *phandle_name,
+ unsigned int index)
{
struct of_phandle_args args;
- if (index < 0)
- return NULL;
-
if (__of_parse_phandle_with_args(np, phandle_name, NULL, 0,
index, &args))
return NULL;
@@ -1531,14 +1530,11 @@ EXPORT_SYMBOL(of_parse_phandle);
* of_parse_phandle_with_args(node3, "list", "#list-cells", 1, &args);
*/
int of_parse_phandle_with_args(const struct device_node *np, const char *list_name,
- const char *cells_name, int index,
+ const char *cells_name, unsigned int index,
struct of_phandle_args *out_args)
{
int cell_count = -1;
- if (index < 0)
- return -EINVAL;
-
/* If cells_name is NULL we assume a cell count of 0 */
if (!cells_name)
cell_count = 0;
@@ -1593,7 +1589,8 @@ EXPORT_SYMBOL(of_parse_phandle_with_args);
int of_parse_phandle_with_args_map(const struct device_node *np,
const char *list_name,
const char *stem_name,
- int index, struct of_phandle_args *out_args)
+ unsigned int index,
+ struct of_phandle_args *out_args)
{
char *cells_name, *map_name = NULL, *mask_name = NULL;
char *pass_name = NULL;
@@ -1606,9 +1603,6 @@ int of_parse_phandle_with_args_map(const struct device_node *np,
int i, ret, map_len, match;
u32 list_size, new_size;
- if (index < 0)
- return -EINVAL;
-
cells_name = kasprintf(GFP_KERNEL, "#%s-cells", stem_name);
if (!cells_name)
return -ENOMEM;
@@ -1764,10 +1758,9 @@ EXPORT_SYMBOL(of_parse_phandle_with_args_map);
*/
int of_parse_phandle_with_fixed_args(const struct device_node *np,
const char *list_name, int cell_count,
- int index, struct of_phandle_args *out_args)
+ unsigned int index,
+ struct of_phandle_args *out_args)
{
- if (index < 0)
- return -EINVAL;
return __of_parse_phandle_with_args(np, list_name, NULL, cell_count,
index, out_args);
}
@@ -366,15 +366,15 @@ extern int of_modalias_node(struct device_node *node, char *modalias, int len);
extern void of_print_phandle_args(const char *msg, const struct of_phandle_args *args);
extern struct device_node *of_parse_phandle(const struct device_node *np,
const char *phandle_name,
- int index);
+ unsigned int index);
extern int of_parse_phandle_with_args(const struct device_node *np,
- const char *list_name, const char *cells_name, int index,
+ const char *list_name, const char *cells_name, unsigned int index,
struct of_phandle_args *out_args);
extern int of_parse_phandle_with_args_map(const struct device_node *np,
- const char *list_name, const char *stem_name, int index,
+ const char *list_name, const char *stem_name, unsigned int index,
struct of_phandle_args *out_args);
extern int of_parse_phandle_with_fixed_args(const struct device_node *np,
- const char *list_name, int cells_count, int index,
+ const char *list_name, int cells_count, unsigned int index,
struct of_phandle_args *out_args);
extern int of_count_phandle_with_args(const struct device_node *np,
const char *list_name, const char *cells_name);
@@ -867,7 +867,7 @@ static inline int of_property_read_string_helper(const struct device_node *np,
static inline struct device_node *of_parse_phandle(const struct device_node *np,
const char *phandle_name,
- int index)
+ unsigned int index)
{
return NULL;
}
@@ -875,7 +875,7 @@ static inline struct device_node *of_parse_phandle(const struct device_node *np,
static inline int of_parse_phandle_with_args(const struct device_node *np,
const char *list_name,
const char *cells_name,
- int index,
+ unsigned int index,
struct of_phandle_args *out_args)
{
return -ENOSYS;
@@ -884,14 +884,14 @@ static inline int of_parse_phandle_with_args(const struct device_node *np,
static inline int of_parse_phandle_with_args_map(const struct device_node *np,
const char *list_name,
const char *stem_name,
- int index,
+ unsigned int index,
struct of_phandle_args *out_args)
{
return -ENOSYS;
}
static inline int of_parse_phandle_with_fixed_args(const struct device_node *np,
- const char *list_name, int cells_count, int index,
+ const char *list_name, int cells_count, unsigned int index,
struct of_phandle_args *out_args)
{
return -ENOSYS;
Since commit 2021bd01ffcc ("of: Remove counting special case from __of_parse_phandle_with_args()"), the index is >=0, thus convert the parameter to unsigned of the of_parse_phandle() and all its variants. This allows us to drop the check for negative index values. Suggested-by: Rob Herring <robh@kernel.org> Signed-off-by: Michael Walle <michael@walle.cc> --- changes since v1: - just change the index to unsigned int, the static inline change is now an own patch drivers/of/base.c | 27 ++++++++++----------------- include/linux/of.h | 16 ++++++++-------- 2 files changed, 18 insertions(+), 25 deletions(-)