From: Wolfram Sang <wsa@the-dreams.de>
To: linux-i2c@vger.kernel.org
Cc: Wolfram Sang <wsa@the-dreams.de>,
linux-sh@vger.kernel.org, Magnus Damm <magnus.damm@gmail.com>,
Wolfram Sang <wsa+renesas@sang-engineering.com>
Subject: [PATCH 2/6] i2c: sh_mobile: improve error handling
Date: Thu, 1 May 2014 00:21:06 +0200 [thread overview]
Message-ID: <1398896470-24663-3-git-send-email-wsa@the-dreams.de> (raw)
In-Reply-To: <1398896470-24663-1-git-send-email-wsa@the-dreams.de>
From: Wolfram Sang <wsa+renesas@sang-engineering.com>
Use standard i2c error codes for i2c failures. Also, don't print
something on timeout since it happens regularly with i2c. Simplify some,
logic, too.
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
drivers/i2c/busses/i2c-sh_mobile.c | 25 +++++++++----------------
1 file changed, 9 insertions(+), 16 deletions(-)
diff --git a/drivers/i2c/busses/i2c-sh_mobile.c b/drivers/i2c/busses/i2c-sh_mobile.c
index d91625eea6bb..d2fa222df3d1 100644
--- a/drivers/i2c/busses/i2c-sh_mobile.c
+++ b/drivers/i2c/busses/i2c-sh_mobile.c
@@ -480,7 +480,7 @@ static int start_ch(struct sh_mobile_i2c_data *pd, struct i2c_msg *usr_msg,
{
if (usr_msg->len == 0 && (usr_msg->flags & I2C_M_RD)) {
dev_err(pd->dev, "Unsupported zero length i2c read\n");
- return -EIO;
+ return -EOPNOTSUPP;
}
if (do_init) {
@@ -515,17 +515,12 @@ static int poll_dte(struct sh_mobile_i2c_data *pd)
break;
if (val & ICSR_TACK)
- return -EIO;
+ return -ENXIO;
udelay(10);
}
- if (!i) {
- dev_warn(pd->dev, "Timeout polling for DTE!\n");
- return -ETIMEDOUT;
- }
-
- return 0;
+ return i ? 0 : -ETIMEDOUT;
}
static int poll_busy(struct sh_mobile_i2c_data *pd)
@@ -543,20 +538,18 @@ static int poll_busy(struct sh_mobile_i2c_data *pd)
*/
if (!(val & ICSR_BUSY)) {
/* handle missing acknowledge and arbitration lost */
- if ((val | pd->sr) & (ICSR_TACK | ICSR_AL))
- return -EIO;
+ val |= pd->sr;
+ if (val & ICSR_TACK)
+ return -ENXIO;
+ if (val & ICSR_AL)
+ return -EAGAIN;
break;
}
udelay(10);
}
- if (!i) {
- dev_err(pd->dev, "Polling timed out\n");
- return -ETIMEDOUT;
- }
-
- return 0;
+ return i ? 0 : -ETIMEDOUT;
}
static int sh_mobile_i2c_xfer(struct i2c_adapter *adapter,
--
1.9.2
next prev parent reply other threads:[~2014-04-30 22:21 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-30 22:21 [PATCH 0/6] i2c: sh_mobile: cleanups Wolfram Sang
2014-04-30 22:21 ` [PATCH 1/6] i2c: sh_mobile: replace magic hex values with constants Wolfram Sang
2014-04-30 22:21 ` Wolfram Sang [this message]
[not found] ` <1398896470-24663-3-git-send-email-wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
2014-04-30 22:25 ` [PATCH 2/6] i2c: sh_mobile: improve error handling Geert Uytterhoeven
2014-05-02 7:19 ` Wolfram Sang
2014-04-30 22:21 ` [PATCH 3/6] i2c: sh_mobile: honor DT bus speed settings Wolfram Sang
[not found] ` <1398896470-24663-1-git-send-email-wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
2014-04-30 22:21 ` [PATCH 4/6] i2c: sh_mobile: add devicetree documentation Wolfram Sang
2014-04-30 22:32 ` Geert Uytterhoeven
2014-05-01 1:02 ` Rob Herring
2014-05-02 7:23 ` Wolfram Sang
2014-04-30 22:21 ` [PATCH 6/6] i2c: sh_mobile: devm conversion, irq setup Wolfram Sang
2014-04-30 22:44 ` Geert Uytterhoeven
2014-04-30 22:21 ` [PATCH 5/6] i2c: sh_mobile: devm conversion, low hanging fruits Wolfram Sang
2014-04-30 22:39 ` Geert Uytterhoeven
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=1398896470-24663-3-git-send-email-wsa@the-dreams.de \
--to=wsa@the-dreams.de \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-sh@vger.kernel.org \
--cc=magnus.damm@gmail.com \
--cc=wsa+renesas@sang-engineering.com \
/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).