Skip to contentSkip to conversation

media: i2c: ds90ub960: Delete duplicate source code in ub960_parse_dt_rxports()

PATCH In review Markus Elfring 5 participants 7 messages Mar 1, 2024 – Mar 2, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: i2c: ds90ub960: Delete duplicate source code in ub960_parse_dt_rxports()

From: Markus Elfring <[email protected]>
Date: Fri, 1 Mar 2024 08:23:24 +0100

Avoid the specification of a duplicate fwnode_handle_put() call in this function implementation.

---
 drivers/media/i2c/ds90ub960.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/media/i2c/ds90ub960.c +1 -4
index ffe5f25f8647..eb708ed7b56e 100644
@@ -3486,10 +3486,7 @@ static int ub960_parse_dt_rxports(struct ub960_data *priv)
 		}
 	}
 
-	fwnode_handle_put(links_fwnode);
-
-	return 0;
-
+	ret = 0;
 err_put_links:
 	fwnode_handle_put(links_fwnode);
 

--
2.44.0

#1 lore raw

Hi Markus,

Quoted 16 lines · Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 1 Mar 2024 08:23:24 +0100

Avoid the specification of a duplicate fwnode_handle_put() call in this function implementation.

---
 drivers/media/i2c/ds90ub960.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/media/i2c/ds90ub960.c +0 -0
index ffe5f25f8647..eb708ed7b56e 100644

drivers/media/i2c/ds90ub960.c static int ub960_parse_dt_rxports(struct ub960_data *priv) · line 3489

Quoted 8 lines
drivers/media/i2c/ds90ub960.c +1 -4
@@ -3486,10 +3486,7 @@ static int ub960_parse_dt_rxports(struct ub960_data *priv)
 		}
 	}
 
-	fwnode_handle_put(links_fwnode);
-
-	return 0;
-
+	ret = 0;

I think it'd be nicer to initialise ret as zero, then you can just drop the assignment above.

Quoted 3 lines
drivers/media/i2c/ds90ub960.c +0 -0
 err_put_links:
 	fwnode_handle_put(links_fwnode);
 
Signature · 3 lines
Regards,

Sakari Ailus
maintainer
#2 lore raw

Hi,

Quoted 22 lines · Sakari Ailus

Hi Markus,

Quoted 19 lines · Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 1 Mar 2024 08:23:24 +0100

Avoid the specification of a duplicate fwnode_handle_put() call in this function implementation.

---
  drivers/media/i2c/ds90ub960.c | 5 +----
  1 file changed, 1 insertion(+), 4 deletions(-)
drivers/media/i2c/ds90ub960.c +0 -0
index ffe5f25f8647..eb708ed7b56e 100644
@@ -3486,10 +3486,7 @@ static int ub960_parse_dt_rxports(struct ub960_data *priv)
  		}
  	}
 
Quoted 8 lines

drivers/media/i2c/ds90ub960.c static int ub960_parse_dt_rxports(struct ub960_data *priv) · line 3489

Quoted 5 lines
drivers/media/i2c/ds90ub960.c +1 -4
-	fwnode_handle_put(links_fwnode);
-
-	return 0;
-
+	ret = 0;

I think it'd be nicer to initialise ret as zero, then you can just drop the assignment above.

I don't like successful execution entering error paths. That's why there's the return 0.

Tomi

Quoted 4 lines
Quoted 3 lines
drivers/media/i2c/ds90ub960.c +0 -0
  err_put_links:
  	fwnode_handle_put(links_fwnode);
 
#3 lore raw

Huomenta,

Quoted 34 lines · Tomi Valkeinen

Hi,

Quoted 22 lines · Sakari Ailus

Hi Markus,

Quoted 19 lines · Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 1 Mar 2024 08:23:24 +0100

Avoid the specification of a duplicate fwnode_handle_put() call in this function implementation.

---
  drivers/media/i2c/ds90ub960.c | 5 +----
  1 file changed, 1 insertion(+), 4 deletions(-)
drivers/media/i2c/ds90ub960.c +0 -0
index ffe5f25f8647..eb708ed7b56e 100644
@@ -3486,10 +3486,7 @@ static int ub960_parse_dt_rxports(struct ub960_data *priv)
  		}
  	}
 
Quoted 8 lines

drivers/media/i2c/ds90ub960.c static int ub960_parse_dt_rxports(struct ub960_data *priv) · line 3489

