linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] i2c: core: only use set_scl for bus recovery after calling prepare_recovery
@ 2015-07-08 14:35 Jan Luebbe
  2015-07-09  7:58 ` Alexander Sverdlin
       [not found] ` <1436366106-11779-1-git-send-email-jlu-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
  0 siblings, 2 replies; 4+ messages in thread
From: Jan Luebbe @ 2015-07-08 14:35 UTC (permalink / raw)
  To: Wolfram Sang, Tony Lindgren, Felipe Balbi
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-omap-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ, Jan Luebbe

Using set_scl may be ineffective before calling the driver specific
prepare_recovery callback, which might change into a test mode. So
instead of setting SCL in i2c_generic_scl_recovery, move it to
i2c_generic_recovery (after the optional prepare_recovery).

Signed-off-by: Jan Luebbe <jlu-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
---
 drivers/i2c/i2c-core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 069a41f116dd..be992b3e0be8 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -567,6 +567,9 @@ static int i2c_generic_recovery(struct i2c_adapter *adap)
 	if (bri->prepare_recovery)
 		bri->prepare_recovery(adap);
 
+	bri->set_scl(adap, val);
+	ndelay(RECOVERY_NDELAY);
+
 	/*
 	 * By this time SCL is high, as we need to give 9 falling-rising edges
 	 */
@@ -597,7 +600,6 @@ static int i2c_generic_recovery(struct i2c_adapter *adap)
 
 int i2c_generic_scl_recovery(struct i2c_adapter *adap)
 {
-	adap->bus_recovery_info->set_scl(adap, 1);
 	return i2c_generic_recovery(adap);
 }
 EXPORT_SYMBOL_GPL(i2c_generic_scl_recovery);
-- 
2.1.4

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

* Re: [PATCH] i2c: core: only use set_scl for bus recovery after calling prepare_recovery
  2015-07-08 14:35 [PATCH] i2c: core: only use set_scl for bus recovery after calling prepare_recovery Jan Luebbe
@ 2015-07-09  7:58 ` Alexander Sverdlin
       [not found] ` <1436366106-11779-1-git-send-email-jlu-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
  1 sibling, 0 replies; 4+ messages in thread
From: Alexander Sverdlin @ 2015-07-09  7:58 UTC (permalink / raw)
  To: ext Jan Luebbe
  Cc: Wolfram Sang, Tony Lindgren, Felipe Balbi, linux-i2c, kernel,
	linux-omap, linux-arm-kernel

Hi!

On 08/07/15 16:35, ext Jan Luebbe wrote:
> Using set_scl may be ineffective before calling the driver specific
> prepare_recovery callback, which might change into a test mode. So
> instead of setting SCL in i2c_generic_scl_recovery, move it to
> i2c_generic_recovery (after the optional prepare_recovery).
> 
> Signed-off-by: Jan Luebbe <jlu@pengutronix.de>

Makes sense,
Acked-by: Alexander Sverdlin <alexander.sverdlin@nokia.com>

> ---
>  drivers/i2c/i2c-core.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
> index 069a41f116dd..be992b3e0be8 100644
> --- a/drivers/i2c/i2c-core.c
> +++ b/drivers/i2c/i2c-core.c
> @@ -567,6 +567,9 @@ static int i2c_generic_recovery(struct i2c_adapter *adap)
>  	if (bri->prepare_recovery)
>  		bri->prepare_recovery(adap);
>  
> +	bri->set_scl(adap, val);
> +	ndelay(RECOVERY_NDELAY);
> +
>  	/*
>  	 * By this time SCL is high, as we need to give 9 falling-rising edges
>  	 */
> @@ -597,7 +600,6 @@ static int i2c_generic_recovery(struct i2c_adapter *adap)
>  
>  int i2c_generic_scl_recovery(struct i2c_adapter *adap)
>  {
> -	adap->bus_recovery_info->set_scl(adap, 1);
>  	return i2c_generic_recovery(adap);
>  }
>  EXPORT_SYMBOL_GPL(i2c_generic_scl_recovery);

