Commit 5a72b25e authored by Wolfram Sang's avatar Wolfram Sang Committed by Wolfram Sang

i2c: sh_mobile: improve error handling

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: default avatarWolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
parent a78f6a41
...@@ -480,7 +480,7 @@ static int start_ch(struct sh_mobile_i2c_data *pd, struct i2c_msg *usr_msg, ...@@ -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)) { if (usr_msg->len == 0 && (usr_msg->flags & I2C_M_RD)) {
dev_err(pd->dev, "Unsupported zero length i2c read\n"); dev_err(pd->dev, "Unsupported zero length i2c read\n");
return -EIO; return -EOPNOTSUPP;
} }
if (do_init) { if (do_init) {
...@@ -515,17 +515,12 @@ static int poll_dte(struct sh_mobile_i2c_data *pd) ...@@ -515,17 +515,12 @@ static int poll_dte(struct sh_mobile_i2c_data *pd)
break; break;
if (val & ICSR_TACK) if (val & ICSR_TACK)
return -EIO; return -ENXIO;
udelay(10); udelay(10);
} }
if (!i) { return i ? 0 : -ETIMEDOUT;
dev_warn(pd->dev, "Timeout polling for DTE!\n");
return -ETIMEDOUT;
}
return 0;
} }
static int poll_busy(struct sh_mobile_i2c_data *pd) static int poll_busy(struct sh_mobile_i2c_data *pd)
...@@ -543,20 +538,18 @@ 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)) { if (!(val & ICSR_BUSY)) {
/* handle missing acknowledge and arbitration lost */ /* handle missing acknowledge and arbitration lost */
if ((val | pd->sr) & (ICSR_TACK | ICSR_AL)) val |= pd->sr;
return -EIO; if (val & ICSR_TACK)
return -ENXIO;
if (val & ICSR_AL)
return -EAGAIN;
break; break;
} }
udelay(10); udelay(10);
} }
if (!i) { return i ? 0 : -ETIMEDOUT;
dev_err(pd->dev, "Polling timed out\n");
return -ETIMEDOUT;
}
return 0;
} }
static int sh_mobile_i2c_xfer(struct i2c_adapter *adapter, static int sh_mobile_i2c_xfer(struct i2c_adapter *adapter,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment