linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] pinctrl: Use int type to store negative error codes
@ 2025-08-31  8:49 Qianfeng Rong
  2025-08-31  8:49 ` [PATCH 1/3] pinctrl: armada-37xx: " Qianfeng Rong
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Qianfeng Rong @ 2025-08-31  8:49 UTC (permalink / raw)
  To: Andrew Lunn, Gregory Clement, Sebastian Hesselbarth,
	Linus Walleij, Jacky Huang, Shan-Chun Hung, Geert Uytterhoeven,
	Bartosz Golaszewski,
	moderated list:ARM/Marvell Kirkwood and Armada 370, 375, 38x,...,
	open list:PIN CONTROL SUBSYSTEM, open list,
	open list:PIN CONTROLLER - RENESAS
  Cc: Qianfeng Rong

The 'ret' variable usually is used to store returns from some functions,
which return either zero on success or negative error codes on failure.

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

Change "ret" from u32/unsigned int to int type.  No effect on runtime.

Qianfeng Rong (3):
  pinctrl: armada-37xx: Use int type to store negative error codes
  pinctrl: ma35: Use int type to store negative error codes
  pinctrl: renesas: Use int type to store negative error codes

 drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 6 ++++--
 drivers/pinctrl/nuvoton/pinctrl-ma35.c      | 3 ++-
 drivers/pinctrl/renesas/pinctrl.c           | 3 ++-
 3 files changed, 8 insertions(+), 4 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/3] pinctrl: armada-37xx: Use int type to store negative error codes
  2025-08-31  8:49 [PATCH 0/3] pinctrl: Use int type to store negative error codes Qianfeng Rong
@ 2025-08-31  8:49 ` Qianfeng Rong
  2025-08-31 14:41   ` Andrew Lunn
  2025-09-01 13:11   ` Linus Walleij
  2025-08-31  8:49 ` [PATCH 2/3] pinctrl: ma35: " Qianfeng Rong
  2025-08-31  8:49 ` [PATCH 3/3] pinctrl: renesas: " Qianfeng Rong
  2 siblings, 2 replies; 10+ messages in thread
From: Qianfeng Rong @ 2025-08-31  8:49 UTC (permalink / raw)
  To: Andrew Lunn, Gregory Clement, Sebastian Hesselbarth,
	Linus Walleij, Bartosz Golaszewski,
	moderated list:ARM/Marvell Kirkwood and Armada 370, 375, 38x,...,
	open list:PIN CONTROL SUBSYSTEM, open list
  Cc: Qianfeng Rong

In armada_37xx_gpio_direction_output(), the 'ret' variable might store
the negative error codes returned by regmap_update_bits(), and in
armada_37xx_edge_both_irq_swap_pol(), the 'ret' variable directly
stores -1, so the type of the 'ret' variable needs to be changed to
int in both cases.

No effect on runtime.

Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
---
 drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
