Commit 71f738bb authored by Wolfram Sang's avatar Wolfram Sang Committed by Greg Kroah-Hartman
Browse files

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: default avatarWolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: default avatarStefan Wahren <wahrenst@gmx.net>
Link: https://lore.kernel.org/r/20240620182538.5497-2-wsa+renesas@sang-engineering.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 7dff0b27
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -591,7 +591,7 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
static void stop_streaming(struct vb2_queue *vq)
{
	int ret;
	unsigned long timeout;
	unsigned long time_left;
	struct bcm2835_mmal_dev *dev = vb2_get_drv_priv(vq);
	struct vchiq_mmal_port *port = dev->capture.port;

@@ -636,9 +636,9 @@ static void stop_streaming(struct vb2_queue *vq)
		v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev,
			 "%s: Waiting for buffers to be returned - %d outstanding\n",
			 __func__, atomic_read(&port->buffers_with_vpu));
		timeout = wait_for_completion_timeout(&dev->capture.frame_cmplt,
		time_left = wait_for_completion_timeout(&dev->capture.frame_cmplt,
							HZ);
		if (timeout == 0) {
		if (time_left == 0) {
			v4l2_err(&dev->v4l2_dev, "%s: Timeout waiting for buffers to be returned - %d outstanding\n",
				 __func__,
				 atomic_read(&port->buffers_with_vpu));
+4 −4
Original line number Diff line number Diff line
@@ -655,7 +655,7 @@ static int send_synchronous_mmal_msg(struct vchiq_mmal_instance *instance,
{
	struct mmal_msg_context *msg_context;
	int ret;
	unsigned long timeout;
	unsigned long time_left;

	/* payload size must not cause message to exceed max size */
	if (payload_len >
@@ -693,9 +693,9 @@ static int send_synchronous_mmal_msg(struct vchiq_mmal_instance *instance,
		return ret;
	}

	timeout = wait_for_completion_timeout(&msg_context->u.sync.cmplt,
	time_left = wait_for_completion_timeout(&msg_context->u.sync.cmplt,
						SYNC_MSG_TIMEOUT * HZ);
	if (timeout == 0) {
	if (time_left == 0) {
		pr_err("timed out waiting for sync completion\n");
		ret = -ETIME;
		/* todo: what happens if the message arrives after aborting */