From 9310bd4bf20ff9ab180a0158f917b1d9af3247dc Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Fri, 22 Jul 2022 09:29:07 +0300 Subject: [PATCH] usb: typec: anx7411: fix error checking in anx7411_get_gpio_irq() This is a minor bug which means that certain error messages are not printed. The devm_gpiod_get_optional() function can return either error pointers or NULL. It returns error pointers if there is an allocation failure, or a similar issue. It returns NULL if no GPIO was assigned to the requested function. Print an error in either case. The gpiod_to_irq() function never returns zero. It either returns a positive IRQ number or a negative error code. Fixes: fe6d8a9c8e64 ("usb: typec: anx7411: Add Analogix PD ANX7411 support") Reviewed-by: Xin Ji Signed-off-by: Dan Carpenter Link: https://lore.kernel.org/r/YtpDs8VsWIbl/Smd@kili Signed-off-by: Greg Kroah-Hartman --- drivers/usb/typec/anx7411.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/typec/anx7411.c b/drivers/usb/typec/anx7411.c index 4f7a5cc..311b56a 100644 --- a/drivers/usb/typec/anx7411.c +++ b/drivers/usb/typec/anx7411.c @@ -1326,13 +1326,13 @@ static void anx7411_get_gpio_irq(struct anx7411_data *ctx) struct device *dev = &ctx->tcpc_client->dev; ctx->intp_gpiod = devm_gpiod_get_optional(dev, "interrupt", GPIOD_IN); - if (!ctx->intp_gpiod) { + if (IS_ERR_OR_NULL(ctx->intp_gpiod)) { dev_err(dev, "no interrupt gpio property\n"); return; } ctx->intp_irq = gpiod_to_irq(ctx->intp_gpiod); - if (!ctx->intp_irq) + if (ctx->intp_irq < 0) dev_err(dev, "failed to get GPIO IRQ\n"); } -- 2.7.4