index 881df5e08f61..81dfbd5e7f07 100644
--- a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
+++ b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
@@ -420,7 +420,8 @@ static int armada_37xx_gpio_direction_output(struct gpio_chip *chip,
 	struct armada_37xx_pinctrl *info = gpiochip_get_data(chip);
 	unsigned int en_offset = offset;
 	unsigned int reg = OUTPUT_VAL;
-	unsigned int mask, val, ret;
+	unsigned int mask, val;
+	int ret;
 
 	armada_37xx_update_reg(&reg, &offset);
 	mask = BIT(offset);
@@ -634,8 +635,9 @@ static int armada_37xx_edge_both_irq_swap_pol(struct armada_37xx_pinctrl *info,
 {
 	u32 reg_idx = pin_idx / GPIO_PER_REG;
 	u32 bit_num = pin_idx % GPIO_PER_REG;
-	u32 p, l, ret;
 	unsigned long flags;
+	u32 p, l;
+	int ret;
 
 	regmap_read(info->regmap, INPUT_VAL + 4*reg_idx, &l);
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/3] pinctrl: ma35: Use int type to store negative error codes
  2025-08-31  8:49 [PATCH 0/3] pinctrl: Use int type to store negative error codes Qianfeng Rong
  2025-08-31  8:49 ` [PATCH 1/3] pinctrl: armada-37xx: " Qianfeng Rong
@ 2025-08-31  8:49 ` Qianfeng Rong
  2025-09-01 13:11   ` Linus Walleij
  2025-08-31  8:49 ` [PATCH 3/3] pinctrl: renesas: " Qianfeng Rong
  2 siblings, 1 reply; 10+ messages in thread
From: Qianfeng Rong @ 2025-08-31  8:49 UTC (permalink / raw)
  To: Jacky Huang, Shan-Chun Hung, Linus Walleij,
	moderated list:ARM/NUVOTON MA35 ARCHITECTURE,
	open list:PIN CONTROL SUBSYSTEM, open list
  Cc: Qianfeng Rong

Change the 'ret' variable in ma35_pinctrl_parse_functions() from u32 to
int, as it needs to store either negative error codes or zero returned
by ma35_pinctrl_parse_groups().

No effect on runtime.

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

diff --git a/drivers/pinctrl/nuvoton/pinctrl-ma35.c b/drivers/pinctrl/nuvoton/pinctrl-ma35.c
index 54652bfbe6ac..cdad01d68a37 100644
--- a/drivers/pinctrl/nuvoton/pinctrl-ma35.c
+++ b/drivers/pinctrl/nuvoton/pinctrl-ma35.c
@@ -1038,7 +1038,8 @@ static int ma35_pinctrl_parse_functions(struct fwnode_handle *fwnode, struct ma3
 	struct group_desc *grp;
 	static u32 grp_index;
 	const char **groups;
-	u32 ret, i = 0;
+	u32 i = 0;
+	int ret;
 
 	dev_dbg(npctl->dev, "parse function(%d): %s\n", index, np->name);
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 3/3] pinctrl: renesas: Use int type to store negative error codes
  2025-08-31  8:49 [PATCH 0/3] pinctrl: Use int type to store negative error codes Qianfeng Rong
  2025-08-31  8:49 ` [PATCH 1/3] pinctrl: armada-37xx: " Qianfeng Rong
  2025-08-31  8:49 ` [PATCH 2/3] pinctrl: ma35: " Qianfeng Rong
@ 2025-08-31  8:49 ` Qianfeng Rong
  2025-09-01  9:07   ` Geert Uytterhoeven
  2 siblings, 1 reply; 10+ messages in thread
From: Qianfeng Rong @ 2025-08-31  8:49 UTC (permalink / raw)
  To: Geert Uytterhoeven, Linus Walleij,
	open list:PIN CONTROLLER - RENESAS,
	open list:PIN CONTROL SUBSYSTEM, open list
  Cc: Qianfeng Rong

Change the 'ret' variable in ma35_pinctrl_parse_functions() from unsigned
int to int, as it needs to store either negative error codes or zero
returned by sh_pfc_pinconf_set().

No effect on runtime.

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

diff --git a/drivers/pinctrl/renesas/pinctrl.c b/drivers/pinctrl/renesas/pinctrl.c
index 29d16c9c1bd1..3a742f74ecd1 100644
--- a/drivers/pinctrl/renesas/pinctrl.c
+++ b/drivers/pinctrl/renesas/pinctrl.c
@@ -726,7 +726,8 @@ static int sh_pfc_pinconf_group_set(struct pinctrl_dev *pctldev, unsigned group,
 	struct sh_pfc_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev);
 	const unsigned int *pins;
 	unsigned int num_pins;
-	unsigned int i, ret;
+	unsigned int i;
+	int ret;
 
 	pins = pmx->pfc->info->groups[group].pins;
 	num_pins = pmx->pfc->info->groups[group].nr_pins;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/3] pinctrl: armada-37xx: Use int type to store negative error codes
  2025-08-31  8:49 ` [PATCH 1/3] pinctrl: armada-37xx: " Qianfeng Rong
@ 2025-08-31 14:41   ` Andrew Lunn
  2025-09-01 13:11   ` Linus Walleij
  1 sibling, 0 replies; 10+ messages in thread
From: Andrew Lunn @ 2025-08-31 14:41 UTC (permalink / raw)
  To: Qianfeng Rong
  Cc: Gregory Clement, Sebastian Hesselbarth, Linus Walleij,
	Bartosz Golaszewski,
	moderated list:ARM/Marvell Kirkwood and Armada 370, 375, 38x,...,
	open list:PIN CONTROL SUBSYSTEM, open list

On Sun, Aug 31, 2025 at 04:49:56PM +0800, Qianfeng Rong wrote:
> In armada_37xx_gpio_direction_output(), the 'ret' variable might store
> the negative error codes returned by regmap_update_bits(), and in
> armada_37xx_edge_both_irq_swap_pol(), the 'ret' variable directly
> stores -1, so the type of the 'ret' variable needs to be changed to
> int in both cases.
> 
> No effect on runtime.
> 
> Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 3/3] pinctrl: renesas: Use int type to store negative error codes
  2025-08-31  8:49 ` [PATCH 3/3] pinctrl: renesas: " Qianfeng Rong
@ 2025-09-01  9:07   ` Geert Uytterhoeven
  2025-09-01 10:13     ` Qianfeng Rong
  0 siblings, 1 reply; 10+ messages in thread
From: Geert Uytterhoeven @ 2025-09-01  9:07 UTC (permalink / raw)
  To: Qianfeng Rong
  Cc: Linus Walleij, open list:PIN CONTROLLER - RENESAS,
	open list:PIN CONTROL SUBSYSTEM, open list

Hi Qianfeng,

Thanks for your patch!

On Sun, 31 Aug 2025 at 10:50, Qianfeng Rong <rongqianfeng@vivo.com> wrote:
> Change the 'ret' variable in ma35_pinctrl_parse_functions() from unsigned

sh_pfc_pinconf_group_set

> int to int, as it needs to store either negative error codes or zero
> returned by sh_pfc_pinconf_set().
>
> No effect on runtime.

Fortunately the issue was indeed harmless.

>
> Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>

Fixes: d0593c363f04ccc4 ("pinctrl: sh-pfc: Propagate errors on group config")
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
i.e. will queue in renesas-pinctrl for v6.18, with the above fixed.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 3/3] pinctrl: renesas: Use int type to store negative error codes
  2025-09-01  9:07   ` Geert Uytterhoeven
@ 2025-09-01 10:13     ` Qianfeng Rong
  2025-09-01 10:25       ` Geert Uytterhoeven
  0 siblings, 1 reply; 10+ messages in thread
From: Qianfeng Rong @ 2025-09-01 10:13 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Linus Walleij, open list:PIN CONTROLLER - RENESAS,
	open list:PIN CONTROL SUBSYSTEM, open list


在 2025/9/1 17:07, Geert Uytterhoeven 写道:
> Hi Qianfeng,
>
> Thanks for your patch!
>
> On Sun, 31 Aug 2025 at 10:50, Qianfeng Rong <rongqianfeng@vivo.com> wrote:
>> Change the 'ret' variable in ma35_pinctrl_parse_functions() from unsigned
> sh_pfc_pinconf_group_set


Thank you for pointing out my mistake.

>
>> int to int, as it needs to store either negative error codes or zero
>> returned by sh_pfc_pinconf_set().
>>
>> No effect on runtime.
> Fortunately the issue was indeed harmless.
>
>> Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
> Fixes: d0593c363f04ccc4 ("pinctrl: sh-pfc: Propagate errors on group config")
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
> i.e. will queue in renesas-pinctrl for v6.18, with the above fixed.


Will do in the next version.

>
> Gr{oetje,eeting}s,
>
>                          Geert
Best regards,
Qianfeng

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 3/3] pinctrl: renesas: Use int type to store negative error codes
  2025-09-01 10:13     ` Qianfeng Rong
