linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] i2c: mv64xxx: remove unreachable signal case handling
@ 2015-06-11 15:27 Nicholas Mc Guire
       [not found] ` <1434036453-23336-1-git-send-email-hofrat-Q945KHDl0DbYtjvyW6yDsg@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Nicholas Mc Guire @ 2015-06-11 15:27 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Thomas Petazzoni, Maxime Ripard, Andrew Lunn, Chen-Yu Tsai,
	linux-i2c, linux-kernel, Nicholas Mc Guire

'commit d295a86eab20 ("i2c: mv64xxx: work around signals causing I2C
transactions to be aborted")' removed the wait_event_interruptible_timeout 
to prevent half/mixed i2c messages from being sent/received but forgot to
drop the signal received cases in the return handling. This just removes
this dead code and simplifies the error message as "time_left" only can be 
0 here and thus it conveys no additional information.

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

Patch was compile tested with multi_v7_defconfig 
(implies CONFIG_I2C_MV64XXX=y)

Patch is against 4.1-rc7 (localversion-next is -next-20150611)

 drivers/i2c/busses/i2c-mv64xxx.c |   15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c
index 30059c1..a4f8ece 100644
--- a/drivers/i2c/busses/i2c-mv64xxx.c
+++ b/drivers/i2c/busses/i2c-mv64xxx.c
@@ -534,7 +534,6 @@ mv64xxx_i2c_wait_for_completion(struct mv64xxx_i2c_data *drv_data)
 {
 	long		time_left;
 	unsigned long	flags;
-	char		abort = 0;
 
 	time_left = wait_event_timeout(drv_data->waitq,
 		!drv_data->block, drv_data->adapter.timeout);
@@ -542,25 +541,17 @@ mv64xxx_i2c_wait_for_completion(struct mv64xxx_i2c_data *drv_data)
 	spin_lock_irqsave(&drv_data->lock, flags);
 	if (!time_left) { /* Timed out */
 		drv_data->rc = -ETIMEDOUT;
-		abort = 1;
-	} else if (time_left < 0) { /* Interrupted/Error */
-		drv_data->rc = time_left; /* errno value */
-		abort = 1;
-	}
-
-	if (abort && drv_data->block) {
 		drv_data->aborting = 1;
 		spin_unlock_irqrestore(&drv_data->lock, flags);
 
 		time_left = wait_event_timeout(drv_data->waitq,
 			!drv_data->block, drv_data->adapter.timeout);
 
-		if ((time_left <= 0) && drv_data->block) {
+		if (time_left == 0) {
 			drv_data->state = MV64XXX_I2C_STATE_IDLE;
 			dev_err(&drv_data->adapter.dev,
-				"mv64xxx: I2C bus locked, block: %d, "
-				"time_left: %d\n", drv_data->block,
-				(int)time_left);
+				"mv64xxx: I2C bus locked, block: %d\n",
+				drv_data->block);
 			mv64xxx_i2c_hw_init(drv_data);
 		}
 	} else
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] i2c: mv64xxx: remove unreachable signal case handling
       [not found] ` <1434036453-23336-1-git-send-email-hofrat-Q945KHDl0DbYtjvyW6yDsg@public.gmane.org>
@ 2015-06-17 13:00   ` Wolfram Sang
  2015-06-17 13:16     ` Gregory CLEMENT
  0 siblings, 1 reply; 4+ messages in thread
From: Wolfram Sang @ 2015-06-17 13:00 UTC (permalink / raw)
  To: Nicholas Mc Guire
  Cc: Thomas Petazzoni, Maxime Ripard, Andrew Lunn, Chen-Yu Tsai,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 2819 bytes --]

On Thu, Jun 11, 2015 at 05:27:33PM +0200, Nicholas Mc Guire wrote:
> 'commit d295a86eab20 ("i2c: mv64xxx: work around signals causing I2C
> transactions to be aborted")' removed the wait_event_interruptible_timeout 
> to prevent half/mixed i2c messages from being sent/received but forgot to
> drop the signal received cases in the return handling. This just removes
> this dead code and simplifies the error message as "time_left" only can be 
> 0 here and thus it conveys no additional information.
> 
> Signed-off-by: Nicholas Mc Guire <hofrat-Q945KHDl0DbYtjvyW6yDsg@public.gmane.org>
> ---
> 
> Patch was compile tested with multi_v7_defconfig 
> (implies CONFIG_I2C_MV64XXX=y)
> 
> Patch is against 4.1-rc7 (localversion-next is -next-20150611)

