From: Dan Carpenter Date: Fri, 19 Mar 2021 14:47:31 +0000 (+0300) Subject: wilc1000: fix a loop timeout condition X-Git-Tag: accepted/tizen/unified/20230118.172025~7335^2~113^2~19 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2f51061edab942988b1a3c057d21228e938603db;p=platform%2Fkernel%2Flinux-rpi.git wilc1000: fix a loop timeout condition If the loop fails, the "while(trials--) {" loop will exit with "trials" set to -1. The test for that expects it to end with "trials" set to 0 so the warning message will not be printed. Fix this by changing from a post-op to a pre-op. This does mean that we only make 99 attempts instead of 100 but that's okay. Fixes: f135a1571a05 ("wilc1000: Support chip sleep over SPI") Signed-off-by: Dan Carpenter Acked-by: Ajay Singh Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/YFS5gx/gi70zlIaO@mwanda --- diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index d4a90c4..2030fc7 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -575,7 +575,7 @@ void chip_allow_sleep(struct wilc *wilc) to_host_from_fw_bit = WILC_SPI_FW_TO_HOST_BIT; } - while (trials--) { + while (--trials) { ret = hif_func->hif_read_reg(wilc, to_host_from_fw_reg, ®); if (ret) return;