pinctrl:sprd: Check if the pinctrl_dev still exists

Message ID 20230430042254.7543-1-sensor1010@163.com
State New
Headers
Series pinctrl:sprd: Check if the pinctrl_dev still exists |

Commit Message

Lizhe April 30, 2023, 4:22 a.m. UTC
  to check if the pinctrl_dev still exists before calling
pinctrl_unregister().

Signed-off-by: Lizhe <sensor1010@163.com>
---
 drivers/pinctrl/sprd/pinctrl-sprd.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
  

Comments

Andy Shevchenko April 30, 2023, 9:43 a.m. UTC | #1
Sun, Apr 30, 2023 at 12:22:54PM +0800, Lizhe kirjoitti:
> to check if the pinctrl_dev still exists before calling
> pinctrl_unregister().

Besides commit message has no explanation (and English grammar
incorrectness)...

...

> +++ b/drivers/pinctrl/sprd/pinctrl-sprd.c
> @@ -1115,7 +1115,9 @@ int sprd_pinctrl_remove(struct platform_device *pdev)
>  {
>  	struct sprd_pinctrl *sprd_pctl = platform_get_drvdata(pdev);
>  
> -	pinctrl_unregister(sprd_pctl->pctl);

> +	if (sprd_pctl->dev)

...this code is not needed.

> +		pinctrl_unregister(sprd_pctl->pctl);
>  	return 0;
>  }

NAK.
  

Patch

diff --git a/drivers/pinctrl/sprd/pinctrl-sprd.c b/drivers/pinctrl/sprd/pinctrl-sprd.c
index ca9659f4e4b1..6f3369130e8a 100644
--- a/drivers/pinctrl/sprd/pinctrl-sprd.c
+++ b/drivers/pinctrl/sprd/pinctrl-sprd.c
@@ -1115,7 +1115,9 @@  int sprd_pinctrl_remove(struct platform_device *pdev)
 {
 	struct sprd_pinctrl *sprd_pctl = platform_get_drvdata(pdev);
 
-	pinctrl_unregister(sprd_pctl->pctl);
+	if (sprd_pctl->dev)
+		pinctrl_unregister(sprd_pctl->pctl);
+
 	return 0;
 }
 EXPORT_SYMBOL_GPL(sprd_pinctrl_remove);