Hmm, IMO this patch is too intrusive to be applied without actual
testing.

> 
>  drivers/i2c/busses/i2c-mv64xxx.c |   15 +++------------
>  1 file changed, 3 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c
> index 30059c1..a4f8ece 100644
> --- a/drivers/i2c/busses/i2c-mv64xxx.c
> +++ b/drivers/i2c/busses/i2c-mv64xxx.c
> @@ -534,7 +534,6 @@ mv64xxx_i2c_wait_for_completion(struct mv64xxx_i2c_data *drv_data)
>  {
>  	long		time_left;
>  	unsigned long	flags;
> -	char		abort = 0;
>  
>  	time_left = wait_event_timeout(drv_data->waitq,
>  		!drv_data->block, drv_data->adapter.timeout);
> @@ -542,25 +541,17 @@ mv64xxx_i2c_wait_for_completion(struct mv64xxx_i2c_data *drv_data)
>  	spin_lock_irqsave(&drv_data->lock, flags);
>  	if (!time_left) { /* Timed out */
>  		drv_data->rc = -ETIMEDOUT;
> -		abort = 1;
> -	} else if (time_left < 0) { /* Interrupted/Error */
> -		drv_data->rc = time_left; /* errno value */
> -		abort = 1;
> -	}
> -
> -	if (abort && drv_data->block) {
>  		drv_data->aborting = 1;
>  		spin_unlock_irqrestore(&drv_data->lock, flags);
>  
>  		time_left = wait_event_timeout(drv_data->waitq,
>  			!drv_data->block, drv_data->adapter.timeout);
>  
> -		if ((time_left <= 0) && drv_data->block) {

I am especially unsure about the drv_data->block removal. Did you double
check if we can do this?

> +		if (time_left == 0) {
>  			drv_data->state = MV64XXX_I2C_STATE_IDLE;
>  			dev_err(&drv_data->adapter.dev,
> -				"mv64xxx: I2C bus locked, block: %d, "
> -				"time_left: %d\n", drv_data->block,
> -				(int)time_left);
> +				"mv64xxx: I2C bus locked, block: %d\n",
> +				drv_data->block);

And if so, shouldn't that also be always 1 in the output here?

>  			mv64xxx_i2c_hw_init(drv_data);
>  		}
>  	} else

Maybe (not sure) it also helps to split the patch into everything
dealing with time_left as patch 1) and simplifying by drv_data->block
removal as patch2?

