diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2008-11-12 11:34:02 -0500 |
---|---|---|
committer | Samuel Ortiz <samuel@sortiz.org> | 2008-11-16 13:58:47 -0500 |
commit | 898d8054ec0cb5ba0ec1b15c78042a23ed103c02 (patch) | |
tree | 1c6cdcc402a8cd19a58a0388c0eea2b165cd1497 /drivers/mfd | |
parent | b1ccbdc4a2af5ffcd6082c3a7a6fbd0e134031f2 (diff) |
mfd: Correct WM8350 I2C return code usage
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>
Diffstat (limited to 'drivers/mfd')
-rw-r--r-- | drivers/mfd/wm8350-i2c.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/drivers/mfd/wm8350-i2c.c b/drivers/mfd/wm8350-i2c.c index 8dfe21bb3bd1..3e0ce0e50ea2 100644 --- a/drivers/mfd/wm8350-i2c.c +++ b/drivers/mfd/wm8350-i2c.c | |||
@@ -30,7 +30,12 @@ static int wm8350_i2c_read_device(struct wm8350 *wm8350, char reg, | |||
30 | ret = i2c_master_send(wm8350->i2c_client, ®, 1); | 30 | ret = i2c_master_send(wm8350->i2c_client, ®, 1); |
31 | if (ret < 0) | 31 | if (ret < 0) |
32 | return ret; | 32 | return ret; |
33 | return i2c_master_recv(wm8350->i2c_client, dest, bytes); | 33 | ret = i2c_master_recv(wm8350->i2c_client, dest, bytes); |
34 | if (ret < 0) | ||
35 | return ret; | ||
36 | if (ret != bytes) | ||
37 | return -EIO; | ||
38 | return 0; | ||
34 | } | 39 | } |
35 | 40 | ||
36 | static int wm8350_i2c_write_device(struct wm8350 *wm8350, char reg, | 41 | static int wm8350_i2c_write_device(struct wm8350 *wm8350, char reg, |
@@ -38,13 +43,19 @@ static int wm8350_i2c_write_device(struct wm8350 *wm8350, char reg, | |||
38 | { | 43 | { |
39 | /* we add 1 byte for device register */ | 44 | /* we add 1 byte for device register */ |
40 | u8 msg[(WM8350_MAX_REGISTER << 1) + 1]; | 45 | u8 msg[(WM8350_MAX_REGISTER << 1) + 1]; |
46 | int ret; | ||
41 | 47 | ||
42 | if (bytes > ((WM8350_MAX_REGISTER << 1) + 1)) | 48 | if (bytes > ((WM8350_MAX_REGISTER << 1) + 1)) |
43 | return -EINVAL; | 49 | return -EINVAL; |
44 | 50 | ||
45 | msg[0] = reg; | 51 | msg[0] = reg; |
46 | memcpy(&msg[1], src, bytes); | 52 | memcpy(&msg[1], src, bytes); |
47 | return i2c_master_send(wm8350->i2c_client, msg, bytes + 1); | 53 | ret = i2c_master_send(wm8350->i2c_client, msg, bytes + 1); |
54 | if (ret < 0) | ||
55 | return ret; | ||
56 | if (ret != bytes + 1) | ||
57 | return -EIO; | ||
58 | return 0; | ||
48 | } | 59 | } |
49 | 60 | ||
50 | static int wm8350_i2c_probe(struct i2c_client *i2c, | 61 | static int wm8350_i2c_probe(struct i2c_client *i2c, |