All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wolfram Sang <wsa+renesas@sang-engineering.com>
To: linux-i2c@vger.kernel.org
Cc: linux-renesas-soc@vger.kernel.org,
	Wolfram Sang <wsa+renesas@sang-engineering.com>
Subject: [PATCH] i2c: recovery: directly exit when SCL is stuck low
Date: Sat, 30 Jun 2018 19:08:13 +0200	[thread overview]
Message-ID: <20180630170813.13194-1-wsa+renesas@sang-engineering.com> (raw)

If SCL is stuck low, the bus cannot be recovered. No need to check SDA
or futilely trying to send a STOP. Just exit.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/i2c/i2c-core-base.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index bfefeb2ab2fd..cbbfe3fd387b 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -189,7 +189,7 @@ int i2c_generic_scl_recovery(struct i2c_adapter *adap)
 				dev_err(&adap->dev,
 					"SCL is stuck low, exit recovery\n");
 				ret = -EBUSY;
-				break;
+				goto exit_unprepare;
 			}
 			/* Break if SDA is high */
 			if (bri->get_sda && bri->get_sda(adap))
@@ -227,6 +227,7 @@ int i2c_generic_scl_recovery(struct i2c_adapter *adap)
 		ndelay(RECOVERY_NDELAY / 2);
 	}
 
+ exit_unprepare:
 	if (bri->unprepare_recovery)
 		bri->unprepare_recovery(adap);
 
-- 
2.11.0

                 reply	other threads:[~2018-06-30 17:08 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180630170813.13194-1-wsa+renesas@sang-engineering.com \
    --to=wsa+renesas@sang-engineering.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.