Skip to contentSkip to conversation

clk: fix count parameter type for clk_release_all

PATCH Applied Eugen Hristev 3 participants 5 messages Jun 19, 2023 – Nov 1, 2023 Common clk

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clk: fix count parameter type for clk_release_all

The second parameter for clk_release_all is used as an unsigned (which makes sense) but the function prototype declares it as an int. This causes warnings/error like such below:

include/clk.h:422:48: error: conversion to ‘int’ from ‘unsigned int’ may change the sign of the result [-Werror=sign-conversion]
422 | return clk_release_all(bulk->clks, bulk->count);

To fix this, changed the type of the count to unsigned int

Fixes 82a8a669b4f7 ("clk: add clk_release_all()")
---
 drivers/clk/clk-uclass.c | 7 ++++---
 include/clk.h            | 4 ++--
 2 files changed, 6 insertions(+), 5 deletions(-)
drivers/clk/clk-uclass.c +4 -3
index dc3e9d6a2615..eada3a3a5b62 100644
@@ -416,12 +416,13 @@ int clk_get_by_name_nodev(ofnode node, const char *name, struct clk *clk)
 	return clk_get_by_index_nodev(node, index, clk);
 }
 
-int clk_release_all(struct clk *clk, int count)
+int clk_release_all(struct clk *clk, unsigned int count)
 {
-	int i, ret;
+	unsigned int i;
+	int ret;
 
 	for (i = 0; i < count; i++) {
-		debug("%s(clk[%d]=%p)\n", __func__, i, &clk[i]);
+		debug("%s(clk[%u]=%p)\n", __func__, i, &clk[i]);
 
 		/* check if clock has been previously requested */
 		if (!clk[i].dev)
include/clk.h +2 -2
index d91285235f79..a342297007b6 100644
@@ -243,7 +243,7 @@ static inline struct clk *devm_clk_get_optional(struct udevice *dev,
  *
  * Return: zero on success, or -ve error code.
  */
-int clk_release_all(struct clk *clk, int count);
+int clk_release_all(struct clk *clk, unsigned int count);
 
 /**
  * devm_clk_put	- "free" a managed clock source
@@ -307,7 +307,7 @@ clk_get_by_name_nodev(ofnode node, const char *name, struct clk *clk)
 	return -ENOSYS;
 }
 
-static inline int clk_release_all(struct clk *clk, int count)
+static inline int clk_release_all(struct clk *clk, unsigned int count)
 {
 	return -ENOSYS;
 }
Signature · 1 line
2.34.1
#1 lore raw
Quoted 51 lines · Eugen Hristev

The second parameter for clk_release_all is used as an unsigned (which makes sense) but the function prototype declares it as an int. This causes warnings/error like such below:

include/clk.h:422:48: error: conversion to ‘int’ from ‘unsigned int’ may change the sign of the result [-Werror=sign-conversion]
422 | return clk_release_all(bulk->clks, bulk->count);

To fix this, changed the type of the count to unsigned int

Fixes 82a8a669b4f7 ("clk: add clk_release_all()")
---
  drivers/clk/clk-uclass.c | 7 ++++---
  include/clk.h            | 4 ++--
  2 files changed, 6 insertions(+), 5 deletions(-)
drivers/clk/clk-uclass.c +4 -3
index dc3e9d6a2615..eada3a3a5b62 100644
@@ -416,12 +416,13 @@ int clk_get_by_name_nodev(ofnode node, const char *name, struct clk *clk)
  	return clk_get_by_index_nodev(node, index, clk);
  }
 
-int clk_release_all(struct clk *clk, int count)
+int clk_release_all(struct clk *clk, unsigned int count)
  {
-	int i, ret;
+	unsigned int i;
+	int ret;
 
  	for (i = 0; i < count; i++) {
-		debug("%s(clk[%d]=%p)\n", __func__, i, &clk[i]);
+		debug("%s(clk[%u]=%p)\n", __func__, i, &clk[i]);
 
  		/* check if clock has been previously requested */
  		if (!clk[i].dev)
include/clk.h +1 -1
index d91285235f79..a342297007b6 100644
@@ -243,7 +243,7 @@ static inline struct clk *devm_clk_get_optional(struct udevice *dev,
   *
   * Return: zero on success, or -ve error code.
   */
-int clk_release_all(struct clk *clk, int count);
+int clk_release_all(struct clk *clk, unsigned int count);
 
  /**
   * devm_clk_put	- "free" a managed clock source

include/clk.h clk_get_by_name_nodev(ofnode node, const char *name, struct clk *clk) · line 313

Quoted 8 lines
include/clk.h +1 -1
@@ -307,7 +307,7 @@ clk_get_by_name_nodev(ofnode node, const char *name, struct clk *clk)
  	return -ENOSYS;
  }
 
-static inline int clk_release_all(struct clk *clk, int count)
+static inline int clk_release_all(struct clk *clk, unsigned int count)
  {
  	return -ENOSYS;
  }

Hi,

gentle ping.

Thanks,
Eugen

Reviewed-by on v1 1/1
#2 lore raw
In reply to Eugen Hristev

El Mon, Jun 19, 2023 at 01:47:52PM +0300, Eugen Hristev deia:

Quoted 11 lines

The second parameter for clk_release_all is used as an unsigned (which makes sense) but the function prototype declares it as an int. This causes warnings/error like such below:

include/clk.h:422:48: error: conversion to ‘int’ from ‘unsigned int’ may change the sign of the result [-Werror=sign-conversion]
422 | return clk_release_all(bulk->clks, bulk->count);

To fix this, changed the type of the count to unsigned int

Fixes 82a8a669b4f7 ("clk: add clk_release_all()")
Quoted 10 lines
---
 drivers/clk/clk-uclass.c | 7 ++++---
 include/clk.h            | 4 ++--
 2 files changed, 6 insertions(+), 5 deletions(-)
drivers/clk/clk-uclass.c +0 -0
index dc3e9d6a2615..eada3a3a5b62 100644

drivers/clk/clk-uclass.c int clk_get_by_name_nodev(ofnode node, const char *name, struct clk *clk) · line 423

Quoted 10 lines
drivers/clk/clk-uclass.c +3 -2
@@ -416,12 +416,13 @@ int clk_get_by_name_nodev(ofnode node, const char *name, struct clk *clk)
 	return clk_get_by_index_nodev(node, index, clk);
 }
 
-int clk_release_all(struct clk *clk, int count)
+int clk_release_all(struct clk *clk, unsigned int count)
 {
-	int i, ret;
+	unsigned int i;
+	int ret;
 

This could also be changed in clk_enable_blk() and clk_disable_blk(). It's unlikely that we get so many clocks for it to matter, but it's till wrong to compare int i to unsigned int bulk->count. That'd be a different patch, though.

Quoted 31 lines
drivers/clk/clk-uclass.c +1 -1
 	for (i = 0; i < count; i++) {
-		debug("%s(clk[%d]=%p)\n", __func__, i, &clk[i]);
+		debug("%s(clk[%u]=%p)\n", __func__, i, &clk[i]);
 
 		/* check if clock has been previously requested */
 		if (!clk[i].dev)
include/clk.h +2 -2
index d91285235f79..a342297007b6 100644
@@ -243,7 +243,7 @@ static inline struct clk *devm_clk_get_optional(struct udevice *dev,
  *
  * Return: zero on success, or -ve error code.
  */
-int clk_release_all(struct clk *clk, int count);
+int clk_release_all(struct clk *clk, unsigned int count);
 
 /**
  * devm_clk_put	- "free" a managed clock source
@@ -307,7 +307,7 @@ clk_get_by_name_nodev(ofnode node, const char *name, struct clk *clk)
 	return -ENOSYS;
 }
 
-static inline int clk_release_all(struct clk *clk, int count)
+static inline int clk_release_all(struct clk *clk, unsigned int count)
 {
 	return -ENOSYS;
 }
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#3 lore raw
In reply to Eugen Hristev
Quoted 51 lines · Eugen Hristev

The second parameter for clk_release_all is used as an unsigned (which makes sense) but the function prototype declares it as an int. This causes warnings/error like such below:

include/clk.h:422:48: error: conversion to ‘int’ from ‘unsigned int’ may change the sign of the result [-Werror=sign-conversion]
422 | return clk_release_all(bulk->clks, bulk->count);

To fix this, changed the type of the count to unsigned int

Fixes 82a8a669b4f7 ("clk: add clk_release_all()")
---
  drivers/clk/clk-uclass.c | 7 ++++---
  include/clk.h            | 4 ++--
  2 files changed, 6 insertions(+), 5 deletions(-)
drivers/clk/clk-uclass.c +4 -3
index dc3e9d6a2615..eada3a3a5b62 100644
@@ -416,12 +416,13 @@ int clk_get_by_name_nodev(ofnode node, const char *name, struct clk *clk)
  	return clk_get_by_index_nodev(node, index, clk);
  }
 
-int clk_release_all(struct clk *clk, int count)
+int clk_release_all(struct clk *clk, unsigned int count)
  {
-	int i, ret;
+	unsigned int i;
+	int ret;
 
  	for (i = 0; i < count; i++) {
-		debug("%s(clk[%d]=%p)\n", __func__, i, &clk[i]);
+		debug("%s(clk[%u]=%p)\n", __func__, i, &clk[i]);
 
  		/* check if clock has been previously requested */
  		if (!clk[i].dev)
include/clk.h +1 -1
index d91285235f79..a342297007b6 100644
@@ -243,7 +243,7 @@ static inline struct clk *devm_clk_get_optional(struct udevice *dev,
   *
   * Return: zero on success, or -ve error code.
   */
-int clk_release_all(struct clk *clk, int count);
+int clk_release_all(struct clk *clk, unsigned int count);
 
  /**
   * devm_clk_put	- "free" a managed clock source

include/clk.h clk_get_by_name_nodev(ofnode node, const char *name, struct clk *clk) · line 313

Quoted 8 lines
include/clk.h +1 -1
@@ -307,7 +307,7 @@ clk_get_by_name_nodev(ofnode node, const char *name, struct clk *clk)
  	return -ENOSYS;
  }
 
-static inline int clk_release_all(struct clk *clk, int count)
+static inline int clk_release_all(struct clk *clk, unsigned int count)
  {
  	return -ENOSYS;
  }
#4 lore raw
In reply to Eugen Hristev
Quoted 8 lines · Eugen Hristev

The second parameter for clk_release_all is used as an unsigned (which makes sense) but the function prototype declares it as an int. This causes warnings/error like such below:

include/clk.h:422:48: error: conversion to ‘int’ from ‘unsigned int’ may change the sign of the result [-Werror=sign-conversion]
422 | return clk_release_all(bulk->clks, bulk->count);

[...]

Applied, thanks!

[1/1] clk: fix count parameter type for clk_release_all

      commit: b6a56f553318b4c0c8fb8b1ea05f2e15b2662ccb

Best regards,

Signature · 1 line
Sean Anderson <[email protected]>