]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
gpio: Use IS_ERR_OR_NULL() helper function
authorHongbo Li <lihongbo22@huawei.com>
Wed, 28 Aug 2024 12:20:39 +0000 (20:20 +0800)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Mon, 2 Sep 2024 10:27:35 +0000 (12:27 +0200)
Use the IS_ERR_OR_NULL() helper instead of open-coding a
NULL and an error pointer checks to simplify the code and
improve readability.

No functional changes are intended.

Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
Link: https://lore.kernel.org/r/20240828122039.3697037-1-lihongbo22@huawei.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
drivers/gpio/gpiolib.c

index 3903d0a75304cbf4c81fd5e2d31f3530363fa0c5..de425db71111a185afb84771f6e8ca43b74ec4a3 100644 (file)
@@ -356,7 +356,7 @@ int gpiod_get_direction(struct gpio_desc *desc)
         * We cannot use VALIDATE_DESC() as we must not return 0 for a NULL
         * descriptor like we usually do.
         */
-       if (!desc || IS_ERR(desc))
+       if (IS_ERR_OR_NULL(desc))
                return -EINVAL;
 
        CLASS(gpio_chip_guard, guard)(desc);
@@ -3591,7 +3591,7 @@ int gpiod_to_irq(const struct gpio_desc *desc)
         * requires this function to not return zero on an invalid descriptor
         * but rather a negative error number.
         */
-       if (!desc || IS_ERR(desc))
+       if (IS_ERR_OR_NULL(desc))
                return -EINVAL;
 
        gdev = desc->gdev;