aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@chromium.org>2014-06-18 14:14:05 -0400
committerLee Jones <lee.jones@linaro.org>2014-07-09 09:58:19 -0400
commit6db07b6336589ff480528173e41f8f6af3f0097f (patch)
tree306bf3f92d5bc8920c8ae668e3e8c93534351d85 /drivers/mfd
parent5799f95a373a2752e5c732f531a6f40fe458b818 (diff)
mfd: cros_ec: Check result code from EC messages
Just because the host was able to talk to the EC doesn't mean that the EC was happy with what it was told. Errors in communincation are not the same as error messages from the EC itself. This change lets the EC report its errors separately. [dianders: Added common function to cros_ec.c] Signed-off-by: Bill Richardson <wfrichar@chromium.org> Signed-off-by: Doug Anderson <dianders@chromium.org> Signed-off-by: Lee Jones <lee.jones@linaro.org>
Diffstat (limited to 'drivers/mfd')
-rw-r--r--drivers/mfd/cros_ec.c18
-rw-r--r--drivers/mfd/cros_ec_i2c.c8
-rw-r--r--drivers/mfd/cros_ec_spi.c19
3 files changed, 27 insertions, 18 deletions
diff --git a/drivers/mfd/cros_ec.c b/drivers/mfd/cros_ec.c
index 4851ed2fbe31..83e30c663578 100644
--- a/drivers/mfd/cros_ec.c
+++ b/drivers/mfd/cros_ec.c
@@ -44,6 +44,24 @@ int cros_ec_prepare_tx(struct cros_ec_device *ec_dev,
44} 44}
45EXPORT_SYMBOL(cros_ec_prepare_tx); 45EXPORT_SYMBOL(cros_ec_prepare_tx);
46 46
47int cros_ec_check_result(struct cros_ec_device *ec_dev,
48 struct cros_ec_command *msg)
49{
50 switch (msg->result) {
51 case EC_RES_SUCCESS:
52 return 0;
53 case EC_RES_IN_PROGRESS:
54 dev_dbg(ec_dev->dev, "command 0x%02x in progress\n",
55 msg->command);
56 return -EAGAIN;
57 default:
58 dev_dbg(ec_dev->dev, "command 0x%02x returned %d\n",
59 msg->command, msg->result);
60 return 0;
61 }
62}
63EXPORT_SYMBOL(cros_ec_check_result);
64
47static irqreturn_t ec_irq_thread(int irq, void *data) 65static irqreturn_t ec_irq_thread(int irq, void *data)
48{ 66{
49 struct cros_ec_device *ec_dev = data; 67 struct cros_ec_device *ec_dev = data;
diff --git a/drivers/mfd/cros_ec_i2c.c b/drivers/mfd/cros_ec_i2c.c
index 5bb32f5550b3..189e7d1d7742 100644
--- a/drivers/mfd/cros_ec_i2c.c
+++ b/drivers/mfd/cros_ec_i2c.c
@@ -92,12 +92,10 @@ static int cros_ec_cmd_xfer_i2c(struct cros_ec_device *ec_dev,
92 } 92 }
93 93
94 /* check response error code */ 94 /* check response error code */
95 if (i2c_msg[1].buf[0]) { 95 msg->result = i2c_msg[1].buf[0];
96 dev_warn(ec_dev->dev, "command 0x%02x returned an error %d\n", 96 ret = cros_ec_check_result(ec_dev, msg);
97 msg->command, i2c_msg[1].buf[0]); 97 if (ret)
98 ret = -EINVAL;
99 goto done; 98 goto done;
100 }
101 99
102 /* copy response packet payload and compute checksum */ 100 /* copy response packet payload and compute checksum */
103 sum = in_buf[0] + in_buf[1]; 101 sum = in_buf[0] + in_buf[1];
diff --git a/drivers/mfd/cros_ec_spi.c b/drivers/mfd/cros_ec_spi.c
index 6e929b5f3bd3..da1da05cd546 100644
--- a/drivers/mfd/cros_ec_spi.c
+++ b/drivers/mfd/cros_ec_spi.c
@@ -285,21 +285,14 @@ static int cros_ec_cmd_xfer_spi(struct cros_ec_device *ec_dev,
285 goto exit; 285 goto exit;
286 } 286 }
287 287
288 /* check response error code */
289 ptr = ec_dev->din; 288 ptr = ec_dev->din;
290 if (ptr[0]) { 289
291 if (ptr[0] == EC_RES_IN_PROGRESS) { 290 /* check response error code */
292 dev_dbg(ec_dev->dev, "command 0x%02x in progress\n", 291 ec_msg->result = ptr[0];
293 ec_msg->command); 292 ret = cros_ec_check_result(ec_dev, ec_msg);
294 ret = -EAGAIN; 293 if (ret)
295 goto exit;
296 }
297 dev_warn(ec_dev->dev, "command 0x%02x returned an error %d\n",
298 ec_msg->command, ptr[0]);
299 debug_packet(ec_dev->dev, "in_err", ptr, len);
300 ret = -EINVAL;
301 goto exit; 294 goto exit;
302 } 295
303 len = ptr[1]; 296 len = ptr[1];
304 sum = ptr[0] + ptr[1]; 297 sum = ptr[0] + ptr[1];
305 if (len > ec_msg->insize) { 298 if (len > ec_msg->insize) {