[v1,2/2] gpiolib: of: Drop redundant check in of_mm_gpiochip_remove()

Message ID 20221109150734.38874-2-andriy.shevchenko@linux.intel.com
State New
Headers
Series [v1,1/2] gpiolib: of: Prepare of_mm_gpiochip_add_data() for fwnode |

Commit Message

Andy Shevchenko Nov. 9, 2022, 3:07 p.m. UTC
  The callers never call the function with invalid pointer.
Moreover, compiler quite likely dropped that check anyway
because we use that pointer before the check.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/gpio/gpiolib-of.c | 3 ---
 1 file changed, 3 deletions(-)
  

Comments

Dmitry Torokhov Nov. 9, 2022, 9:13 p.m. UTC | #1
On Wed, Nov 09, 2022 at 05:07:34PM +0200, Andy Shevchenko wrote:
> The callers never call the function with invalid pointer.
> Moreover, compiler quite likely dropped that check anyway
> because we use that pointer before the check.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

> ---
>  drivers/gpio/gpiolib-of.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
> index feeb9e8e846d..83997434215e 100644
> --- a/drivers/gpio/gpiolib-of.c
> +++ b/drivers/gpio/gpiolib-of.c
> @@ -963,9 +963,6 @@ void of_mm_gpiochip_remove(struct of_mm_gpio_chip *mm_gc)
>  {
>  	struct gpio_chip *gc = &mm_gc->gc;
>  
> -	if (!mm_gc)
> -		return;
> -
>  	gpiochip_remove(gc);
>  	iounmap(mm_gc->regs);
>  	kfree(gc->label);
> -- 
> 2.35.1
>
  

Patch

diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index feeb9e8e846d..83997434215e 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -963,9 +963,6 @@  void of_mm_gpiochip_remove(struct of_mm_gpio_chip *mm_gc)
 {
 	struct gpio_chip *gc = &mm_gc->gc;
 
-	if (!mm_gc)
-		return;
-
 	gpiochip_remove(gc);
 	iounmap(mm_gc->regs);
 	kfree(gc->label);