Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

pinctrl: mediatek: fix check on EINT_NA comparison

Currently, the check on desc->eint.eint_n == EINT_NA is always false
because this is comparing a u16 to -1 which can never be true. Fix
this by casting EINT_NA to u16.

Detected by CoverityScan, CID#1473610 ("Operands don't affect result")

Fixes: fb5fa8dc151b ("pinctrl: mediatek: extend struct mtk_pin_desc to pinctrl-mtk-common-v2.c")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Colin Ian King and committed by
Linus Walleij
7a52127e 22eb8301

+2 -2
+2 -2
drivers/pinctrl/mediatek/pinctrl-moore.c
··· 476 476 477 477 desc = (const struct mtk_pin_desc *)&hw->soc->pins[offset]; 478 478 479 - if (desc->eint.eint_n == EINT_NA) 479 + if (desc->eint.eint_n == (u16)EINT_NA) 480 480 return -ENOTSUPP; 481 481 482 482 return mtk_eint_find_irq(hw->eint, desc->eint.eint_n); ··· 493 493 494 494 if (!hw->eint || 495 495 pinconf_to_config_param(config) != PIN_CONFIG_INPUT_DEBOUNCE || 496 - desc->eint.eint_n == EINT_NA) 496 + desc->eint.eint_n == (u16)EINT_NA) 497 497 return -ENOTSUPP; 498 498 499 499 debounce = pinconf_to_config_argument(config);