linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alan Cox <alan-qBU/x9rampVanCEyBjwyrvXRex20P6io@public.gmane.org>
To: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH 1/2] i2c_intel_mid: Improve error reporting
Date: Wed, 24 Nov 2010 14:49:09 +0000	[thread overview]
Message-ID: <20101124144904.10210.90314.stgit@bob.linux.org.uk> (raw)

From: Catalin Popescu <catalinx.popescu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

The error messages printed from mrst_i2c_abort() didn't give slave address info.

But I2C device driver developers always need this to check which slave device
has the problem.

This patch enhances the error message format by adding slave address info to
each error message.

Signed-off-by: Bin Yang <bin.yang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
[Ported to upstream driver branch and tidied a spot]
Signed-off-by: Alan Cox <alan-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---

 drivers/i2c/busses/i2c-intel-mid.c |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)


diff --git a/drivers/i2c/busses/i2c-intel-mid.c b/drivers/i2c/busses/i2c-intel-mid.c
index 80f70d3..bdf17da 100644
--- a/drivers/i2c/busses/i2c-intel-mid.c
+++ b/drivers/i2c/busses/i2c-intel-mid.c
@@ -78,7 +78,7 @@ struct intel_mid_i2c_private {
 	void __iomem *base;
 	int speed;
 	struct completion complete;
-	int abort;
+	u32 abort;
 	u8 *rx_buf;
 	int rx_buf_len;
 	enum mid_i2c_status status;
@@ -464,9 +464,15 @@ static inline bool intel_mid_i2c_address_neq(const struct i2c_msg *p1,
 static void intel_mid_i2c_abort(struct intel_mid_i2c_private *i2c)
 {
 	/* Read about source register */
-	int abort = i2c->abort;
+	u32 abort = i2c->abort;
 	struct i2c_adapter *adap = &i2c->adap;
 
+	if (abort & (ABRT_MASTER_DIS | ABRT_10B_RD_NORSTRT |
+	    ABRT_SBYTE_NORSTRT | ABRT_SBYTE_ACKDET | ABRT_TXDATA_NOACK |
+	    ABRT_10ADDR2_NOACK | ABRT_10ADDR1_NOACK | ABRT_7B_ADDR_NOACK))
+		dev_err(&adap->dev, "i2c abort on address 0x%x\n",
+							i2c->msg->addr);
+
 	/* Single transfer error check:
 	 * According to databook, TX/RX FIFOs would be flushed when
 	 * the abort interrupt occured.
@@ -550,7 +556,8 @@ static int xfer_read(struct i2c_adapter *adap, unsigned char *buf, int length)
 	i2c->status = STATUS_READ_START;
 	err = wait_for_completion_interruptible_timeout(&i2c->complete, HZ);
 	if (!err) {
-		dev_err(&adap->dev, "Timeout for ACK from I2C slave device\n");
+		dev_err(&adap->dev, "Timeout for ACK from I2C slave 0x%x\n",
+						i2c->msg->addr);
 		intel_mid_i2c_hwinit(i2c);
 		return -ETIMEDOUT;
 	}
@@ -602,7 +609,8 @@ static int xfer_write(struct i2c_adapter *adap,
 	i2c->status = STATUS_WRITE_START;
 	err = wait_for_completion_interruptible_timeout(&i2c->complete, HZ);
 	if (!err) {
-		dev_err(&adap->dev, "Timeout for ACK from I2C slave device\n");
+		dev_err(&adap->dev, "Timeout for ACK from I2C slave 0x%x\n",
+							i2c->msg->addr);
 		intel_mid_i2c_hwinit(i2c);
 		return -ETIMEDOUT;
 	} else {

             reply	other threads:[~2010-11-24 14:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-24 14:49 Alan Cox [this message]
     [not found] ` <20101124144904.10210.90314.stgit-Z/y2cZnRghHXmaaqVzeoHQ@public.gmane.org>
2010-11-24 14:49   ` [PATCH 2/2] i2c-intel-mid: improve timeout handling Alan Cox
     [not found]     ` <20101124144920.10210.36601.stgit-Z/y2cZnRghHXmaaqVzeoHQ@public.gmane.org>
2010-12-06  4:32       ` Ben Dooks
2010-12-06  4:31   ` [PATCH 1/2] i2c_intel_mid: Improve error reporting Ben Dooks

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=20101124144904.10210.90314.stgit@bob.linux.org.uk \
    --to=alan-qbu/x9rampvanceybjwyrvxrex20p6io@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.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 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).