aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-04-26 16:36:02 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-04-26 16:36:02 -0400
commit36a8032d77649430f5ef11fbf0df2bb026be0b04 (patch)
tree18e386a957bde5f71e9efd2cddf1d8aadafe48e4 /drivers/i2c
parent7f9f44308c8993c9ab8078d174dad34bea3e82d7 (diff)
parent96cba9b00e297303774bec59e192064d20adeb3d (diff)
Merge tag 'chrome-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/olof/chrome-platform
Pull chrome platform updates from Olof Johansson: "Here's a set of updates to the Chrome OS platform drivers for this merge window. Main new things this cycle is: - Driver changes to expose the lightbar to users. With this, you can make your own blinkenlights on Chromebook Pixels. - Changes in the way that the atmel_mxt trackpads are probed. The laptop driver is trying to be smart and not instantiate the devices that don't answer to probe. For the trackpad that can come up in two modes (bootloader or regular), this gets complicated since the driver already knows how to handle the two modes including the actual addresses used. So now the laptop driver needs to know more too, instantiating the regular address even if the bootloader one is the probe that passed. - mfd driver improvements by Javier Martines Canillas, and a few bugfixes from him, kbuild and myself" * tag 'chrome-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/olof/chrome-platform: platform/chrome: chromeos_laptop - instantiate Atmel at primary address platform/chrome: cros_ec_lpc - Depend on X86 || COMPILE_TEST platform/chrome: cros_ec_lpc - Include linux/io.h header file platform/chrome: fix platform_no_drv_owner.cocci warnings platform/chrome: cros_ec_lightbar - fix duplicate const warning platform/chrome: cros_ec_dev - fix Unknown escape '%' warning platform/chrome: Expose Chrome OS Lightbar to users platform/chrome: Create sysfs attributes for the ChromeOS EC mfd: cros_ec: Instantiate ChromeOS EC character device platform/chrome: Add Chrome OS EC userspace device interface platform/chrome: Add cros_ec_lpc driver for x86 devices mfd: cros_ec: Add char dev and virtual dev pointers mfd: cros_ec: Use fixed size arrays to transfer data with the EC
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/busses/i2c-cros-ec-tunnel.c51
1 files changed, 10 insertions, 41 deletions
diff --git a/drivers/i2c/busses/i2c-cros-ec-tunnel.c b/drivers/i2c/busses/i2c-cros-ec-tunnel.c
index 875c22ae5400..fa8dedd8c3a2 100644
--- a/drivers/i2c/busses/i2c-cros-ec-tunnel.c
+++ b/drivers/i2c/busses/i2c-cros-ec-tunnel.c
@@ -182,72 +182,41 @@ static int ec_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg i2c_msgs[],
182 const u16 bus_num = bus->remote_bus; 182 const u16 bus_num = bus->remote_bus;
183 int request_len; 183 int request_len;
184 int response_len; 184 int response_len;
185 u8 *request = NULL;
186 u8 *response = NULL;
187 int result; 185 int result;
188 struct cros_ec_command msg; 186 struct cros_ec_command msg = { };
189 187
190 request_len = ec_i2c_count_message(i2c_msgs, num); 188 request_len = ec_i2c_count_message(i2c_msgs, num);
191 if (request_len < 0) { 189 if (request_len < 0) {
192 dev_warn(dev, "Error constructing message %d\n", request_len); 190 dev_warn(dev, "Error constructing message %d\n", request_len);
193 result = request_len; 191 return request_len;
194 goto exit;
195 } 192 }
193
196 response_len = ec_i2c_count_response(i2c_msgs, num); 194 response_len = ec_i2c_count_response(i2c_msgs, num);
197 if (response_len < 0) { 195 if (response_len < 0) {
198 /* Unexpected; no errors should come when NULL response */ 196 /* Unexpected; no errors should come when NULL response */
199 dev_warn(dev, "Error preparing response %d\n", response_len); 197 dev_warn(dev, "Error preparing response %d\n", response_len);
200 result = response_len; 198 return response_len;
201 goto exit;
202 }
203
204 if (request_len <= ARRAY_SIZE(bus->request_buf)) {
205 request = bus->request_buf;
206 } else {
207 request = kzalloc(request_len, GFP_KERNEL);
208 if (request == NULL) {
209 result = -ENOMEM;
210 goto exit;
211 }
212 }
213 if (response_len <= ARRAY_SIZE(bus->response_buf)) {
214 response = bus->response_buf;
215 } else {
216 response = kzalloc(response_len, GFP_KERNEL);
217 if (response == NULL) {
218 result = -ENOMEM;
219 goto exit;
220 }
221 } 199 }
222 200
223 result = ec_i2c_construct_message(request, i2c_msgs, num, bus_num); 201 result = ec_i2c_construct_message(msg.outdata, i2c_msgs, num, bus_num);
224 if (result) 202 if (result)
225 goto exit; 203 return result;
226 204
227 msg.version = 0; 205 msg.version = 0;
228 msg.command = EC_CMD_I2C_PASSTHRU; 206 msg.command = EC_CMD_I2C_PASSTHRU;
229 msg.outdata = request;
230 msg.outsize = request_len; 207 msg.outsize = request_len;
231 msg.indata = response;
232 msg.insize = response_len; 208 msg.insize = response_len;
233 209
234 result = cros_ec_cmd_xfer(bus->ec, &msg); 210 result = cros_ec_cmd_xfer(bus->ec, &msg);
235 if (result < 0) 211 if (result < 0)
236 goto exit; 212 return result;
237 213
238 result = ec_i2c_parse_response(response, i2c_msgs, &num); 214 result = ec_i2c_parse_response(msg.indata, i2c_msgs, &num);
239 if (result < 0) 215 if (result < 0)
240 goto exit; 216 return result;
241 217
242 /* Indicate success by saying how many messages were sent */ 218 /* Indicate success by saying how many messages were sent */
243 result = num; 219 return num;
244exit:
245 if (request != bus->request_buf)
246 kfree(request);
247 if (response != bus->response_buf)
248 kfree(response);
249
250 return result;
251} 220}
252 221
253static u32 ec_i2c_functionality(struct i2c_adapter *adap) 222static u32 ec_i2c_functionality(struct i2c_adapter *adap)