Skip to content

Commit

Permalink
mfd: Correct WM8350 I2C return code usage
Browse files Browse the repository at this point in the history
The vendor BSP used for the WM8350 development provided an I2C driver
which incorrectly returned zero on succesful sends rather than the
number of transmitted bytes, an error which was then propagated into the
WM8350 I2C accessors.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Samuel Ortiz <sameo@openedhand.com>
  • Loading branch information
Mark Brown authored and Samuel Ortiz committed Nov 16, 2008
1 parent b1ccbdc commit 898d805
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions drivers/mfd/wm8350-i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,32 @@ static int wm8350_i2c_read_device(struct wm8350 *wm8350, char reg,
ret = i2c_master_send(wm8350->i2c_client, &reg, 1);
if (ret < 0)
return ret;
return i2c_master_recv(wm8350->i2c_client, dest, bytes);
ret = i2c_master_recv(wm8350->i2c_client, dest, bytes);
if (ret < 0)
return ret;
if (ret != bytes)
return -EIO;
return 0;
}

static int wm8350_i2c_write_device(struct wm8350 *wm8350, char reg,
int bytes, void *src)
{
/* we add 1 byte for device register */
u8 msg[(WM8350_MAX_REGISTER << 1) + 1];
int ret;

if (bytes > ((WM8350_MAX_REGISTER << 1) + 1))
return -EINVAL;

msg[0] = reg;
memcpy(&msg[1], src, bytes);
return i2c_master_send(wm8350->i2c_client, msg, bytes + 1);
ret = i2c_master_send(wm8350->i2c_client, msg, bytes + 1);
if (ret < 0)
return ret;
if (ret != bytes + 1)
return -EIO;
return 0;
}

static int wm8350_i2c_probe(struct i2c_client *i2c,
Expand Down

0 comments on commit 898d805

Please sign in to comment.