@ 2025-09-01 10:25       ` Geert Uytterhoeven
  0 siblings, 0 replies; 10+ messages in thread
From: Geert Uytterhoeven @ 2025-09-01 10:25 UTC (permalink / raw)
  To: Qianfeng Rong
  Cc: Linus Walleij, open list:PIN CONTROLLER - RENESAS,
	open list:PIN CONTROL SUBSYSTEM, open list

Hi Qianfeng,

On Mon, 1 Sept 2025 at 12:13, Qianfeng Rong <rongqianfeng@vivo.com> wrote:
> 在 2025/9/1 17:07, Geert Uytterhoeven 写道:
> > On Sun, 31 Aug 2025 at 10:50, Qianfeng Rong <rongqianfeng@vivo.com> wrote:
> >> Change the 'ret' variable in ma35_pinctrl_parse_functions() from unsigned
> > sh_pfc_pinconf_group_set
>
> Thank you for pointing out my mistake.
>
> >> int to int, as it needs to store either negative error codes or zero
> >> returned by sh_pfc_pinconf_set().
> >>
> >> No effect on runtime.
> > Fortunately the issue was indeed harmless.
> >
> >> Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
> > Fixes: d0593c363f04ccc4 ("pinctrl: sh-pfc: Propagate errors on group config")
> > Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
> > i.e. will queue in renesas-pinctrl for v6.18, with the above fixed.
>
> Will do in the next version.

There is no need to resend; I will fix this up while applying.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/3] pinctrl: armada-37xx: Use int type to store negative error codes
  2025-08-31  8:49 ` [PATCH 1/3] pinctrl: armada-37xx: " Qianfeng Rong
  2025-08-31 14:41   ` Andrew Lunn
@ 2025-09-01 13:11   ` Linus Walleij
  1 sibling, 0 replies; 10+ messages in thread
