| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359 | 
							- From 66a8f7f04979f4ad739085f01d99c8caf620b4f5 Mon Sep 17 00:00:00 2001
 
- From: Michael Walle <[email protected]>
 
- Date: Tue, 18 Jan 2022 18:35:02 +0100
 
- Subject: [PATCH] of: base: make small of_parse_phandle() variants static
 
-  inline
 
- Make all the smaller variants of the of_parse_phandle() static inline.
 
- This also let us remove the empty function stubs if CONFIG_OF is not
 
- defined.
 
- Suggested-by: Rob Herring <[email protected]>
 
- Signed-off-by: Michael Walle <[email protected]>
 
- [robh: move index < 0 check into __of_parse_phandle_with_args]
 
- Signed-off-by: Rob Herring <[email protected]>
 
- Link: https://lore.kernel.org/r/[email protected]
 
- ---
 
-  drivers/of/base.c  | 131 +++------------------------------------
 
-  include/linux/of.h | 148 ++++++++++++++++++++++++++++++++++++---------
 
-  2 files changed, 129 insertions(+), 150 deletions(-)
 
- --- a/drivers/of/base.c
 
- +++ b/drivers/of/base.c
 
- @@ -1371,15 +1371,18 @@ int of_phandle_iterator_args(struct of_p
 
-  	return count;
 
-  }
 
-  
 
- -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,
 
- -					struct of_phandle_args *out_args)
 
- +int __of_parse_phandle_with_args(const struct device_node *np,
 
- +				 const char *list_name,
 
- +				 const char *cells_name,
 
- +				 int cell_count, int index,
 
- +				 struct of_phandle_args *out_args)
 