Thanks,

   Wolfram


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] i2c: mv64xxx: remove unreachable signal case handling
  2015-06-17 13:00   ` Wolfram Sang
@ 2015-06-17 13:16     ` Gregory CLEMENT
       [not found]       ` <5581731B.10506-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Gregory CLEMENT @ 2015-06-17 13:16 UTC (permalink / raw)
  To: Wolfram Sang, Nicholas Mc Guire
  Cc: Thomas Petazzoni, Maxime Ripard, Andrew Lunn, Chen-Yu Tsai,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

Hi Wolfram, Nicholas,

On 17/06/2015 15:00, Wolfram Sang wrote:
> On Thu, Jun 11, 2015 at 05:27:33PM +0200, Nicholas Mc Guire wrote:
>> 'commit d295a86eab20 ("i2c: mv64xxx: work around signals causing I2C
>> transactions to be aborted")' removed the wait_event_interruptible_timeout 
>> to prevent half/mixed i2c messages from being sent/received but forgot to
>> drop the signal received cases in the return handling. This just removes
>> this dead code and simplifies the error message as "time_left" only can be 
>> 0 here and thus it conveys no additional information.
>>
>> Signed-off-by: Nicholas Mc Guire <hofrat-Q945KHDl0DbYtjvyW6yDsg@public.gmane.org>
>> ---
>>
>> Patch was compile tested with multi_v7_defconfig 
>> (implies CONFIG_I2C_MV64XXX=y)
>>
>> Patch is against 4.1-rc7 (localversion-next is -next-20150611)
> 
> Hmm, IMO this patch is too intrusive to be applied without actual
> testing.
> 
>>
>>  drivers/i2c/busses/i2c-mv64xxx.c |   15 +++------------
>>  1 file changed, 3 insertions(+), 12 deletions(-)
>>
>> diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c
>> index 30059c1..a4f8ece 100644
>> --- a/drivers/i2c/busses/i2c-mv64xxx.c
>> +++ b/drivers/i2c/busses/i2c-mv64xxx.c
>> @@ -534,7 +534,6 @@ mv64xxx_i2c_wait_for_completion(struct mv64xxx_i2c_data *drv_data)
>>  {
>>  	long		time_left;
>>  	unsigned long	flags;
>> -	char		abort = 0;
>>  
>>  	time_left = wait_event_timeout(drv_data->waitq,
>>  		!drv_data->block, drv_data->adapter.timeout);
>> @@ -542,25 +541,17 @@ mv64xxx_i2c_wait_for_completion(struct mv64xxx_i2c_data *drv_data)
>>  	spin_lock_irqsave(&drv_data->lock, flags);
>>  	if (!time_left) { /* Timed out */
>>  		drv_data->rc = -ETIMEDOUT;
>> -		abort = 1;
>> -	} else if (time_left < 0) { /* Interrupted/Error */
>> -		drv_data->rc = time_left; /* errno value */
>> -		abort = 1;
>> -	}
>> -
>> -	if (abort && drv_data->block) {
>>  		drv_data->aborting = 1;
>>  		spin_unlock_irqrestore(&drv_data->lock, flags);
>>  
>>  		time_left = wait_event_timeout(drv_data->waitq,
>>  			!drv_data->block, drv_data->adapter.timeout);
>>  
>> -		if ((time_left <= 0) && drv_data->block) {
> 
> I am especially unsure about the drv_data->block removal. Did you double
> check if we can do this?
> 
>> +		if (time_left == 0) {
>>  			drv_data->state = MV64XXX_I2C_STATE_IDLE;
>>  			dev_err(&drv_data->adapter.dev,
>> -				"mv64xxx: I2C bus locked, block: %d, "
>> -				"time_left: %d\n", drv_data->block,
>> -				(int)time_left);
>> +				"mv64xxx: I2C bus locked, block: %d\n",
>> +				drv_data->block);
> 
> And if so, shouldn't that also be always 1 in the output here?
> 
>>  			mv64xxx_i2c_hw_init(drv_data);
>>  		}
>>  	} else
> 
> Maybe (not sure) it also helps to split the patch into everything
> dealing with time_left as patch 1) and simplifying by drv_data->block
> removal as patch2?

I agree. I would like to see 2 patches. The first one should be not controversial
and could be applied whereas the second one will need a deeper review.

Thanks,

Gregory



-- 
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] i2c: mv64xxx: remove unreachable signal case handling
       [not found]       ` <5581731B.10506-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
