diff mbox series

[v3] media: v4l2-fwnode: Simplify v4l2_async_nf_parse_fwnode_endpoints()

Message ID 20210613150847.774978-1-niklas.soderlund+renesas@ragnatech.se (mailing list archive)
State New, archived
Headers show
Series [v3] media: v4l2-fwnode: Simplify v4l2_async_nf_parse_fwnode_endpoints() | expand

Commit Message

Niklas Söderlund June 13, 2021, 3:08 p.m. UTC
There are only one user left of __v4l2_async_notifier_parse_fwnode_ep()
since [1], v4l2_async_notifier_parse_fwnode_endpoints(). The two
functions can be merged.

The merge of the two highlights a dead code block conditioned by the
argument 'has_port' that always is false and can therefor be removed.

1. commit 0ae426ebd0dcef81 ("media: v4l2-fwnode: Remove v4l2_async_notifier_parse_fwnode_endpoints_by_port()")

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
---
* Changes since v2
- Extend commit message to describe that the dead code removed is created
  by the merge of the two functions.
- The rename of the effected function never made it upstream, rebase
  this patch to latest media-tree so it can be picked-up without the
  rename.

* Changes since v1
- Rebased on Sakari's branch which renames
  v4l2_async_notifier_parse_fwnode_endpoints() to
  v4l2_async_nf_parse_fwnode_endpoints).
---
 drivers/media/v4l2-core/v4l2-fwnode.c | 33 ++++-----------------------
 1 file changed, 5 insertions(+), 28 deletions(-)

Comments

Jacopo Mondi June 16, 2021, 3:29 p.m. UTC | #1
Hi Niklas,

On Sun, Jun 13, 2021 at 05:08:47PM +0200, Niklas Söderlund wrote:
> There are only one user left of __v4l2_async_notifier_parse_fwnode_ep()
> since [1], v4l2_async_notifier_parse_fwnode_endpoints(). The two
> functions can be merged.
>
> The merge of the two highlights a dead code block conditioned by the
> argument 'has_port' that always is false and can therefor be removed.
>
> 1. commit 0ae426ebd0dcef81 ("media: v4l2-fwnode: Remove v4l2_async_notifier_parse_fwnode_endpoints_by_port()")
>
> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

Makes sense to me

Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>

Thanks
  j