-  {
 
-  	struct of_phandle_iterator it;
 
-  	int rc, cur_index = 0;
 
-  
 
- +	if (index < 0)
 
- +		return -EINVAL;
 
- +
 
-  	/* Loop over the phandles until all the requested entry is found */
 
-  	of_for_each_phandle(&it, rc, np, list_name, cells_name, cell_count) {
 
-  		/*
 
- @@ -1422,82 +1425,7 @@ static int __of_parse_phandle_with_args(
 
-  	of_node_put(it.node);
 
-  	return rc;
 
-  }
 
- -
 
- -/**
 
- - * of_parse_phandle - Resolve a phandle property to a device_node pointer
 
- - * @np: Pointer to device node holding phandle property
 
- - * @phandle_name: Name of property holding a phandle value
 
- - * @index: For properties holding a table of phandles, this is the index into
 
- - *         the table
 
- - *
 
- - * Return: The device_node pointer with refcount incremented.  Use
 
- - * of_node_put() on it when done.
 
- - */
 
- -struct device_node *of_parse_phandle(const struct device_node *np,
 
- -				     const char *phandle_name, 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;
 
- -
 
- -	return args.np;
 
- -}
 
- -EXPORT_SYMBOL(of_parse_phandle);
 
- -
 
- -/**
 
- - * of_parse_phandle_with_args() - Find a node pointed by phandle in a list
 
- - * @np:		pointer to a device tree node containing a list
 
- - * @list_name:	property name that contains a list
 
- - * @cells_name:	property name that specifies phandles' arguments count
 
- - * @index:	index of a phandle to parse out
 
- - * @out_args:	optional pointer to output arguments structure (will be filled)
 
- - *
 
- - * This function is useful to parse lists of phandles and their arguments.
 
- - * Returns 0 on success and fills out_args, on error returns appropriate
 
- - * errno value.
 
- - *
 
- - * Caller is responsible to call of_node_put() on the returned out_args->np
 
- - * pointer.
 
- - *
 
- - * Example::
 
- - *
 
- - *  phandle1: node1 {
 
- - *	#list-cells = <2>;
 
- - *  };
 
- - *
 
- - *  phandle2: node2 {
 
- - *	#list-cells = <1>;
 
- - *  };
 
- - *
 
- - *  node3 {
 
- - *	list = <&phandle1 1 2 &phandle2 3>;
 
- - *  };
 
- - *
 
- - * To get a device_node of the ``node2`` node you may call this:
 
- - * 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,
 
- -				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;
 
- -
 
- -	return __of_parse_phandle_with_args(np, list_name, cells_name,
 
- -					    cell_count, index, out_args);
 
- -}
 
- -EXPORT_SYMBOL(of_parse_phandle_with_args);
 
- +EXPORT_SYMBOL(__of_parse_phandle_with_args);
 
-  
 
-  /**
 
-   * of_parse_phandle_with_args_map() - Find a node pointed by phandle in a list and remap it
 
- @@ -1684,47 +1612,6 @@ free:
 
-  EXPORT_SYMBOL(of_parse_phandle_with_args_map);
 
-  
 
-  /**
 
- - * of_parse_phandle_with_fixed_args() - Find a node pointed by phandle in a list
 
- - * @np:		pointer to a device tree node containing a list
 
- - * @list_name:	property name that contains a list
 
- - * @cell_count: number of argument cells following the phandle
 
- - * @index:	index of a phandle to parse out
 
- - * @out_args:	optional pointer to output arguments structure (will be filled)
 
- - *
 
- - * This function is useful to parse lists of phandles and their arguments.
 
- - * Returns 0 on success and fills out_args, on error returns appropriate
 
- - * errno value.
 
- - *
 
- - * Caller is responsible to call of_node_put() on the returned out_args->np
 
- - * pointer.
 
- - *
 
- - * Example::
 
- - *
 
- - *  phandle1: node1 {
 
- - *  };
 
- - *
 
- - *  phandle2: node2 {
 
- - *  };
 
- - *
 
- - *  node3 {
 
- - *  	list = <&phandle1 0 2 &phandle2 2 3>;
 
- - *  };
 
- - *
 
- - * To get a device_node of the ``node2`` node you may call this:
 
- - * of_parse_phandle_with_fixed_args(node3, "list", 2, 1, &args);
 
- - */
 
- -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)
 
- -{
 
- -	if (index < 0)
 
- -		return -EINVAL;
 
- -	return __of_parse_phandle_with_args(np, list_name, NULL, cell_count,
 
- -					   index, out_args);
 
- -}
 
- -EXPORT_SYMBOL(of_parse_phandle_with_fixed_args);
 
- -
 
- -/**
 
-   * of_count_phandle_with_args() - Find the number of phandles references in a property
 
-   * @np:		pointer to a device tree node containing a list
 
-   * @list_name:	property name that contains a list
 
- --- a/include/linux/of.h
 
- +++ b/include/linux/of.h
 
- @@ -363,18 +363,12 @@ extern const struct of_device_id *of_mat
 
-  	const struct of_device_id *matches, const struct device_node *node);
 
-  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);
 
- -extern int of_parse_phandle_with_args(const struct device_node *np,
 
- -	const char *list_name, const char *cells_name, int index,
 
- -	struct of_phandle_args *out_args);
 
- +extern int __of_parse_phandle_with_args(const struct device_node *np,
 
- +	const char *list_name, const char *cells_name, int cell_count,
 
- +	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,
 
-  	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,
 
- -	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);
 
-  
 
- @@ -864,18 +858,12 @@ static inline int of_property_read_strin
 
-  	return -ENOSYS;
 
-  }
 
-  
 
- -static inline struct device_node *of_parse_phandle(const struct device_node *np,
 
- -						   const char *phandle_name,
 
- -						   int index)
 
- -{
 
- -	return NULL;
 
- -}
 
- -
 
- -static inline int of_parse_phandle_with_args(const struct device_node *np,
 
- -					     const char *list_name,
 
- -					     const char *cells_name,
 
- -					     int index,
 
- -					     struct of_phandle_args *out_args)
 
- +static inline int __of_parse_phandle_with_args(const struct device_node *np,
 
- +					       const char *list_name,
 
- +					       const char *cells_name,
 
- +					       int cell_count,
 
- +					       int index,
 
- +					       struct of_phandle_args *out_args)
 
-  {
 
-  	return -ENOSYS;
 
-  }
 
- @@ -889,13 +877,6 @@ static inline int of_parse_phandle_with_
 
-  	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,
 
- -	struct of_phandle_args *out_args)
 
- -{
 
- -	return -ENOSYS;
 
- -}
 
- -
 
-  static inline int of_count_phandle_with_args(const struct device_node *np,
 
-  					     const char *list_name,
 
-  					     const char *cells_name)
 
- @@ -1077,6 +1058,117 @@ static inline bool of_node_is_type(const
 
-  }
 
-  
 
-  /**
 
- + * of_parse_phandle - Resolve a phandle property to a device_node pointer
 
- + * @np: Pointer to device node holding phandle property
 
- + * @phandle_name: Name of property holding a phandle value
 
- + * @index: For properties holding a table of phandles, this is the index into
 
- + *         the table
 
- + *
 
- + * Return: The device_node pointer with refcount incremented.  Use
 
- + * of_node_put() on it when done.
 
- + */
 
- +static inline struct device_node *of_parse_phandle(const struct device_node *np,
 
- +						   const char *phandle_name,
 
- +						   int index)
 
- +{
 
- +	struct of_phandle_args args;
 
- +
 
- +	if (__of_parse_phandle_with_args(np, phandle_name, NULL, 0,
 
- +					 index, &args))
 
- +		return NULL;
 
- +
 
- +	return args.np;
 
- +}
 
- +
 
- +/**
 
- + * of_parse_phandle_with_args() - Find a node pointed by phandle in a list
 
- + * @np:		pointer to a device tree node containing a list
 
- + * @list_name:	property name that contains a list
 
- + * @cells_name:	property name that specifies phandles' arguments count
 
- + * @index:	index of a phandle to parse out
 
- + * @out_args:	optional pointer to output arguments structure (will be filled)
 
- + *
 
- + * This function is useful to parse lists of phandles and their arguments.
 
- + * Returns 0 on success and fills out_args, on error returns appropriate
 
- + * errno value.
 
- + *
 
- + * Caller is responsible to call of_node_put() on the returned out_args->np
 
- + * pointer.
 
- + *
 
- + * Example::
 
- + *
 
- + *  phandle1: node1 {
 
- + *	#list-cells = <2>;
 
- + *  };
 
- + *
 
- + *  phandle2: node2 {
 
- + *	#list-cells = <1>;
 
- + *  };
 
- + *
 
- + *  node3 {
 
- + *	list = <&phandle1 1 2 &phandle2 3>;
 
- + *  };
 
- + *
 
- + * To get a device_node of the ``node2`` node you may call this:
 
- + * of_parse_phandle_with_args(node3, "list", "#list-cells", 1, &args);
 
- + */
 
- +static inline int of_parse_phandle_with_args(const struct device_node *np,
 
- +					     const char *list_name,
 
- +					     const char *cells_name,
 
- +					     int index,
 
- +					     struct of_phandle_args *out_args)
 
- +{
 
- +	int cell_count = -1;
 
- +
 
- +	/* If cells_name is NULL we assume a cell count of 0 */
 
- +	if (!cells_name)
 
- +		cell_count = 0;
 
- +
 
- +	return __of_parse_phandle_with_args(np, list_name, cells_name,
 
- +					    cell_count, index, out_args);
 
- +}
 
- +
 
- +/**
 
- + * of_parse_phandle_with_fixed_args() - Find a node pointed by phandle in a list
 
- + * @np:		pointer to a device tree node containing a list
 
- + * @list_name:	property name that contains a list
 
- + * @cell_count: number of argument cells following the phandle
 
- + * @index:	index of a phandle to parse out
 
- + * @out_args:	optional pointer to output arguments structure (will be filled)
 
- + *
 
- + * This function is useful to parse lists of phandles and their arguments.
 
- + * Returns 0 on success and fills out_args, on error returns appropriate
 
- + * errno value.
 
- + *
 
- + * Caller is responsible to call of_node_put() on the returned out_args->np
 
- + * pointer.
 
- + *
 
- + * Example::
 
- + *
 
- + *  phandle1: node1 {
 
- + *  };
 
- + *
 
- + *  phandle2: node2 {
 
- + *  };
 
- + *
 
- + *  node3 {
 
- + *	list = <&phandle1 0 2 &phandle2 2 3>;
 
- + *  };
 
- + *
 
- + * To get a device_node of the ``node2`` node you may call this:
 
- + * of_parse_phandle_with_fixed_args(node3, "list", 2, 1, &args);
 
- + */
 
- +static inline 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)
 
- +{
 
- +	return __of_parse_phandle_with_args(np, list_name, NULL, cell_count,
 
- +					    index, out_args);
 
- +}
 
- +
 
- +/**
 
-   * of_property_count_u8_elems - Count the number of u8 elements in a property
 
-   *
 
-   * @np:		device node from which the property value is to be read.
 
 
  |