diff mbox series

[2/2] of: property: use unsigned int return on of_graph_get_endpoint_count()

Message ID 87h6irs8fp.wl-kuninori.morimoto.gx@renesas.com
State Superseded
Headers show
Series of: property: cleanup of_graph_get_endpoint_count() | expand

Checks

Context Check Description
robh/checkpatch success
robh/patch-applied fail build log

Commit Message

Kuninori Morimoto Feb. 2, 2024, 6:10 a.m. UTC
Because of of_graph_get_endpoint_count() doesn't report error,
just return count of endpoint, the return type should be unsigned.
Tidyup it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 drivers/of/property.c    | 4 ++--
 include/linux/of_graph.h | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

Comments

Laurent Pinchart Feb. 4, 2024, 9:20 a.m. UTC | #1
Hello Morimoto-san,

Thank you for the patch.

On Fri, Feb 02, 2024 at 06:10:19AM +0000, Kuninori Morimoto wrote:
> Because of of_graph_get_endpoint_count() doesn't report error,
> just return count of endpoint, the return type should be unsigned.
> Tidyup it.

I've briefly checked the callers and none of them seem to check if the
return value is < 0. We may want to update them to store the returned
value in an unsigned int variable, but that could be done separately.

Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
>  drivers/of/property.c    | 4 ++--
>  include/linux/of_graph.h | 4 ++--
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/of/property.c b/drivers/of/property.c
> index 4e879faa1710..66834f85b0ff 100644
> --- a/drivers/of/property.c
> +++ b/drivers/of/property.c
> @@ -817,10 +817,10 @@ EXPORT_SYMBOL(of_graph_get_remote_port);
>   *
>   * Return: count of endpoint of this device node
>   */
> -int of_graph_get_endpoint_count(const struct device_node *np)
> +unsigned int of_graph_get_endpoint_count(const struct device_node *np)
>  {
>  	struct device_node *endpoint;
> -	int num = 0;
> +	unsigned int num = 0;
>  
>  	for_each_endpoint_of_node(np, endpoint)
>  		num++;
> diff --git a/include/linux/of_graph.h b/include/linux/of_graph.h
> index 4d7756087b6b..a4bea62bfa29 100644
> --- a/include/linux/of_graph.h
> +++ b/include/linux/of_graph.h
> @@ -41,7 +41,7 @@ struct of_endpoint {
>  bool of_graph_is_present(const struct device_node *node);
>  int of_graph_parse_endpoint(const struct device_node *node,
>  				struct of_endpoint *endpoint);
> -int of_graph_get_endpoint_count(const struct device_node *np);
> +unsigned int of_graph_get_endpoint_count(const struct device_node *np);
>  struct device_node *of_graph_get_port_by_id(struct device_node *node, u32 id);
>  struct device_node *of_graph_get_next_endpoint(const struct device_node *parent,
>  					struct device_node *previous);
> @@ -68,7 +68,7 @@ static inline int of_graph_parse_endpoint(const struct device_node *node,
>  	return -ENOSYS;
>  }
>  
> -static inline int of_graph_get_endpoint_count(const struct device_node *np)
> +static inline unsigned int of_graph_get_endpoint_count(const struct device_node *np)
>  {
>  	return 0;
>  }
Kuninori Morimoto Feb. 5, 2024, 12:39 a.m. UTC | #2
Hi Laurent

> > Because of of_graph_get_endpoint_count() doesn't report error,
> > just return count of endpoint, the return type should be unsigned.
> > Tidyup it.
> 
> I've briefly checked the callers and none of them seem to check if the
> return value is < 0. We may want to update them to store the returned
> value in an unsigned int variable, but that could be done separately.

Yes, it is one of my concern. This kind of change for example
"int vs unsigned int" / "pointer vs const pointer" might be big compile
warning/error. So I don't want to aggressive update it :(

Thank you for your review.

Best regards
---
Renesas Electronics
Ph.D. Kuninori Morimoto
diff mbox series

Patch

diff --git a/drivers/of/property.c b/drivers/of/property.c
index 4e879faa1710..66834f85b0ff 100644
--- a/drivers/of/property.c
+++ b/drivers/of/property.c
@@ -817,10 +817,10 @@  EXPORT_SYMBOL(of_graph_get_remote_port);
  *
  * Return: count of endpoint of this device node
  */
-int of_graph_get_endpoint_count(const struct device_node *np)
+unsigned int of_graph_get_endpoint_count(const struct device_node *np)
 {
 	struct device_node *endpoint;
-	int num = 0;
+	unsigned int num = 0;
 
 	for_each_endpoint_of_node(np, endpoint)
 		num++;
diff --git a/include/linux/of_graph.h b/include/linux/of_graph.h
index 4d7756087b6b..a4bea62bfa29 100644
--- a/include/linux/of_graph.h
+++ b/include/linux/of_graph.h
@@ -41,7 +41,7 @@  struct of_endpoint {
 bool of_graph_is_present(const struct device_node *node);
 int of_graph_parse_endpoint(const struct device_node *node,
 				struct of_endpoint *endpoint);
-int of_graph_get_endpoint_count(const struct device_node *np);
+unsigned int of_graph_get_endpoint_count(const struct device_node *np);
 struct device_node *of_graph_get_port_by_id(struct device_node *node, u32 id);
 struct device_node *of_graph_get_next_endpoint(const struct device_node *parent,
 					struct device_node *previous);
@@ -68,7 +68,7 @@  static inline int of_graph_parse_endpoint(const struct device_node *node,
 	return -ENOSYS;
 }
 
-static inline int of_graph_get_endpoint_count(const struct device_node *np)
+static inline unsigned int of_graph_get_endpoint_count(const struct device_node *np)
 {
 	return 0;
 }