aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mfd')
-rw-r--r--drivers/mfd/wm831x-i2c.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/drivers/mfd/wm831x-i2c.c b/drivers/mfd/wm831x-i2c.c
index 3853fa8e7cc2..a06cbc739716 100644
--- a/drivers/mfd/wm831x-i2c.c
+++ b/drivers/mfd/wm831x-i2c.c
@@ -51,17 +51,25 @@ static int wm831x_i2c_write_device(struct wm831x *wm831x, unsigned short reg,
51 int bytes, void *src) 51 int bytes, void *src)
52{ 52{
53 struct i2c_client *i2c = wm831x->control_data; 53 struct i2c_client *i2c = wm831x->control_data;
54 unsigned char msg[bytes + 2]; 54 struct i2c_msg xfer[2];
55 int ret; 55 int ret;
56 56
57 reg = cpu_to_be16(reg); 57 reg = cpu_to_be16(reg);
58 memcpy(&msg[0], &reg, 2);
59 memcpy(&msg[2], src, bytes);
60 58
61 ret = i2c_master_send(i2c, msg, bytes + 2); 59 xfer[0].addr = i2c->addr;
60 xfer[0].flags = 0;
61 xfer[0].len = 2;
62 xfer[0].buf = (char *)®
63
64 xfer[1].addr = i2c->addr;
65 xfer[1].flags = I2C_M_NOSTART;
66 xfer[1].len = bytes;
67 xfer[1].buf = (char *)src;
68
69 ret = i2c_transfer(i2c->adapter, xfer, 2);
62 if (ret < 0) 70 if (ret < 0)
63 return ret; 71 return ret;
64 if (ret < bytes + 2) 72 if (ret != 2)
65 return -EIO; 73 return -EIO;
66 74
67 return 0; 75 return 0;