diff mbox series

[6/8] media: solo6x10: use 'time_left' variable with wait_for_completion_timeout()

Message ID 20240603092841.9500-7-wsa+renesas@sang-engineering.com (mailing list archive)
State New
Headers show
Series media: use 'time_left' instead of 'timeout' with wait_*() functions | expand

Commit Message

Wolfram Sang June 3, 2024, 9:28 a.m. UTC
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.

Fix to the proper variable type 'unsigned long' while here.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/media/pci/solo6x10/solo6x10-p2m.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Ismael Luceno June 3, 2024, 4:25 p.m. UTC | #1
On 03/Jun/2024 11:28, Wolfram Sang wrote:
> 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.
> 
> Fix to the proper variable type 'unsigned long' while here.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> ---
>  drivers/media/pci/solo6x10/solo6x10-p2m.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/media/pci/solo6x10/solo6x10-p2m.c b/drivers/media/pci/solo6x10/solo6x10-p2m.c
> index ca70a864a3ef..5f100e5e03d9 100644
> --- a/drivers/media/pci/solo6x10/solo6x10-p2m.c
> +++ b/drivers/media/pci/solo6x10/solo6x10-p2m.c
> @@ -57,7 +57,7 @@ int solo_p2m_dma_desc(struct solo_dev *solo_dev,
>  		      int desc_cnt)
>  {
>  	struct solo_p2m_dev *p2m_dev;
> -	unsigned int timeout;
> +	unsigned long time_left;
>  	unsigned int config = 0;
>  	int ret = 0;
>  	unsigned int p2m_id = 0;
> @@ -99,12 +99,12 @@ int solo_p2m_dma_desc(struct solo_dev *solo_dev,
>  			       desc[1].ctrl);
>  	}
>  
> -	timeout = wait_for_completion_timeout(&p2m_dev->completion,
> -					      solo_dev->p2m_jiffies);
> +	time_left = wait_for_completion_timeout(&p2m_dev->completion,
> +						solo_dev->p2m_jiffies);
>  
>  	if (WARN_ON_ONCE(p2m_dev->error))
>  		ret = -EIO;
> -	else if (timeout == 0) {
> +	else if (time_left == 0) {
>  		solo_dev->p2m_timeouts++;
>  		ret = -EAGAIN;
>  	}

Signed-off-by: Ismael Luceno <ismael@iodev.co.uk>
Ismael Luceno June 3, 2024, 4:28 p.m. UTC | #2
On 03/Jun/2024 18:25, Ismael Luceno wrote:
> On 03/Jun/2024 11:28, Wolfram Sang wrote:
> > 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.
> > 
> > Fix to the proper variable type 'unsigned long' while here.
> > 
> > Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> > ---
> >  drivers/media/pci/solo6x10/solo6x10-p2m.c | 8 ++++----
> >  1 file changed, 4 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/media/pci/solo6x10/solo6x10-p2m.c b/drivers/media/pci/solo6x10/solo6x10-p2m.c
> > index ca70a864a3ef..5f100e5e03d9 100644
> > --- a/drivers/media/pci/solo6x10/solo6x10-p2m.c
> > +++ b/drivers/media/pci/solo6x10/solo6x10-p2m.c
> > @@ -57,7 +57,7 @@ int solo_p2m_dma_desc(struct solo_dev *solo_dev,
> >  		      int desc_cnt)
> >  {
> >  	struct solo_p2m_dev *p2m_dev;
> > -	unsigned int timeout;
> > +	unsigned long time_left;
> >  	unsigned int config = 0;
> >  	int ret = 0;
> >  	unsigned int p2m_id = 0;
> > @@ -99,12 +99,12 @@ int solo_p2m_dma_desc(struct solo_dev *solo_dev,
> >  			       desc[1].ctrl);
> >  	}
> >  
> > -	timeout = wait_for_completion_timeout(&p2m_dev->completion,
> > -					      solo_dev->p2m_jiffies);
> > +	time_left = wait_for_completion_timeout(&p2m_dev->completion,
> > +						solo_dev->p2m_jiffies);
> >  
> >  	if (WARN_ON_ONCE(p2m_dev->error))
> >  		ret = -EIO;
> > -	else if (timeout == 0) {
> > +	else if (time_left == 0) {
> >  		solo_dev->p2m_timeouts++;
> >  		ret = -EAGAIN;
> >  	}
> 
> Signed-off-by: Ismael Luceno <ismael@iodev.co.uk>

Sorry, I meant Acked-by.
diff mbox series

Patch

diff --git a/drivers/media/pci/solo6x10/solo6x10-p2m.c b/drivers/media/pci/solo6x10/solo6x10-p2m.c
index ca70a864a3ef..5f100e5e03d9 100644
--- a/drivers/media/pci/solo6x10/solo6x10-p2m.c
+++ b/drivers/media/pci/solo6x10/solo6x10-p2m.c
@@ -57,7 +57,7 @@  int solo_p2m_dma_desc(struct solo_dev *solo_dev,
 		      int desc_cnt)
 {
 	struct solo_p2m_dev *p2m_dev;
-	unsigned int timeout;
+	unsigned long time_left;
 	unsigned int config = 0;
 	int ret = 0;
 	unsigned int p2m_id = 0;
@@ -99,12 +99,12 @@  int solo_p2m_dma_desc(struct solo_dev *solo_dev,
 			       desc[1].ctrl);
 	}
 
-	timeout = wait_for_completion_timeout(&p2m_dev->completion,
-					      solo_dev->p2m_jiffies);
+	time_left = wait_for_completion_timeout(&p2m_dev->completion,
+						solo_dev->p2m_jiffies);
 
 	if (WARN_ON_ONCE(p2m_dev->error))
 		ret = -EIO;
-	else if (timeout == 0) {
+	else if (time_left == 0) {
 		solo_dev->p2m_timeouts++;
 		ret = -EAGAIN;
 	}