diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2011-03-17 17:40:51 -0400 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2011-03-23 05:42:09 -0400 |
commit | 4c4d887822070410e3be519e1a4ff933fb899ba8 (patch) | |
tree | 0e7b58b1d53d42b745846c7456317c1e1e413da1 /drivers/mfd | |
parent | aad343107b4c153dd9f3ffc3d0f32558a25438e9 (diff) |
mfd: Remove copy from WM831x I2C write function
This saves us allocating an array on the stack, giving a meaningless
performance improvement and ensuring that if drivers ever do large writes
we'll not allocate large arrays on the stack.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/mfd')
-rw-r--r-- | drivers/mfd/wm831x-i2c.c | 18 |
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], ®, 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; |