diff mbox

pinctrl: Delete unnecessary checks before the function call "pinctrl_unregister"

Message ID 563B810B.6050401@users.sourceforge.net
State New
Headers show

Commit Message

SF Markus Elfring Nov. 5, 2015, 4:17 p.m. UTC
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 5 Nov 2015 17:10:22 +0100

The pinctrl_unregister() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c | 3 +--
 drivers/pinctrl/pinctrl-single.c          | 5 +----
 2 files changed, 2 insertions(+), 6 deletions(-)

Comments

Ray Jui Nov. 5, 2015, 4:53 p.m. UTC | #1
On 11/5/2015 8:17 AM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 5 Nov 2015 17:10:22 +0100
>
> The pinctrl_unregister() function tests whether its argument is NULL
> and then returns immediately. Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>   drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c | 3 +--
>   drivers/pinctrl/pinctrl-single.c          | 5 +----
>   2 files changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c b/drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c
> index 12a48f4..663ad0a 100644
> --- a/drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c
> +++ b/drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c
> @@ -638,8 +638,7 @@ static int cygnus_gpio_register_pinconf(struct cygnus_gpio *chip)
>
>   static void cygnus_gpio_unregister_pinconf(struct cygnus_gpio *chip)
>   {
> -	if (chip->pctl)
> -		pinctrl_unregister(chip->pctl);
> +	pinctrl_unregister(chip->pctl);
>   }
>
>   struct cygnus_gpio_data {
> diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
> index ef04b96..d24e5f1 100644
> --- a/drivers/pinctrl/pinctrl-single.c
> +++ b/drivers/pinctrl/pinctrl-single.c
> @@ -1484,10 +1484,7 @@ static void pcs_irq_free(struct pcs_device *pcs)
>   static void pcs_free_resources(struct pcs_device *pcs)
>   {
>   	pcs_irq_free(pcs);
> -
> -	if (pcs->pctl)
> -		pinctrl_unregister(pcs->pctl);
> -
> +	pinctrl_unregister(pcs->pctl);
>   	pcs_free_funcs(pcs);
>   	pcs_free_pingroups(pcs);
>   }
>

The change looks good to me, thanks!

Reviewed-by: Ray Jui <rjui@broadcom.com>

+ Pramod since he's working on changes on the pinctrl-cygnus-gpio driver.

Ray
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Linus Walleij Nov. 17, 2015, 10:50 a.m. UTC | #2
On Thu, Nov 5, 2015 at 5:17 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 5 Nov 2015 17:10:22 +0100
>
> The pinctrl_unregister() function tests whether its argument is NULL
> and then returns immediately. Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Patch applied with Ray's Review tag.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c b/drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c
index 12a48f4..663ad0a 100644
--- a/drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c
+++ b/drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c
@@ -638,8 +638,7 @@  static int cygnus_gpio_register_pinconf(struct cygnus_gpio *chip)
 
 static void cygnus_gpio_unregister_pinconf(struct cygnus_gpio *chip)
 {
-	if (chip->pctl)
-		pinctrl_unregister(chip->pctl);
+	pinctrl_unregister(chip->pctl);
 }
 
 struct cygnus_gpio_data {
diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index ef04b96..d24e5f1 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -1484,10 +1484,7 @@  static void pcs_irq_free(struct pcs_device *pcs)
 static void pcs_free_resources(struct pcs_device *pcs)
 {
 	pcs_irq_free(pcs);
-
-	if (pcs->pctl)
-		pinctrl_unregister(pcs->pctl);
-
+	pinctrl_unregister(pcs->pctl);
 	pcs_free_funcs(pcs);
 	pcs_free_pingroups(pcs);
 }