Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1432083 > unrolled thread

[PATCH] pinctrl: stm32: Modify error handling for pinctrl_register

Started byAmitoj Kaur Chawla <amitoj1606@gmail.com>
First post2016-06-27 16:30 +0200
Last post2016-06-29 10:40 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] pinctrl: stm32: Modify error handling for pinctrl_register Amitoj Kaur Chawla <amitoj1606@gmail.com> - 2016-06-27 16:30 +0200
    Re: [PATCH] pinctrl: stm32: Modify error handling for pinctrl_register Linus Walleij <linus.walleij@linaro.org> - 2016-06-29 10:40 +0200

#1432083 — [PATCH] pinctrl: stm32: Modify error handling for pinctrl_register

FromAmitoj Kaur Chawla <amitoj1606@gmail.com>
Date2016-06-27 16:30 +0200
Subject[PATCH] pinctrl: stm32: Modify error handling for pinctrl_register
Message-ID<rOFHY-1ok-33@gated-at.bofh.it>
pinctrl_register returns an ERR_PTR on error.

The Coccinelle semantic patch used to make this change is as follows:

@@
expression e,e1,e2;
@@

e = pinctrl_register(...)
... when != e = e1
if (
-   e == NULL
+   IS_ERR(e)
   ) {
     ...
     return
-      e2
+      PTR_ERR(e)
     ;
     }

Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
---
 drivers/pinctrl/stm32/pinctrl-stm32.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/pinctrl/stm32/pinctrl-stm32.c b/drivers/pinctrl/stm32/pinctrl-stm32.c
index 8deb566..857bb3d 100644
--- a/drivers/pinctrl/stm32/pinctrl-stm32.c
+++ b/drivers/pinctrl/stm32/pinctrl-stm32.c
@@ -814,9 +814,9 @@ int stm32_pctl_probe(struct platform_device *pdev)
 	pctl->dev = &pdev->dev;
 
 	pctl->pctl_dev = pinctrl_register(&pctl->pctl_desc, &pdev->dev, pctl);
-	if (!pctl->pctl_dev) {
+	if (IS_ERR(pctl->pctl_dev)) {
 		dev_err(&pdev->dev, "Failed pinctrl registration\n");
-		return -EINVAL;
+		return PTR_ERR(pctl->pctl_dev);
 	}
 
 	for (i = 0; i < pctl->nbanks; i++)
-- 
1.9.1

[toc] | [next] | [standalone]


#1433569

FromLinus Walleij <linus.walleij@linaro.org>
Date2016-06-29 10:40 +0200
Message-ID<rPjcn-1RY-47@gated-at.bofh.it>
In reply to#1432083
On Mon, Jun 27, 2016 at 4:23 PM, Amitoj Kaur Chawla
<amitoj1606@gmail.com> wrote:

> pinctrl_register returns an ERR_PTR on error.
>
> The Coccinelle semantic patch used to make this change is as follows:
>
> @@
> expression e,e1,e2;
> @@
>
> e = pinctrl_register(...)
> ... when != e = e1
> if (
> -   e == NULL
> +   IS_ERR(e)
>    ) {
>      ...
>      return
> -      e2
> +      PTR_ERR(e)
>      ;
>      }
>
> Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>

I already have a patch like this in my tree it seems.

But very nice that cocinelle is now finding this!

Yours,
Linus Walleij

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web