2024-06-03 09:38:30

by Wolfram Sang

[permalink] [raw]
Subject: [PATCH 0/8] media: use 'time_left' instead of 'timeout' with wait_*() functions

There is a confusing pattern in the kernel to use a variable named 'timeout' to
store the result of wait_*() functions 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
obvious and self explaining.

This is part of a tree-wide series. The rest of the patches can be found here:

git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/time_left

Because these patches are generated, I audit them before sending. This is why I
will send series step by step. Build bot is happy with these patches, though.
No functional changes intended.

Wolfram Sang (8):
media: allegro: use 'time_left' variable with
wait_for_completion_timeout()
media: atmel-isi: use 'time_left' variable with
wait_for_completion_timeout()
media: bdisp: use 'time_left' variable with wait_event_timeout()
media: fimc-is: use 'time_left' variable with wait_event_timeout()
media: platform: exynos-gsc: use 'time_left' variable with
wait_event_timeout()
media: solo6x10: use 'time_left' variable with
wait_for_completion_timeout()
media: tegra-vde: use 'time_left' variable with
wait_for_completion_interruptible_timeout()
media: ti: cal: use 'time_left' variable with wait_event_timeout()

drivers/media/pci/solo6x10/solo6x10-p2m.c | 8 ++++----
.../media/platform/allegro-dvt/allegro-core.c | 16 ++++++++--------
drivers/media/platform/atmel/atmel-isi.c | 8 ++++----
drivers/media/platform/nvidia/tegra-vde/h264.c | 10 +++++-----
.../media/platform/samsung/exynos-gsc/gsc-core.c | 10 +++++-----
.../platform/samsung/exynos4-is/fimc-core.c | 10 +++++-----
drivers/media/platform/st/sti/bdisp/bdisp-v4l2.c | 10 +++++-----
drivers/media/platform/ti/cal/cal.c | 8 ++++----
8 files changed, 40 insertions(+), 40 deletions(-)

--
2.43.0



2024-06-03 09:39:07

by Wolfram Sang

[permalink] [raw]
Subject: [PATCH 2/8] media: atmel-isi: 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 <[email protected]>
---
drivers/media/platform/atmel/atmel-isi.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/atmel/atmel-isi.c b/drivers/media/platform/atmel/atmel-isi.c
index c1108df72dd5..5c823d3f9cc0 100644
--- a/drivers/media/platform/atmel/atmel-isi.c
+++ b/drivers/media/platform/atmel/atmel-isi.c
@@ -242,7 +242,7 @@ static irqreturn_t isi_interrupt(int irq, void *dev_id)
#define WAIT_ISI_DISABLE 0
static int atmel_isi_wait_status(struct atmel_isi *isi, int wait_reset)
{
- unsigned long timeout;
+ unsigned long time_left;
/*
* The reset or disable will only succeed if we have a
* pixel clock from the camera.
@@ -257,9 +257,9 @@ static int atmel_isi_wait_status(struct atmel_isi *isi, int wait_reset)
isi_writel(isi, ISI_CTRL, ISI_CTRL_DIS);
}

- timeout = wait_for_completion_timeout(&isi->complete,
- msecs_to_jiffies(500));
- if (timeout == 0)
+ time_left = wait_for_completion_timeout(&isi->complete,
+ msecs_to_jiffies(500));
+ if (time_left == 0)
return -ETIMEDOUT;

return 0;
--
2.43.0