[char-misc:char-misc-testing 29/36] drivers/nvmem/lan9662-otpc.c:43 lan9662_otp_wait_flag_clear() warn: signedness bug returning '(-110)'

From: Dan Carpenter
Date: Tue Sep 27 2022 - 04:12:15 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git char-misc-testing
head: 0f65caa911019561d71ceb70f0d1c7a965b3045f
commit: 9e8f208ad5229ddda97cd4a83ecf89c735d99592 [29/36] nvmem: lan9662-otp: add support
config: openrisc-randconfig-m041-20220926
compiler: or1k-linux-gcc (GCC) 12.1.0

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>

smatch warnings:
drivers/nvmem/lan9662-otpc.c:43 lan9662_otp_wait_flag_clear() warn: signedness bug returning '(-110)'

vim +43 drivers/nvmem/lan9662-otpc.c

9e8f208ad5229d Horatiu Vultur 2022-09-16 39 static bool lan9662_otp_wait_flag_clear(void __iomem *reg, u32 flag)
9e8f208ad5229d Horatiu Vultur 2022-09-16 40 {
9e8f208ad5229d Horatiu Vultur 2022-09-16 41 u32 val;
9e8f208ad5229d Horatiu Vultur 2022-09-16 42
9e8f208ad5229d Horatiu Vultur 2022-09-16 @43 return readl_poll_timeout(reg, val, !(val & flag),
9e8f208ad5229d Horatiu Vultur 2022-09-16 44 OTP_SLEEP_US, OTP_TIMEOUT_US);


readl_poll_timeout() returns zero on success or a negative error code.
Better to make lan9662_otp_wait_flag_clear() return ints. Returning
false/true (as opposed to true/false or zero/negative) for
success/failure is pants.

9e8f208ad5229d Horatiu Vultur 2022-09-16 45 }