diff mbox

[v2] i2c: img-scb: fixup of wait_for_completion_timeout return handling

Message ID 1423494921-2708-1-git-send-email-hofrat@osadl.org
State Accepted
Headers show

Commit Message

Nicholas Mc Guire Feb. 9, 2015, 3:15 p.m. UTC
Return type of wait_for_completion_timeout is unsigned long not int. 
Appropriately typed/named variable are added and assignment fixed up.

Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
---

v2: int ret is an idiom - thus rather than just changing the type, rename
    the variable, as suggested by Wolfram Sang <wsa@the-dreams.de>.

Patch was compile tested with x86_64_defconfig + CONFIG_COMPILE_TEST=y
CONFIG_I2C_IMG=m

Patch is against 3.19.0-rc7 (localversion-next is -next-20150209)

 drivers/i2c/busses/i2c-img-scb.c |   14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

Comments

James Hogan Feb. 9, 2015, 3:25 p.m. UTC | #1
On 09/02/15 15:15, Nicholas Mc Guire wrote:
> Return type of wait_for_completion_timeout is unsigned long not int. 
> Appropriately typed/named variable are added and assignment fixed up.
> 
> Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>

v2 also:
Acked-by: James Hogan <james.hogan@imgtec.com>

Thanks
James

> ---
> 
> v2: int ret is an idiom - thus rather than just changing the type, rename
>     the variable, as suggested by Wolfram Sang <wsa@the-dreams.de>.
> 
> Patch was compile tested with x86_64_defconfig + CONFIG_COMPILE_TEST=y
> CONFIG_I2C_IMG=m
> 
> Patch is against 3.19.0-rc7 (localversion-next is -next-20150209)
> 
>  drivers/i2c/busses/i2c-img-scb.c |   14 ++++++++------
>  1 file changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-img-scb.c b/drivers/i2c/busses/i2c-img-scb.c
> index 0fcc169..6e4e990 100644
> --- a/drivers/i2c/busses/i2c-img-scb.c
> +++ b/drivers/i2c/busses/i2c-img-scb.c
> @@ -988,15 +988,16 @@ out:
>  static int img_i2c_reset_bus(struct img_i2c *i2c)
>  {
>  	unsigned long flags;
> -	int ret;
> +	unsigned long timeout;
>  
>  	spin_lock_irqsave(&i2c->lock, flags);
>  	reinit_completion(&i2c->msg_complete);
>  	img_i2c_reset_start(i2c);
>  	spin_unlock_irqrestore(&i2c->lock, flags);
>  
> -	ret = wait_for_completion_timeout(&i2c->msg_complete, IMG_I2C_TIMEOUT);
> -	if (ret == 0)
> +	timeout = wait_for_completion_timeout(&i2c->msg_complete,
> +					      IMG_I2C_TIMEOUT);
> +	if (timeout == 0)
>  		return -ETIMEDOUT;
>  	return 0;
>  }
> @@ -1007,6 +1008,7 @@ static int img_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
>  	struct img_i2c *i2c = i2c_get_adapdata(adap);
>  	bool atomic = false;
>  	int i, ret;
> +	unsigned long timeout;
>  
>  	if (i2c->mode == MODE_SUSPEND) {
>  		WARN(1, "refusing to service transaction in suspended state\n");
> @@ -1068,11 +1070,11 @@ static int img_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
>  			img_i2c_write(i2c);
>  		spin_unlock_irqrestore(&i2c->lock, flags);
>  
> -		ret = wait_for_completion_timeout(&i2c->msg_complete,
> -						  IMG_I2C_TIMEOUT);
> +		timeout = wait_for_completion_timeout(&i2c->msg_complete,
> +						      IMG_I2C_TIMEOUT);
>  		del_timer_sync(&i2c->check_timer);
>  
> -		if (ret == 0) {
> +		if (timeout == 0) {
>  			dev_err(adap->dev.parent, "i2c transfer timed out\n");
>  			i2c->msg_status = -ETIMEDOUT;
>  			break;
>
Wolfram Sang March 15, 2015, 10:01 a.m. UTC | #2
On Mon, Feb 09, 2015 at 10:15:21AM -0500, Nicholas Mc Guire wrote:
> Return type of wait_for_completion_timeout is unsigned long not int. 
> Appropriately typed/named variable are added and assignment fixed up.
> 
> Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
> ---

Fixed variable name to 'time_left' and applied to for-next, thanks!
Nicholas Mc Guire March 15, 2015, 10:12 a.m. UTC | #3
On Sun, 15 Mar 2015, Wolfram Sang wrote:

> On Mon, Feb 09, 2015 at 10:15:21AM -0500, Nicholas Mc Guire wrote:
> > Return type of wait_for_completion_timeout is unsigned long not int. 
> > Appropriately typed/named variable are added and assignment fixed up.
> > 
> > Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
> > ---
> 
> Fixed variable name to 'time_left' and applied to for-next, thanks!
> 
thanks - in all of the new cleanups (I hope) the naming
has been considered.

thx!
hofrat

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/i2c/busses/i2c-img-scb.c b/drivers/i2c/busses/i2c-img-scb.c
index 0fcc169..6e4e990 100644
--- a/drivers/i2c/busses/i2c-img-scb.c
+++ b/drivers/i2c/busses/i2c-img-scb.c
@@ -988,15 +988,16 @@  out:
 static int img_i2c_reset_bus(struct img_i2c *i2c)
 {
 	unsigned long flags;
-	int ret;
+	unsigned long timeout;
 
 	spin_lock_irqsave(&i2c->lock, flags);
 	reinit_completion(&i2c->msg_complete);
 	img_i2c_reset_start(i2c);
 	spin_unlock_irqrestore(&i2c->lock, flags);
 
-	ret = wait_for_completion_timeout(&i2c->msg_complete, IMG_I2C_TIMEOUT);
-	if (ret == 0)
+	timeout = wait_for_completion_timeout(&i2c->msg_complete,
+					      IMG_I2C_TIMEOUT);
+	if (timeout == 0)
 		return -ETIMEDOUT;
 	return 0;
 }
@@ -1007,6 +1008,7 @@  static int img_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
 	struct img_i2c *i2c = i2c_get_adapdata(adap);
 	bool atomic = false;
 	int i, ret;
+	unsigned long timeout;
 
 	if (i2c->mode == MODE_SUSPEND) {
 		WARN(1, "refusing to service transaction in suspended state\n");
@@ -1068,11 +1070,11 @@  static int img_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
 			img_i2c_write(i2c);
 		spin_unlock_irqrestore(&i2c->lock, flags);
 
-		ret = wait_for_completion_timeout(&i2c->msg_complete,
-						  IMG_I2C_TIMEOUT);
+		timeout = wait_for_completion_timeout(&i2c->msg_complete,
+						      IMG_I2C_TIMEOUT);
 		del_timer_sync(&i2c->check_timer);
 
-		if (ret == 0) {
+		if (timeout == 0) {
 			dev_err(adap->dev.parent, "i2c transfer timed out\n");
 			i2c->msg_status = -ETIMEDOUT;
 			break;