> ---
> * Changes since v2
> - Extend commit message to describe that the dead code removed is created
>   by the merge of the two functions.
> - The rename of the effected function never made it upstream, rebase
>   this patch to latest media-tree so it can be picked-up without the
>   rename.
>
> * Changes since v1
> - Rebased on Sakari's branch which renames
>   v4l2_async_notifier_parse_fwnode_endpoints() to
>   v4l2_async_nf_parse_fwnode_endpoints).
> ---
>  drivers/media/v4l2-core/v4l2-fwnode.c | 33 ++++-----------------------
>  1 file changed, 5 insertions(+), 28 deletions(-)
>
> diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-core/v4l2-fwnode.c
> index 843259c304bb5857..60ef0e11af51850c 100644
> --- a/drivers/media/v4l2-core/v4l2-fwnode.c
> +++ b/drivers/media/v4l2-core/v4l2-fwnode.c
> @@ -839,13 +839,11 @@ v4l2_async_notifier_fwnode_parse_endpoint(struct device *dev,
>  	return ret == -ENOTCONN ? 0 : ret;
>  }
>
> -static int
> -__v4l2_async_notifier_parse_fwnode_ep(struct device *dev,
> -				      struct v4l2_async_notifier *notifier,
> -				      size_t asd_struct_size,
> -				      unsigned int port,
> -				      bool has_port,
> -				      parse_endpoint_func parse_endpoint)
> +int
> +v4l2_async_notifier_parse_fwnode_endpoints(struct device *dev,
> +					   struct v4l2_async_notifier *notifier,
> +					   size_t asd_struct_size,
> +					   parse_endpoint_func parse_endpoint)
>  {
>  	struct fwnode_handle *fwnode;
>  	int ret = 0;
> @@ -863,16 +861,6 @@ __v4l2_async_notifier_parse_fwnode_ep(struct device *dev,
>  		if (!is_available)
>  			continue;
>
> -		if (has_port) {
> -			struct fwnode_endpoint ep;
> -
> -			ret = fwnode_graph_parse_endpoint(fwnode, &ep);
> -			if (ret)
> -				break;
> -
> -			if (ep.port != port)
> -				continue;
> -		}
>
>  		ret = v4l2_async_notifier_fwnode_parse_endpoint(dev,
>  								notifier,
> @@ -887,17 +875,6 @@ __v4l2_async_notifier_parse_fwnode_ep(struct device *dev,
>
>  	return ret;
>  }
> -
> -int
> -v4l2_async_notifier_parse_fwnode_endpoints(struct device *dev,
> -					   struct v4l2_async_notifier *notifier,
> -					   size_t asd_struct_size,
> -					   parse_endpoint_func parse_endpoint)
> -{
> -	return __v4l2_async_notifier_parse_fwnode_ep(dev, notifier,
> -						     asd_struct_size, 0,
> -						     false, parse_endpoint);
> -}
>  EXPORT_SYMBOL_GPL(v4l2_async_notifier_parse_fwnode_endpoints);
>
>  /*
> --
> 2.32.0
>
Sakari Ailus June 22, 2021, 10:36 a.m. UTC | #2
Hi Niklas,

On Sun, Jun 13, 2021 at 05:08:47PM +0200, Niklas Söderlund wrote:
> There are only one user left of __v4l2_async_notifier_parse_fwnode_ep()
> since [1], v4l2_async_notifier_parse_fwnode_endpoints(). The two
> functions can be merged.
> 
> The merge of the two highlights a dead code block conditioned by the
> argument 'has_port' that always is false and can therefor be removed.
> 
> 1. commit 0ae426ebd0dcef81 ("media: v4l2-fwnode: Remove v4l2_async_notifier_parse_fwnode_endpoints_by_port()")
> 
> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> ---
> * Changes since v2
> - Extend commit message to describe that the dead code removed is created
>   by the merge of the two functions.
> - The rename of the effected function never made it upstream, rebase
>   this patch to latest media-tree so it can be picked-up without the
>   rename.

I've continued work on the rename, and I'm about to send a new version.

So I'll take the commit message changes from this one if that's fine for
you.
diff mbox series

Patch

diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-core/v4l2-fwnode.c
index 843259c304bb5857..60ef0e11af51850c 100644
--- a/drivers/media/v4l2-core/v4l2-fwnode.c
+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
@@ -839,13 +839,11 @@  v4l2_async_notifier_fwnode_parse_endpoint(struct device *dev,
 	return ret == -ENOTCONN ? 0 : ret;
 }
 
-static int
-__v4l2_async_notifier_parse_fwnode_ep(struct device *dev,
-				      struct v4l2_async_notifier *notifier,
-				      size_t asd_struct_size,
-				      unsigned int port,
-				      bool has_port,
-				      parse_endpoint_func parse_endpoint)
+int
+v4l2_async_notifier_parse_fwnode_endpoints(struct device *dev,
+					   struct v4l2_async_notifier *notifier,
+					   size_t asd_struct_size,
+					   parse_endpoint_func parse_endpoint)
 {
 	struct fwnode_handle *fwnode;
 	int ret = 0;
@@ -863,16 +861,6 @@  __v4l2_async_notifier_parse_fwnode_ep(struct device *dev,
 		if (!is_available)
 			continue;
 
-		if (has_port) {
-			struct fwnode_endpoint ep;
-
-			ret = fwnode_graph_parse_endpoint(fwnode, &ep);
-			if (ret)
-				break;
-
-			if (ep.port != port)
-				continue;
-		}
 
 		ret = v4l2_async_notifier_fwnode_parse_endpoint(dev,
 								notifier,
@@ -887,17 +875,6 @@  __v4l2_async_notifier_parse_fwnode_ep(struct device *dev,
 
 	return ret;
 }
-
-int
-v4l2_async_notifier_parse_fwnode_endpoints(struct device *dev,
-					   struct v4l2_async_notifier *notifier,
-					   size_t asd_struct_size,
-					   parse_endpoint_func parse_endpoint)
-{
-	return __v4l2_async_notifier_parse_fwnode_ep(dev, notifier,
-						     asd_struct_size, 0,
-						     false, parse_endpoint);
-}
 EXPORT_SYMBOL_GPL(v4l2_async_notifier_parse_fwnode_endpoints);
 
 /*