All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iio: adc: ad9467: Replace PTR_ERR_OR_ZERO() in ad9467_reset()
@ 2025-08-07  1:39 Salah Triki
  2025-08-07  2:07 ` David Lechner
  2025-08-07 20:38 ` Andy Shevchenko
  0 siblings, 2 replies; 3+ messages in thread
From: Salah Triki @ 2025-08-07  1:39 UTC (permalink / raw)
  To: Michael Hennerich, Nuno Sa, Lars-Peter Clausen, Jonathan Cameron,
	David Lechner, Andy Shevchenko, linux-iio, linux-kernel
  Cc: salah.triki

PTR_ERR_OR_ZERO() returns 0 if the argument is NULL, which can hide real
issues when the caller expects an ERR_PTR on failure. Use a ternary
expression instead to return the appropriate error code.

Signed-off-by: Salah Triki <salah.triki@gmail.com>
---
 drivers/iio/adc/ad9467.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/adc/ad9467.c b/drivers/iio/adc/ad9467.c
index f7a9f46ea0dc..70aee2666ff1 100644
--- a/drivers/iio/adc/ad9467.c
+++ b/drivers/iio/adc/ad9467.c
@@ -945,7 +945,7 @@ static int ad9467_reset(struct device *dev)
 
 	gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
 	if (IS_ERR_OR_NULL(gpio))
-		return PTR_ERR_OR_ZERO(gpio);
+		return gpio ? PTR_ERR(gpio) : -ENODEV;
 
 	fsleep(1);
 	gpiod_set_value_cansleep(gpio, 0);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-08-07 20:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-07  1:39 [PATCH] iio: adc: ad9467: Replace PTR_ERR_OR_ZERO() in ad9467_reset() Salah Triki
2025-08-07  2:07 ` David Lechner
2025-08-07 20:38 ` Andy Shevchenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.