Quoted 5 lines
drivers/media/i2c/ds90ub960.c +1 -4
-	fwnode_handle_put(links_fwnode);
-
-	return 0;
-
+	ret = 0;

I think it'd be nicer to initialise ret as zero, then you can just drop the assignment above.

Quoted 2 lines

I don't like successful execution entering error paths. That's why there's the return 0.

It could be called a common cleanup path as what you really want to do here is to put the fwnode handle, independently of whether there was an error. I think the current code is of course fine, too.

Soon you can do

	struct fwnode_handle *links_fwnode __free(fwnode_handle);

and forget about putting it (but you must need putting it).

Signature · 3 lines
Terveisin,

Sakari Ailus
#4 lore raw
Quoted 22 lines · Sakari Ailus
Quoted 21 lines · Tomi Valkeinen
Quoted 20 lines · Sakari Ailus
Quoted 19 lines · Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 1 Mar 2024 08:23:24 +0100

Avoid the specification of a duplicate fwnode_handle_put() call in this function implementation.

---
  drivers/media/i2c/ds90ub960.c | 5 +----
  1 file changed, 1 insertion(+), 4 deletions(-)
drivers/media/i2c/ds90ub960.c +0 -0
index ffe5f25f8647..eb708ed7b56e 100644
@@ -3486,10 +3486,7 @@ static int ub960_parse_dt_rxports(struct ub960_data *priv)
  		}
  	}
 
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

drivers/media/i2c/ds90ub960.c static int ub960_parse_dt_rxports(struct ub960_data *priv) · line 3489

Quoted 5 lines
drivers/media/i2c/ds90ub960.c +1 -4
-	fwnode_handle_put(links_fwnode);
-
-	return 0;
-
+	ret = 0;

I think it'd be nicer to initialise ret as zero, then you can just drop the assignment above.

I think tearing apart the assignment and its actual user is not good.

Quoted 7 lines
Quoted 2 lines

I don't like successful execution entering error paths. That's why there's the return 0.

It could be called a common cleanup path as what you really want to do here is to put the fwnode handle, independently of whether there was an error. I think the current code is of course fine, too.

Quoted 5 lines

Soon you can do

	struct fwnode_handle *links_fwnode __free(fwnode_handle);

and forget about putting it (but you must need putting it).

Let's wait for the Jonathan's patches to land (v6.9-rc1 I hope) and then we may modify drivers if needed.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#5 lore raw
Quoted 41 lines · Andy Shevchenko
Quoted 22 lines · Sakari Ailus
Quoted 21 lines · Tomi Valkeinen
Quoted 20 lines · Sakari Ailus
Quoted 19 lines · Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 1 Mar 2024 08:23:24 +0100

Avoid the specification of a duplicate fwnode_handle_put() call in this function implementation.

---
  drivers/media/i2c/ds90ub960.c | 5 +----
  1 file changed, 1 insertion(+), 4 deletions(-)
drivers/media/i2c/ds90ub960.c +0 -0
index ffe5f25f8647..eb708ed7b56e 100644
@@ -3486,10 +3486,7 @@ static int ub960_parse_dt_rxports(struct ub960_data *priv)
  		}
  	}
 
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

drivers/media/i2c/ds90ub960.c static int ub960_parse_dt_rxports(struct ub960_data *priv) · line 3489

Quoted 5 lines
drivers/media/i2c/ds90ub960.c +1 -4
-	fwnode_handle_put(links_fwnode);
-
-	return 0;
-
+	ret = 0;

I think it'd be nicer to initialise ret as zero, then you can just drop the assignment above.

I think tearing apart the assignment and its actual user is not good.

Quoted 7 lines
Quoted 2 lines

I don't like successful execution entering error paths. That's why there's the return 0.

It could be called a common cleanup path as what you really want to do here is to put the fwnode handle, independently of whether there was an error. I think the current code is of course fine, too.

Quoted 8 lines
Quoted 5 lines

Soon you can do

	struct fwnode_handle *links_fwnode __free(fwnode_handle);

and forget about putting it (but you must need putting it).

Let's wait for the Jonathan's patches to land (v6.9-rc1 I hope) and then we may modify drivers if needed.

The __free(fwnode_handle) stuff has already been merged.

We could do some additional work to make a _scoped() macro for fwnode_handles but here it's function wide so we already have what we need.

regards,
dan carpenter

#6 lore raw
Quoted 1 line

The __free(fwnode_handle) stuff has already been merged.

Would you like to point a corresponding commit out?

Regards,
Markus