@ 2015-06-17 13:49         ` Nicholas Mc Guire
  0 siblings, 0 replies; 4+ messages in thread
From: Nicholas Mc Guire @ 2015-06-17 13:49 UTC (permalink / raw)
  To: Gregory CLEMENT
  Cc: Wolfram Sang, Nicholas Mc Guire, Thomas Petazzoni, Maxime Ripard,
	Andrew Lunn, Chen-Yu Tsai, linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

On Wed, 17 Jun 2015, Gregory CLEMENT wrote:

> Hi Wolfram, Nicholas,
> 
> On 17/06/2015 15:00, Wolfram Sang wrote:
> > On Thu, Jun 11, 2015 at 05:27:33PM +0200, Nicholas Mc Guire wrote:
> >> 'commit d295a86eab20 ("i2c: mv64xxx: work around signals causing I2C
> >> transactions to be aborted")' removed the wait_event_interruptible_timeout 
> >> to prevent half/mixed i2c messages from being sent/received but forgot to
> >> drop the signal received cases in the return handling. This just removes
> >> this dead code and simplifies the error message as "time_left" only can be 
> >> 0 here and thus it conveys no additional information.
> >>
> >> Signed-off-by: Nicholas Mc Guire <hofrat-Q945KHDl0DbYtjvyW6yDsg@public.gmane.org>
> >> ---
> >>
> >> Patch was compile tested with multi_v7_defconfig 
> >> (implies CONFIG_I2C_MV64XXX=y)
> >>
> >> Patch is against 4.1-rc7 (localversion-next is -next-20150611)
> > 
> > Hmm, IMO this patch is too intrusive to be applied without actual
> > testing.
> > 
> >>
> >>  drivers/i2c/busses/i2c-mv64xxx.c |   15 +++------------
> >>  1 file changed, 3 insertions(+), 12 deletions(-)
> >>
> >> diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c
> >> index 30059c1..a4f8ece 100644
> >> --- a/drivers/i2c/busses/i2c-mv64xxx.c
> >> +++ b/drivers/i2c/busses/i2c-mv64xxx.c
> >> @@ -534,7 +534,6 @@ mv64xxx_i2c_wait_for_completion(struct mv64xxx_i2c_data *drv_data)
> >>  {
> >>  	long		time_left;
> >>  	unsigned long	flags;
> >> -	char		abort = 0;
> >>  
> >>  	time_left = wait_event_timeout(drv_data->waitq,
> >>  		!drv_data->block, drv_data->adapter.timeout);
> >> @@ -542,25 +541,17 @@ mv64xxx_i2c_wait_for_completion(struct mv64xxx_i2c_data *drv_data)
> >>  	spin_lock_irqsave(&drv_data->lock, flags);
> >>  	if (!time_left) { /* Timed out */
> >>  		drv_data->rc = -ETIMEDOUT;
> >> -		abort = 1;
> >> -	} else if (time_left < 0) { /* Interrupted/Error */
> >> -		drv_data->rc = time_left; /* errno value */
> >> -		abort = 1;
> >> -	}
> >> -
> >> -	if (abort && drv_data->block) {
> >>  		drv_data->aborting = 1;
> >>  		spin_unlock_irqrestore(&drv_data->lock, flags);
> >>  
> >>  		time_left = wait_event_timeout(drv_data->waitq,
> >>  			!drv_data->block, drv_data->adapter.timeout);
> >>  
> >> -		if ((time_left <= 0) && drv_data->block) {
> > 
> > I am especially unsure about the drv_data->block removal. Did you double
> > check if we can do this?
> > 

The consideration was 
  * wait_event_timeout was checkign !drv_data->block - so it it returned
    the condition held OR timeout
  * since it was a timeout here the condition was NOT met so either both
    are true or both are wrong 
I think the current logic only makes sense if one assumes that a signal case
is also possible.

> >> +		if (time_left == 0) {
> >>  			drv_data->state = MV64XXX_I2C_STATE_IDLE;
> >>  			dev_err(&drv_data->adapter.dev,
> >> -				"mv64xxx: I2C bus locked, block: %d, "
> >> -				"time_left: %d\n", drv_data->block,
> >> -				(int)time_left);
> >> +				"mv64xxx: I2C bus locked, block: %d\n",
> >> +				drv_data->block);
> > 
> > And if so, shouldn't that also be always 1 in the output here?
> > 

yes drv_data->block is 0 | 1 only - so that probably could be dropped 
as well

> >>  			mv64xxx_i2c_hw_init(drv_data);
> >>  		}
> >>  	} else
> > 
> > Maybe (not sure) it also helps to split the patch into everything
> > dealing with time_left as patch 1) and simplifying by drv_data->block
> > removal as patch2?
> 
> I agree. I would like to see 2 patches. The first one should be not controversial
> and could be applied whereas the second one will need a deeper review.
>
thanks - will refactor and split it into two parts
and see if I can get this tested somehow - no urgency
as its really only cleanup.

thx!
hofrat

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-06-17 13:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-11 15:27 [PATCH] i2c: mv64xxx: remove unreachable signal case handling Nicholas Mc Guire
     [not found] ` <1434036453-23336-1-git-send-email-hofrat-Q945KHDl0DbYtjvyW6yDsg@public.gmane.org>
2015-06-17 13:00   ` Wolfram Sang
2015-06-17 13:16     ` Gregory CLEMENT
     [not found]       ` <5581731B.10506-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2015-06-17 13:49         ` Nicholas Mc Guire

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).