-- 
Best regards,
Alexander Sverdlin.

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

* Re: [PATCH] i2c: core: only use set_scl for bus recovery after calling prepare_recovery
       [not found] ` <1436366106-11779-1-git-send-email-jlu-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
@ 2015-07-12 15:31   ` Alexander Sverdlin
  2015-07-31 10:51   ` Wolfram Sang
  1 sibling, 0 replies; 4+ messages in thread
From: Alexander Sverdlin @ 2015-07-12 15:31 UTC (permalink / raw)
  To: Jan Luebbe
  Cc: Wolfram Sang, Tony Lindgren, Felipe Balbi,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ, linux-omap-u79uwXL29TY76Z2rM5mHXA,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

On 08/07/15 16:35, Jan Luebbe wrote:
> Using set_scl may be ineffective before calling the driver specific
> prepare_recovery callback, which might change into a test mode. So
> instead of setting SCL in i2c_generic_scl_recovery, move it to
> i2c_generic_recovery (after the optional prepare_recovery).
> 
> Signed-off-by: Jan Luebbe <jlu-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>

I've tested it with oscilloscope on Beagle Bone Black, makes sense with
your next patch, so:

Tested-by: Alexander Sverdlin <alexander.sverdlin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

> ---
>  drivers/i2c/i2c-core.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
> index 069a41f116dd..be992b3e0be8 100644
> --- a/drivers/i2c/i2c-core.c
> +++ b/drivers/i2c/i2c-core.c
> @@ -567,6 +567,9 @@ static int i2c_generic_recovery(struct i2c_adapter *adap)
>  	if (bri->prepare_recovery)
>  		bri->prepare_recovery(adap);
>  
> +	bri->set_scl(adap, val);
> +	ndelay(RECOVERY_NDELAY);
> +
>  	/*
>  	 * By this time SCL is high, as we need to give 9 falling-rising edges
>  	 */
> @@ -597,7 +600,6 @@ static int i2c_generic_recovery(struct i2c_adapter *adap)
>  
>  int i2c_generic_scl_recovery(struct i2c_adapter *adap)
>  {
> -	adap->bus_recovery_info->set_scl(adap, 1);
>  	return i2c_generic_recovery(adap);
>  }
>  EXPORT_SYMBOL_GPL(i2c_generic_scl_recovery);
> 

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

* Re: [PATCH] i2c: core: only use set_scl for bus recovery after calling prepare_recovery
       [not found] ` <1436366106-11779-1-git-send-email-jlu-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
  2015-07-12 15:31   ` Alexander Sverdlin
@ 2015-07-31 10:51   ` Wolfram Sang
  1 sibling, 0 replies; 4+ messages in thread
From: Wolfram Sang @ 2015-07-31 10:51 UTC (permalink / raw)
  To: Jan Luebbe
  Cc: Tony Lindgren, Felipe Balbi, linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-omap-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ

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

On Wed, Jul 08, 2015 at 04:35:06PM +0200, Jan Luebbe wrote:
> Using set_scl may be ineffective before calling the driver specific
> prepare_recovery callback, which might change into a test mode. So
> instead of setting SCL in i2c_generic_scl_recovery, move it to
> i2c_generic_recovery (after the optional prepare_recovery).
> 
> Signed-off-by: Jan Luebbe <jlu-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>

Applied to for-current, thanks!


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

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

end of thread, other threads:[~2015-07-31 10:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-08 14:35 [PATCH] i2c: core: only use set_scl for bus recovery after calling prepare_recovery Jan Luebbe
2015-07-09  7:58 ` Alexander Sverdlin
     [not found] ` <1436366106-11779-1-git-send-email-jlu-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2015-07-12 15:31   ` Alexander Sverdlin
2015-07-31 10:51   ` Wolfram Sang

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