diff mbox series

[-next] gpio: Use IS_ERR_OR_NULL() helper function

Message ID 20240828122039.3697037-1-lihongbo22@huawei.com
State New
Headers show
Series [-next] gpio: Use IS_ERR_OR_NULL() helper function | expand

Commit Message

Hongbo Li Aug. 28, 2024, 12:20 p.m. UTC
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>
---
 drivers/gpio/gpiolib.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Bartosz Golaszewski Sept. 2, 2024, 10:06 a.m. UTC | #1
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>


On Wed, 28 Aug 2024 20:20:39 +0800, Hongbo Li wrote:
> 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.
> 
> 
> [...]

Applied, thanks!

[1/1] gpio: Use IS_ERR_OR_NULL() helper function
      commit: 15657d46b8b46d0b0d367d746e75e545bae52678

Best regards,
diff mbox series

Patch

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 3903d0a75304..de425db71111 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -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;