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

greybus: gb-beagleplay: Fix timeout handling in bootloader functions

wait_for_completion_timeout() returns the remaining jiffies
(at least 1) on success or 0 on timeout, but never negative
error codes. The current code incorrectly checks for negative
values, causing timeouts to be ignored and treated as success.

Check for a zero return value to correctly identify and
handle timeout events.

Fixes: 0cf7befa3ea2 ("greybus: gb-beagleplay: Add firmware upload API")
Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
Link: https://patch.msgid.link/20251121064027.571-1-vulab@iscas.ac.cn
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Haotian Zhang and committed by
Greg Kroah-Hartman
e6df0f64 8c5d9488

+6 -6
+6 -6
drivers/greybus/gb-beagleplay.c
··· 644 644 645 645 ret = wait_for_completion_timeout( 646 646 &bg->fwl_ack_com, msecs_to_jiffies(CC1352_BOOTLOADER_TIMEOUT)); 647 - if (ret < 0) 648 - return dev_err_probe(&bg->sd->dev, ret, 647 + if (!ret) 648 + return dev_err_probe(&bg->sd->dev, -ETIMEDOUT, 649 649 "Failed to acquire ack semaphore"); 650 650 651 651 switch (READ_ONCE(bg->fwl_ack)) { ··· 683 683 ret = wait_for_completion_timeout( 684 684 &bg->fwl_cmd_response_com, 685 685 msecs_to_jiffies(CC1352_BOOTLOADER_TIMEOUT)); 686 - if (ret < 0) 687 - return dev_err_probe(&bg->sd->dev, ret, 686 + if (!ret) 687 + return dev_err_probe(&bg->sd->dev, -ETIMEDOUT, 688 688 "Failed to acquire last status semaphore"); 689 689 690 690 switch (READ_ONCE(bg->fwl_cmd_response)) { ··· 768 768 ret = wait_for_completion_timeout( 769 769 &bg->fwl_cmd_response_com, 770 770 msecs_to_jiffies(CC1352_BOOTLOADER_TIMEOUT)); 771 - if (ret < 0) 772 - return dev_err_probe(&bg->sd->dev, ret, 771 + if (!ret) 772 + return dev_err_probe(&bg->sd->dev, -ETIMEDOUT, 773 773 "Failed to acquire last status semaphore"); 774 774 775 775 *crc32 = READ_ONCE(bg->fwl_cmd_response);