diff mbox

i2c: img-scb: match return type of wait_for_completion_timeout

Message ID 1423401155-8955-1-git-send-email-hofrat@osadl.org
State Superseded
Headers show

Commit Message

Nicholas Mc Guire Feb. 8, 2015, 1:12 p.m. UTC
Return type of wait_for_completion_timeout is unsigned long not int. ret in 
img_i2c_reset_bus() was exclusively used for wait_for_completion_timeout so 
its type is simply adjusted. In img_i2c_xfer an appropriately typed variable
is added and assignment fixed up.

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

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-20150204)

 drivers/i2c/busses/i2c-img-scb.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

James Hogan Feb. 9, 2015, 10:53 a.m. UTC | #1
On 08/02/15 13:12, Nicholas Mc Guire wrote:
> Return type of wait_for_completion_timeout is unsigned long not int. ret in 
> img_i2c_reset_bus() was exclusively used for wait_for_completion_timeout so 
> its type is simply adjusted. In img_i2c_xfer an appropriately typed variable
> is added and assignment fixed up.
> 
> Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>

Looks good to me,

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

Thanks
James

> ---
> 
> 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-20150204)
> 
>  drivers/i2c/busses/i2c-img-scb.c |    9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-img-scb.c b/drivers/i2c/busses/i2c-img-scb.c
> index 0fcc169..4f3a153 100644
> --- a/drivers/i2c/busses/i2c-img-scb.c
> +++ b/drivers/i2c/busses/i2c-img-scb.c
> @@ -988,7 +988,7 @@ out:
>  static int img_i2c_reset_bus(struct img_i2c *i2c)
>  {
>  	unsigned long flags;
> -	int ret;
> +	unsigned long ret;
>  
>  	spin_lock_irqsave(&i2c->lock, flags);
>  	reinit_completion(&i2c->msg_complete);
> @@ -1007,6 +1007,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 +1069,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 Feb. 9, 2015, 1:22 p.m. UTC | #2
On Sun, Feb 08, 2015 at 08:12:35AM -0500, Nicholas Mc Guire wrote:
> Return type of wait_for_completion_timeout is unsigned long not int. ret in 
> img_i2c_reset_bus() was exclusively used for wait_for_completion_timeout so 
> its type is simply adjusted. In img_i2c_xfer an appropriately typed variable
> is added and assignment fixed up.
> 
> Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>

Same as for the axxia driver: Please rename the variable because ret
being an int is kind of an idiom.

> ---
> 
> 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-20150204)
> 
>  drivers/i2c/busses/i2c-img-scb.c |    9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-img-scb.c b/drivers/i2c/busses/i2c-img-scb.c
> index 0fcc169..4f3a153 100644
> --- a/drivers/i2c/busses/i2c-img-scb.c
> +++ b/drivers/i2c/busses/i2c-img-scb.c
> @@ -988,7 +988,7 @@ out:
>  static int img_i2c_reset_bus(struct img_i2c *i2c)
>  {
>  	unsigned long flags;
> -	int ret;
> +	unsigned long ret;
>  
>  	spin_lock_irqsave(&i2c->lock, flags);
>  	reinit_completion(&i2c->msg_complete);
> @@ -1007,6 +1007,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 +1069,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;
> -- 
> 1.7.10.4
>
Nicholas Mc Guire Feb. 9, 2015, 2:57 p.m. UTC | #3
On Mon, 09 Feb 2015, Wolfram Sang wrote:

> On Sun, Feb 08, 2015 at 08:12:35AM -0500, Nicholas Mc Guire wrote:
> > Return type of wait_for_completion_timeout is unsigned long not int. ret in 
> > img_i2c_reset_bus() was exclusively used for wait_for_completion_timeout so 
> > its type is simply adjusted. In img_i2c_xfer an appropriately typed variable
> > is added and assignment fixed up.
> > 
> > Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
> 
> Same as for the axxia driver: Please rename the variable because ret
> being an int is kind of an idiom.
>
added "don't break idioms" to my list of Checks - maybe something like this
even should be in SubmittingPatches ?

will fix up and resend.

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..4f3a153 100644
--- a/drivers/i2c/busses/i2c-img-scb.c
+++ b/drivers/i2c/busses/i2c-img-scb.c
@@ -988,7 +988,7 @@  out:
 static int img_i2c_reset_bus(struct img_i2c *i2c)
 {
 	unsigned long flags;
-	int ret;
+	unsigned long ret;
 
 	spin_lock_irqsave(&i2c->lock, flags);
 	reinit_completion(&i2c->msg_complete);
@@ -1007,6 +1007,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 +1069,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;