From: Linus Walleij @ 2025-09-01 13:11 UTC (permalink / raw)
  To: Qianfeng Rong
  Cc: Andrew Lunn, Gregory Clement, Sebastian Hesselbarth,
	Bartosz Golaszewski,
	moderated list:ARM/Marvell Kirkwood and Armada 370, 375, 38x,...,
	open list:PIN CONTROL SUBSYSTEM, open list

On Sun, Aug 31, 2025 at 10:50 AM Qianfeng Rong <rongqianfeng@vivo.com> wrote:

> In armada_37xx_gpio_direction_output(), the 'ret' variable might store
> the negative error codes returned by regmap_update_bits(), and in
> armada_37xx_edge_both_irq_swap_pol(), the 'ret' variable directly
> stores -1, so the type of the 'ret' variable needs to be changed to
> int in both cases.
>
> No effect on runtime.
>
> Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>

This patch (1/3) applied for next in the pinctrl tree.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/3] pinctrl: ma35: Use int type to store negative error codes
  2025-08-31  8:49 ` [PATCH 2/3] pinctrl: ma35: " Qianfeng Rong
@ 2025-09-01 13:11   ` Linus Walleij
  0 siblings, 0 replies; 10+ messages in thread
From: Linus Walleij @ 2025-09-01 13:11 UTC (permalink / raw)
  To: Qianfeng Rong
  Cc: Jacky Huang, Shan-Chun Hung,
	moderated list:ARM/NUVOTON MA35 ARCHITECTURE,
	open list:PIN CONTROL SUBSYSTEM, open list

On Sun, Aug 31, 2025 at 10:50 AM Qianfeng Rong <rongqianfeng@vivo.com> wrote:

> Change the 'ret' variable in ma35_pinctrl_parse_functions() from u32 to
> int, as it needs to store either negative error codes or zero returned
> by ma35_pinctrl_parse_groups().
>
> No effect on runtime.
>
> Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>

This patch (2/3) applied for next in the pinctrl tree.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2025-09-01 13:11 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-31  8:49 [PATCH 0/3] pinctrl: Use int type to store negative error codes Qianfeng Rong
2025-08-31  8:49 ` [PATCH 1/3] pinctrl: armada-37xx: " Qianfeng Rong
2025-08-31 14:41   ` Andrew Lunn
2025-09-01 13:11   ` Linus Walleij
2025-08-31  8:49 ` [PATCH 2/3] pinctrl: ma35: " Qianfeng Rong
2025-09-01 13:11   ` Linus Walleij
2025-08-31  8:49 ` [PATCH 3/3] pinctrl: renesas: " Qianfeng Rong
2025-09-01  9:07   ` Geert Uytterhoeven
2025-09-01 10:13     ` Qianfeng Rong
2025-09-01 10:25       ` Geert Uytterhoeven

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).