Skip to contentSkip to conversation

pinctrl: artpec6: Fix return value check in artpec6_pmx_probe()

PATCH Superseded Wei Yongjun 5 participants 9 messages Apr 25, 2017 – Apr 28, 2017

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

PATCH 1/1 pinctrl: artpec6: Fix return value check in artpec6_pmx_probe()

From: Wei Yongjun <[email protected]>

In case of error, the function pinctrl_register() returns NULL not ERR_PTR(). The IS_ERR() test in the return value check should be replaced with NULL test.

---
 drivers/pinctrl/pinctrl-artpec6.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pinctrl/pinctrl-artpec6.c +2 -2
index b5a2eff..6a16019 100644
@@ -938,9 +938,9 @@ static int artpec6_pmx_probe(struct platform_device *pdev)
 	pmx->num_pin_groups = ARRAY_SIZE(artpec6_pin_groups);
 	pmx->pctl	    = pinctrl_register(&artpec6_desc, &pdev->dev, pmx);
 
-	if (!pmx->pctl) {
+	if (IS_ERR(pmx->pctl)) {
 		dev_err(&pdev->dev, "could not register pinctrl driver\n");
-		return -EINVAL;
+		return PTR_ERR(pmx->pctl);
 	}
 
 	platform_set_drvdata(pdev, pmx);
maintainer
#1 lore raw
Quoted 5 lines · Wei Yongjun

From: Wei Yongjun <[email protected]>

In case of error, the function pinctrl_register() returns NULL not ERR_PTR(). The IS_ERR() test in the return value check should be replaced with NULL test.

Uh, the comment above reads as the exact opposite of what the patch does. Your point is valid though, but the comment needs rephrasing.

Quoted 1 line

/Jesper

Quoted 10 lines
---
 drivers/pinctrl/pinctrl-artpec6.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pinctrl/pinctrl-artpec6.c +0 -0
index b5a2eff..6a16019 100644
@@ -938,9 +938,9 @@ static int artpec6_pmx_probe(struct platform_device *pdev)
 	pmx->num_pin_groups = ARRAY_SIZE(artpec6_pin_groups);

drivers/pinctrl/pinctrl-artpec6.c static int artpec6_pmx_probe(struct platform_device *pdev) · line 946

Quoted 10 lines
drivers/pinctrl/pinctrl-artpec6.c +2 -2
 	pmx->pctl	    = pinctrl_register(&artpec6_desc, &pdev->dev, pmx);
 
-	if (!pmx->pctl) {
+	if (IS_ERR(pmx->pctl)) {
 		dev_err(&pdev->dev, "could not register pinctrl driver\n");
-		return -EINVAL;
+		return PTR_ERR(pmx->pctl);
 	}
 
 	platform_set_drvdata(pdev, pmx);

/^JN - Jesper Nilsson

Signature · 1 line
               Jesper Nilsson -- [email protected]
#2 lore raw
Quoted 16 lines

-----Original Message-----
From: Jesper Nilsson [mailto:[email protected]]
Sent: Tuesday, April 25, 2017 4:31 PM
To: Wei Yongjun <[email protected]>
Cc: Jesper Nilsson <[email protected]>; Lars Persson <[email protected]>; Niklas Cassel <[email protected]>; Linus Walleij <[email protected]>; weiyongjun (A) <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH -next] pinctrl: artpec6: Fix return value check in artpec6_pmx_probe()

Quoted 2 lines · Wei Yongjun

From: Wei Yongjun <[email protected]>

Quoted 8 lines
Quoted 3 lines

In case of error, the function pinctrl_register() returns NULL not ERR_PTR(). The IS_ERR() test in the return value check should be replaced with NULL test.

Uh, the comment above reads as the exact opposite of what the patch does. Your point is valid though, but the comment needs rephrasing.

Oh, sorry, I will send the v2 patch with comment fixed soon. Thanks.

Wei Yongjun

#3 lore raw

PATCH v2 1/1 pinctrl: artpec6: Fix return value check in artpec6_pmx_probe()

In reply to Wei Yongjun

From: Wei Yongjun <[email protected]>

In case of error, the function pinctrl_register() returns ERR_PTR() not NULL. The NULL test in the return value check should be replaced with IS_ERR().

---
v1 -> v2: fix comment

---
 drivers/pinctrl/pinctrl-artpec6.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pinctrl/pinctrl-artpec6.c +2 -2
index b5a2eff..6a16019 100644
@@ -938,9 +938,9 @@ static int artpec6_pmx_probe(struct platform_device *pdev)
 	pmx->num_pin_groups = ARRAY_SIZE(artpec6_pin_groups);
 	pmx->pctl	    = pinctrl_register(&artpec6_desc, &pdev->dev, pmx);
 
-	if (!pmx->pctl) {
+	if (IS_ERR(pmx->pctl)) {
 		dev_err(&pdev->dev, "could not register pinctrl driver\n");
-		return -EINVAL;
+		return PTR_ERR(pmx->pctl);
 	}
 
 	platform_set_drvdata(pdev, pmx);
maintainer Acked-by on v2 1/1
#4 lore raw
Quoted 7 lines · Wei Yongjun

From: Wei Yongjun <[email protected]>

In case of error, the function pinctrl_register() returns ERR_PTR() not NULL. The NULL test in the return value check should be replaced with IS_ERR().

Although I'm wondering if moving to pinctrl_register_and_init() would sense here. Linus?

/Jesper

Quoted 12 lines

---
v1 -> v2: fix comment

---
 drivers/pinctrl/pinctrl-artpec6.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pinctrl/pinctrl-artpec6.c +0 -0
index b5a2eff..6a16019 100644
@@ -938,9 +938,9 @@ static int artpec6_pmx_probe(struct platform_device *pdev)
 	pmx->num_pin_groups = ARRAY_SIZE(artpec6_pin_groups);

drivers/pinctrl/pinctrl-artpec6.c static int artpec6_pmx_probe(struct platform_device *pdev) · line 946

Quoted 10 lines
drivers/pinctrl/pinctrl-artpec6.c +2 -2
 	pmx->pctl	    = pinctrl_register(&artpec6_desc, &pdev->dev, pmx);
 
-	if (!pmx->pctl) {
+	if (IS_ERR(pmx->pctl)) {
 		dev_err(&pdev->dev, "could not register pinctrl driver\n");
-		return -EINVAL;
+		return PTR_ERR(pmx->pctl);
 	}
 
 	platform_set_drvdata(pdev, pmx);

/^JN - Jesper Nilsson

Signature · 1 line
               Jesper Nilsson -- [email protected]
#5 lore raw
Quoted 7 lines · Jesper Nilsson
Quoted 6 lines · Wei Yongjun

From: Wei Yongjun <[email protected]>

In case of error, the function pinctrl_register() returns ERR_PTR() not NULL. The NULL test in the return value check should be replaced with IS_ERR().

Quoted 6 lines
Quoted 1 line

Although I'm wondering if moving to pinctrl_register_and_init() would sense here. Linus?

That depends, check on the commits introducing it for the usecase.

OTOMH it was introduced for when you have hogs in drivers doing all set-up of groups and functions from the device tree.

Tony?

Yours,
Linus Walleij

maintainer
#6 lore raw
Quoted 12 lines · Linus Walleij
Quoted 11 lines · Jesper Nilsson
Quoted 7 lines · Wei Yongjun

From: Wei Yongjun <[email protected]>

In case of error, the function pinctrl_register() returns ERR_PTR() not NULL. The NULL test in the return value check should be replaced with IS_ERR().

Quoted 8 lines
Quoted 2 lines

Although I'm wondering if moving to pinctrl_register_and_init() would sense here. Linus?

That depends, check on the commits introducing it for the usecase.

OTOMH it was introduced for when you have hogs in drivers doing all set-up of groups and functions from the device tree.

Yeah, so in this case it is not necessary, but the comment above pinctrl_register() explicitly says:
"To avoid issues later on, please use the
new pinctrl_register_and_init() below instead." Which to me indicates that it is recommended
to use the pinctrl_register_and_init() in future code...

Quoted 4 lines

Tony?

Yours,
Linus Walleij

/^JN - Jesper Nilsson

Signature · 1 line
               Jesper Nilsson -- [email protected]
#7 lore raw
Quoted 22 lines · Jesper Nilsson
Quoted 12 lines · Linus Walleij
Quoted 11 lines · Jesper Nilsson
Quoted 7 lines · Wei Yongjun

From: Wei Yongjun <[email protected]>

In case of error, the function pinctrl_register() returns ERR_PTR() not NULL. The NULL test in the return value check should be replaced with IS_ERR().

Quoted 8 lines
Quoted 2 lines

Although I'm wondering if moving to pinctrl_register_and_init() would sense here. Linus?

That depends, check on the commits introducing it for the usecase.

OTOMH it was introduced for when you have hogs in drivers doing all set-up of groups and functions from the device tree.

Quoted 8 lines

Yeah, so in this case it is not necessary, but the comment above pinctrl_register() explicitly says:
"To avoid issues later on, please use the
new pinctrl_register_and_init() below instead." Which to me indicates that it is recommended
to use the pinctrl_register_and_init() in future code...

Quoted 1 line

Tony?

If you want to use GENERIC_PINCTRL_GROUPS or GENERIC_PINMUX_FUNCTIONS want or allocate pins dynamically in the driver, then init needs to be updated. So yeah I'd use that style init for any new code.

Regards,

Tony