From: Danielle Costantino <[email protected]>
This patch enforces correct I2C error returned codes from Freescale's
MPC i2c bus driver, allowing for proper user-space/kernel error
handling.
Signed-off-by: Danielle Costantino <[email protected]>
---
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index 0edf630..66bef28 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -124,7 +124,7 @@
static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing)
{
unsigned long orig_jiffies = jiffies;
- u32 x;
+ u32 cmd_err;
int result = 0;
if (!i2c->irq) {
@@ -137,7 +137,7 @@
break;
}
}
- x = readb(i2c->base + MPC_I2C_SR);
+ cmd_err = readb(i2c->base + MPC_I2C_SR);
writeb(0, i2c->base + MPC_I2C_SR);
} else {
/* Interrupt mode */
@@ -150,30 +150,30 @@
result = -ETIMEDOUT;
}
- x = i2c->interrupt;
+ cmd_err = i2c->interrupt;
i2c->interrupt = 0;
}
- if (result < 0)
- return result;
+ if (result < 0)
+ return result;
- if (!(x & CSR_MCF)) {
- dev_dbg(i2c->dev, "unfinished\n");
- return -EIO;
- }
+ if (!(cmd_err & CSR_MCF)) {
+ dev_dbg(i2c->dev, "unfinished\n");
+ return -EIO;
+ }
- if (x & CSR_MAL) {
- dev_dbg(i2c->dev, "MAL\n");
- return -EIO;
- }
+ if (cmd_err & CSR_MAL) {
+ dev_dbg(i2c->dev, "MAL\n");
+ return -EAGAIN;
+ }
- if (writing && (x & CSR_RXAK)) {
- dev_dbg(i2c->dev, "No RXAK\n");
- /* generate stop */
- writeccr(i2c, CCR_MEN);
- return -EIO;
- }
- return 0;
+ if (writing && (cmd_err & CSR_RXAK)) {
+ dev_dbg(i2c->dev, "No RXAK\n");
+ /* generate stop */
+ writeccr(i2c, CCR_MEN);
+ return -ENXIO;
+ }
+ return 0;
}
#if defined(CONFIG_PPC_MPC52xx) || defined(CONFIG_PPC_MPC512x)
--
- Danielle Costantino
On Tue, Oct 21, 2014 at 12:05:44AM -0700, Danielle Costantino wrote:
> From: Danielle Costantino <[email protected]>
>
> This patch enforces correct I2C error returned codes from Freescale's
> MPC i2c bus driver, allowing for proper user-space/kernel error
> handling.
>
> Signed-off-by: Danielle Costantino <[email protected]>
Tabs converted to spaces here? Please resend properly.
From: Danielle Costantino <[email protected]>
Subject: [PATCH v2] i2c: mpc: report correct I2C error return codes
This patch enforces correct I2C error returned codes from Freescale's
MPC i2c bus driver, allowing for proper user-space/kernel error
handling.
Signed-off-by: Danielle Costantino <[email protected]>
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index 0edf630..4c5d7d9 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -124,7 +124,7 @@
static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing)
{
unsigned long orig_jiffies = jiffies;
- u32 x;
+ u32 cmd_err;
int result = 0;
if (!i2c->irq) {
@@ -133,11 +133,11 @@
if (time_after(jiffies, orig_jiffies + timeout)) {
dev_dbg(i2c->dev, "timeout\n");
writeccr(i2c, 0);
- result = -EIO;
+ result = -ETIMEDOUT;
break;
}
}
- x = readb(i2c->base + MPC_I2C_SR);
+ cmd_err = readb(i2c->base + MPC_I2C_SR);
writeb(0, i2c->base + MPC_I2C_SR);
} else {
/* Interrupt mode */
@@ -150,28 +150,28 @@
result = -ETIMEDOUT;
}
- x = i2c->interrupt;
+ cmd_err = i2c->interrupt;
i2c->interrupt = 0;
}
if (result < 0)
return result;
- if (!(x & CSR_MCF)) {
+ if (!(cmd_err & CSR_MCF)) {
dev_dbg(i2c->dev, "unfinished\n");
return -EIO;
}
- if (x & CSR_MAL) {
+ if (cmd_err & CSR_MAL) {
dev_dbg(i2c->dev, "MAL\n");
- return -EIO;
+ return -EAGAIN;
}
- if (writing && (x & CSR_RXAK)) {
+ if (writing && (cmd_err & CSR_RXAK)) {
dev_dbg(i2c->dev, "No RXAK\n");
/* generate stop */
writeccr(i2c, CCR_MEN);
- return -EIO;
+ return -ENXIO;
}
return 0;
}
On Mon, Nov 10, 2014 at 6:49 AM, Wolfram Sang <[email protected]> wrote:
> On Tue, Oct 21, 2014 at 12:05:44AM -0700, Danielle Costantino wrote:
>> From: Danielle Costantino <[email protected]>
>>
>> This patch enforces correct I2C error returned codes from Freescale's
>> MPC i2c bus driver, allowing for proper user-space/kernel error
>> handling.
>>
>> Signed-off-by: Danielle Costantino <[email protected]>
>
> Tabs converted to spaces here? Please resend properly.
>
--
- Danielle Costantino
On Wed, Nov 12, 2014 at 05:08:09AM -0800, Danielle Costantino wrote:
> From: Danielle Costantino <[email protected]>
> Subject: [PATCH v2] i2c: mpc: report correct I2C error return codes
>
> This patch enforces correct I2C error returned codes from Freescale's
> MPC i2c bus driver, allowing for proper user-space/kernel error
> handling.
>
> Signed-off-by: Danielle Costantino <[email protected]>
>
> diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
> index 0edf630..4c5d7d9 100644
Applied to for-next, thanks!
Still, the attachment worked, not the mail itself. That is OK for now,
but not generally acceptable. There is Documentation/email-clients.txt
which has some info about GMail. Please check.