Skip to content

Commit e6df0f6

Browse files
ISCAS-Vulabgregkh
authored andcommitted
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: 0cf7bef ("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>
1 parent 8c5d948 commit e6df0f6

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

drivers/greybus/gb-beagleplay.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -644,8 +644,8 @@ static int cc1352_bootloader_wait_for_ack(struct gb_beagleplay *bg)
644644

645645
ret = wait_for_completion_timeout(
646646
&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,
649649
"Failed to acquire ack semaphore");
650650

651651
switch (READ_ONCE(bg->fwl_ack)) {
@@ -683,8 +683,8 @@ static int cc1352_bootloader_get_status(struct gb_beagleplay *bg)
683683
ret = wait_for_completion_timeout(
684684
&bg->fwl_cmd_response_com,
685685
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,
688688
"Failed to acquire last status semaphore");
689689

690690
switch (READ_ONCE(bg->fwl_cmd_response)) {
@@ -768,8 +768,8 @@ static int cc1352_bootloader_crc32(struct gb_beagleplay *bg, u32 *crc32)
768768
ret = wait_for_completion_timeout(
769769
&bg->fwl_cmd_response_com,
770770
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,
773773
"Failed to acquire last status semaphore");
774774

775775
*crc32 = READ_ONCE(bg->fwl_cmd_response);

0 commit comments

Comments
 (0)