1

platform: cznic: turris-omnia-mcu: Fix error check in omnia_mcu_register_trng()

The gpiod_to_irq() function never returns zero.  It returns negative
error codes or a positive IRQ number.  Update the checking to check
for negatives.

Fixes: 41bb142a40 ("platform: cznic: turris-omnia-mcu: Add support for MCU provided TRNG")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Marek Behún <kabel@kernel.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
This commit is contained in:
Dan Carpenter 2024-09-05 16:16:53 +03:00 committed by Arnd Bergmann
parent 249d30b515
commit 2d516b8fc0

View File

@ -70,8 +70,8 @@ int omnia_mcu_register_trng(struct omnia_mcu *mcu)
irq_idx = omnia_int_to_gpio_idx[__bf_shf(OMNIA_INT_TRNG)];
irq = gpiod_to_irq(gpio_device_get_desc(mcu->gc.gpiodev, irq_idx));
if (!irq)
return dev_err_probe(dev, -ENXIO, "Cannot get TRNG IRQ\n");
if (irq < 0)
return dev_err_probe(dev, irq, "Cannot get TRNG IRQ\n");
/*
* If someone else cleared the TRNG interrupt but did not read the