[PATCH] regulator: scmi: Use int type to store negative error codes

Qianfeng Rong posted 1 patch 1 month ago
drivers/regulator/scmi-regulator.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[PATCH] regulator: scmi: Use int type to store negative error codes
Posted by Qianfeng Rong 1 month ago
Change the 'ret' variable from u32 to int to store negative error codes or
zero returned by of_property_read_u32().

Storing the negative error codes in unsigned type, doesn't cause an issue
at runtime but it's ugly as pants. Additionally, assigning negative error
codes to unsigned type may trigger a GCC warning when the -Wsign-conversion
flag is enabled.

No effect on runtime.

Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
---
 drivers/regulator/scmi-regulator.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/regulator/scmi-regulator.c b/drivers/regulator/scmi-regulator.c
index 9df726f10ad1..6d609c42e479 100644
--- a/drivers/regulator/scmi-regulator.c
+++ b/drivers/regulator/scmi-regulator.c
@@ -257,7 +257,8 @@ static int process_scmi_regulator_of_node(struct scmi_device *sdev,
 					  struct device_node *np,
 					  struct scmi_regulator_info *rinfo)
 {
-	u32 dom, ret;
+	u32 dom;
+	int ret;
 
 	ret = of_property_read_u32(np, "reg", &dom);
 	if (ret)
-- 
2.34.1
Re: [PATCH] regulator: scmi: Use int type to store negative error codes
Posted by Mark Brown 1 month ago
On Fri, 29 Aug 2025 18:14:11 +0800, Qianfeng Rong wrote:
> Change the 'ret' variable from u32 to int to store negative error codes or
> zero returned by of_property_read_u32().
> 
> Storing the negative error codes in unsigned type, doesn't cause an issue
> at runtime but it's ugly as pants. Additionally, assigning negative error
> codes to unsigned type may trigger a GCC warning when the -Wsign-conversion
> flag is enabled.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next

Thanks!

[1/1] regulator: scmi: Use int type to store negative error codes
      commit: 9d35d068fb138160709e04e3ee97fe29a6f8615b

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark
Re: [PATCH] regulator: scmi: Use int type to store negative error codes
Posted by Sudeep Holla 1 month ago
On Fri, Aug 29, 2025 at 06:14:11PM +0800, Qianfeng Rong wrote:
> Change the 'ret' variable from u32 to int to store negative error codes or
> zero returned by of_property_read_u32().
> 
> Storing the negative error codes in unsigned type, doesn't cause an issue
> at runtime but it's ugly as pants. Additionally, assigning negative error
> codes to unsigned type may trigger a GCC warning when the -Wsign-conversion
> flag is enabled.
> 
> No effect on runtime.
>

Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>

Mark,

Not sure if it is worth adding:

Fixes: 0fbeae70ee7c ("regulator: add SCMI driver")

Especially if value > 0 is not treated as error in some driver using
regulator APIs.

-- 
Regards,
Sudeep