pinctrl: artpec6: Fix return value check in artpec6_pmx_probe()
Subsystems (3)
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
@@ -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);
Jesper Nilsson
maintainerQuoted 5 lines · Wei Yongjun
From: Wei Yongjun <[email protected]>
In case of error, the function
pinctrl_register()returns NULL notERR_PTR(). TheIS_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
Signed-off-by Wei Yongjun <[email protected]>
/Jesper
Quoted 10 lines
--- drivers/pinctrl/pinctrl-artpec6.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/pinctrl/pinctrl-artpec6.c +0
-0@@ -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
-2pmx->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]
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 inartpec6_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 notERR_PTR(). TheIS_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
PATCH v2 1/1 pinctrl: artpec6: Fix return value check in artpec6_pmx_probe()
In reply to Wei YongjunFrom: 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
@@ -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);
Quoted 7 lines · Wei Yongjun
From: Wei Yongjun <[email protected]>
In case of error, the function
pinctrl_register()returnsERR_PTR()not NULL. The NULL test in the return value check should be replaced withIS_ERR().Signed-off-by Wei Yongjun <[email protected]>
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@@ -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
-2pmx->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]
Quoted 9 lines · Wei Yongjun
From: Wei Yongjun <[email protected]>
In case of error, the function
pinctrl_register()returnsERR_PTR()not NULL. The NULL test in the return value check should be replaced withIS_ERR().Signed-off-by Wei Yongjun <[email protected]>---
v1 -> v2: fix comment
Patch applied with Jesper's ACK.
Yours,
Linus Walleij
Quoted 7 lines · Jesper Nilsson
Quoted 6 lines · Wei Yongjun
From: Wei Yongjun <[email protected]>
In case of error, the function
pinctrl_register()returnsERR_PTR()not NULL. The NULL test in the return value check should be replaced withIS_ERR().
Quoted 6 lines
Quoted 1 line
Signed-off-by Wei Yongjun <[email protected]>Acked-by Jesper Nilsson <[email protected]>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
Jesper Nilsson
maintainerQuoted 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()returnsERR_PTR()not NULL. The NULL test in the return value check should be replaced withIS_ERR().Signed-off-by Wei Yongjun <[email protected]>Acked-by Jesper Nilsson <[email protected]>
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]
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()returnsERR_PTR()not NULL. The NULL test in the return value check should be replaced withIS_ERR().Signed-off-by Wei Yongjun <[email protected]>Acked-by Jesper Nilsson <[email protected]>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
newpinctrl_register_and_init()below instead." Which to me indicates that it is recommended
to use thepinctrl_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