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

staging: vc04_services: use 'time_left' variable with wait_for_completion_timeout()

There is a confusing pattern in the kernel to use a variable named
'timeout' to store the result of wait_for_completion_timeout() causing
patterns like:

timeout = wait_for_completion_timeout(...)
if (!timeout) return -ETIMEDOUT;

with all kinds of permutations. Use 'time_left' as a variable to make the
code self explaining.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Stefan Wahren <wahrenst@gmx.net>
Link: https://lore.kernel.org/r/20240620182538.5497-2-wsa+renesas@sang-engineering.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Wolfram Sang and committed by
Greg Kroah-Hartman
71f738bb 7dff0b27

+8 -8
+4 -4
drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
··· 591 591 static void stop_streaming(struct vb2_queue *vq) 592 592 { 593 593 int ret; 594 - unsigned long timeout; 594 + unsigned long time_left; 595 595 struct bcm2835_mmal_dev *dev = vb2_get_drv_priv(vq); 596 596 struct vchiq_mmal_port *port = dev->capture.port; 597 597 ··· 636 636 v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev, 637 637 "%s: Waiting for buffers to be returned - %d outstanding\n", 638 638 __func__, atomic_read(&port->buffers_with_vpu)); 639 - timeout = wait_for_completion_timeout(&dev->capture.frame_cmplt, 640 - HZ); 641 - if (timeout == 0) { 639 + time_left = wait_for_completion_timeout(&dev->capture.frame_cmplt, 640 + HZ); 641 + if (time_left == 0) { 642 642 v4l2_err(&dev->v4l2_dev, "%s: Timeout waiting for buffers to be returned - %d outstanding\n", 643 643 __func__, 644 644 atomic_read(&port->buffers_with_vpu));
+4 -4
drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
··· 655 655 { 656 656 struct mmal_msg_context *msg_context; 657 657 int ret; 658 - unsigned long timeout; 658 + unsigned long time_left; 659 659 660 660 /* payload size must not cause message to exceed max size */ 661 661 if (payload_len > ··· 693 693 return ret; 694 694 } 695 695 696 - timeout = wait_for_completion_timeout(&msg_context->u.sync.cmplt, 697 - SYNC_MSG_TIMEOUT * HZ); 698 - if (timeout == 0) { 696 + time_left = wait_for_completion_timeout(&msg_context->u.sync.cmplt, 697 + SYNC_MSG_TIMEOUT * HZ); 698 + if (time_left == 0) { 699 699 pr_err("timed out waiting for sync completion\n"); 700 700 ret = -ETIME; 701 701 /* todo: what happens if the message arrives after aborting */