Merge tag 'mfd-next-5.2' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd
[linux-2.6-block.git] / drivers / platform / chrome / cros_ec_proto.c
index 52ca564a64e7566164430cce4062cc6dedb85382..3d2325197a68b889022fd0bcb9fab2c262abe3d8 100644 (file)
@@ -10,6 +10,8 @@
 #include <linux/slab.h>
 #include <asm/unaligned.h>
 
+#include "cros_ec_trace.h"
+
 #define EC_COMMAND_RETRIES     50
 
 static int prepare_packet(struct cros_ec_device *ec_dev,
@@ -51,11 +53,24 @@ static int send_command(struct cros_ec_device *ec_dev,
        int ret;
        int (*xfer_fxn)(struct cros_ec_device *ec, struct cros_ec_command *msg);
 
+       trace_cros_ec_cmd(msg);
+
        if (ec_dev->proto_version > 2)
                xfer_fxn = ec_dev->pkt_xfer;
        else
                xfer_fxn = ec_dev->cmd_xfer;
 
+       if (!xfer_fxn) {
+               /*
+                * This error can happen if a communication error happened and
+                * the EC is trying to use protocol v2, on an underlying
+                * communication mechanism that does not support v2.
+                */
+               dev_err_once(ec_dev->dev,
+                            "missing EC transfer API, cannot send command\n");
+               return -EIO;
+       }
+
        ret = (*xfer_fxn)(ec_dev, msg);
        if (msg->result == EC_RES_IN_PROGRESS) {
                int i;