[PATCH v1 2/7] gpiolib: Revert "Don't WARN on gpiod_put() for optional GPIO"

Andy Shevchenko posted 7 patches 8 months, 1 week ago
There is a newer version of this series
[PATCH v1 2/7] gpiolib: Revert "Don't WARN on gpiod_put() for optional GPIO"
Posted by Andy Shevchenko 8 months, 1 week ago
No need to double check the pointer for NULL since gpiod_free()
is using VALIDATE_DESC_VOID() which simply returns in that case.

This reverts commit 1d7765ba15aca68f3bc52f59434c1c34855bbb54.

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

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 0089745b381f..8ea5ddf4704d 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -5156,8 +5156,7 @@ EXPORT_SYMBOL_GPL(gpiod_get_array_optional);
  */
 void gpiod_put(struct gpio_desc *desc)
 {
-	if (desc)
-		gpiod_free(desc);
+	gpiod_free(desc);
 }
 EXPORT_SYMBOL_GPL(gpiod_put);
 
-- 
2.47.2
Re: [PATCH v1 2/7] gpiolib: Revert "Don't WARN on gpiod_put() for optional GPIO"
Posted by Linus Walleij 8 months, 1 week ago
On Tue, Apr 15, 2025 at 1:11 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:

> No need to double check the pointer for NULL since gpiod_free()
> is using VALIDATE_DESC_VOID() which simply returns in that case.
>
> This reverts commit 1d7765ba15aca68f3bc52f59434c1c34855bbb54.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Well spotted!
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij