All of lore.kernel.org
 help / color / mirror / Atom feed
From: akpm@linux-foundation.org
To: mm-commits@vger.kernel.org
Cc: clifford@clifford.at, khali@linux-fr.org
Subject: + i2c-fix-i2c-mpc-driver-for-multi-master-i2c-busses.patch added to -mm tree
Date: Mon, 22 Dec 2008 13:01:46 -0800	[thread overview]
Message-ID: <200812222101.mBML1kn7021201@imap1.linux-foundation.org> (raw)


The patch titled
     i2c: fix i2c-mpc driver for multi-master i2c busses
has been added to the -mm tree.  Its filename is
     i2c-fix-i2c-mpc-driver-for-multi-master-i2c-busses.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/SubmitChecklist when testing your code ***

See http://userweb.kernel.org/~akpm/stuff/added-to-mm.txt to find
out what to do about this

The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/

------------------------------------------------------
Subject: i2c: fix i2c-mpc driver for multi-master i2c busses
From: Clifford Wolf <clifford@clifford.at>

Simply retry on arbitration lost until xfer is successfull, a
non-arbitration-lost error is triggered or the 1s timeout is hit.

Tested with a freescale MPC8349E host cpu.

Signed-off-by: Clifford Wolf <clifford@clifford.at>
Cc: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 drivers/i2c/busses/i2c-mpc.c |   22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff -puN drivers/i2c/busses/i2c-mpc.c~i2c-fix-i2c-mpc-driver-for-multi-master-i2c-busses drivers/i2c/busses/i2c-mpc.c
--- a/drivers/i2c/busses/i2c-mpc.c~i2c-fix-i2c-mpc-driver-for-multi-master-i2c-busses
+++ a/drivers/i2c/busses/i2c-mpc.c
@@ -134,13 +134,13 @@ static int i2c_wait(struct mpc_i2c *i2c,
 	if (result < 0)
 		return result;
 
-	if (!(x & CSR_MCF)) {
-		pr_debug("I2C: unfinished\n");
-		return -EIO;
-	}
-
 	if (x & CSR_MAL) {
 		pr_debug("I2C: MAL\n");
+		return -EAGAIN;
+	}
+
+	if (!(x & CSR_MCF)) {
+		pr_debug("I2C: unfinished\n");
 		return -EIO;
 	}
 
@@ -257,11 +257,11 @@ static int mpc_read(struct mpc_i2c *i2c,
 static int mpc_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
 {
 	struct i2c_msg *pmsg;
-	int i;
-	int ret = 0;
+	int i, ret;
 	unsigned long orig_jiffies = jiffies;
 	struct mpc_i2c *i2c = i2c_get_adapdata(adap);
 
+restart:
 	mpc_i2c_start(i2c);
 
 	/* Allow bus up to 1s to become not busy */
@@ -281,7 +281,7 @@ static int mpc_xfer(struct i2c_adapter *
 		schedule();
 	}
 
-	for (i = 0; ret >= 0 && i < num; i++) {
+	for (i = 0, ret = 0; ret >= 0 && i < num; i++) {
 		pmsg = &msgs[i];
 		pr_debug("Doing %s %d bytes to 0x%02x - %d of %d messages\n",
 			 pmsg->flags & I2C_M_RD ? "read" : "write",
@@ -292,7 +292,13 @@ static int mpc_xfer(struct i2c_adapter *
 		else
 			ret =
 			    mpc_write(i2c, pmsg->addr, pmsg->buf, pmsg->len, i);
+		if (ret == -EAGAIN) {
+			pr_debug("Lost i2c arbitration -> retry.\n");
+			mpc_i2c_stop(i2c);
+			goto restart;
+		}
 	}
+
 	mpc_i2c_stop(i2c);
 	return (ret < 0) ? ret : num;
 }
_

Patches currently in -mm which might be from clifford@clifford.at are

i2c-fix-i2c-mpc-driver-for-multi-master-i2c-busses.patch


             reply	other threads:[~2008-12-22 21:02 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-22 21:01 akpm [this message]
     [not found] ` <20090108154604.2cade06e@hyperion.delvare>
     [not found] ` <20090109100145.GA12376@clifford.at>
     [not found]   ` <20090214121745.39dfddf9@hyperion.delvare>
     [not found]     ` <200902151653.36860.david-b@pacbell.net>
     [not found]       ` <200902151653.36860.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2009-02-16  8:20         ` + i2c-fix-i2c-mpc-driver-for-multi-master-i2c-busses.patch added to -mm tree Jean Delvare
     [not found]           ` <20090216092000.13af2d74-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2009-02-16 11:58             ` David Brownell
     [not found]               ` <200902160358.48176.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2009-02-16 12:41                 ` Clifford Wolf
2009-02-16 13:08                 ` Handling of i2c arbitration loss (Was: i2c-fix-i2c-mpc-driver-for-multi-master-i2c-busses.patch added to -mm tree) Jean Delvare
     [not found]                   ` <20090216140809.01acaea1-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2009-02-19 19:15                     ` David Brownell
     [not found]                       ` <200902191115.07289.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2009-02-19 21:08                         ` Clifford Wolf
2009-02-19 21:31                         ` Jean Delvare
     [not found]     ` <20090214180014.GA19352@clifford.at>
     [not found]       ` <20090215113122.5bcc3f3d@hyperion.delvare>
     [not found]         ` <20090216131026.GA17437@clifford.at>
     [not found]           ` <20090216131026.GA17437-cPpHkPqGOEfk7+2FdBfRIA@public.gmane.org>
2009-02-19 16:26             ` Handling of i2c arbitration loss Jean Delvare
     [not found]               ` <20090219172605.7e70a797-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2009-02-19 21:23                 ` Clifford Wolf
     [not found]                   ` <20090219212325.GC16107-cPpHkPqGOEfk7+2FdBfRIA@public.gmane.org>
2009-02-20 11:45                     ` Jean Delvare
     [not found]                       ` <20090220124546.193e49f2-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2009-04-09  6:47                         ` Jean Delvare
     [not found]                           ` <20090409084726.3f2bd193-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2009-04-09  8:35                             ` Clifford Wolf
     [not found]                               ` <20090409083553.GA20058-cPpHkPqGOEfk7+2FdBfRIA@public.gmane.org>
2009-04-23 12:24                                 ` Jean Delvare

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=200812222101.mBML1kn7021201@imap1.linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=clifford@clifford.at \
    --cc=khali@linux-fr.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mm-commits@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.