mfd: cros_ec: ec_dev->cmd_xfer() returns number of bytes received from EC
authorBill Richardson <wfrichar@chromium.org>
Wed, 18 Jun 2014 18:14:06 +0000 (11:14 -0700)
committerLee Jones <lee.jones@linaro.org>
Wed, 9 Jul 2014 13:58:20 +0000 (14:58 +0100)
When communicating with the EC, the cmd_xfer() function should return the
number of bytes it received from the EC, or negative on error.

Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Signed-off-by: Doug Anderson <dianders@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Acked-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
drivers/i2c/busses/i2c-cros-ec-tunnel.c
drivers/mfd/cros_ec_i2c.c
drivers/mfd/cros_ec_spi.c
include/linux/mfd/cros_ec.h

index dd07818d03d02463337ac556770e2b7b638af420..05e033c981151277b62628510f31814ec46ce1ee 100644 (file)
@@ -228,7 +228,7 @@ static int ec_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg i2c_msgs[],
        msg.insize = response_len;
 
        result = bus->ec->cmd_xfer(bus->ec, &msg);
-       if (result)
+       if (result < 0)
                goto exit;
 
        result = ec_i2c_parse_response(response, i2c_msgs, &num);
index 189e7d1d7742eef9d56fc97648c028841f1ffa98..fd7a546d3478683b0a140bed97725d20514307d2 100644 (file)
@@ -111,7 +111,7 @@ static int cros_ec_cmd_xfer_i2c(struct cros_ec_device *ec_dev,
                goto done;
        }
 
-       ret = 0;
+       ret = i2c_msg[1].buf[1];
  done:
        kfree(in_buf);
        kfree(out_buf);
index da1da05cd546baafefa9078e17b5cbb52b28a981..ac52e3653e90395d9fb9a0d51c975cad33526ef4 100644 (file)
@@ -320,7 +320,7 @@ static int cros_ec_cmd_xfer_spi(struct cros_ec_device *ec_dev,
                goto exit;
        }
 
-       ret = 0;
+       ret = len;
 exit:
        mutex_unlock(&ec_spi->lock);
        return ret;
index 1f79f162abe410693cc94c8bec201e2aa6374e29..0ebf26fddbbbd1f60a16d5fe0b9d42a780e94985 100644 (file)
@@ -41,7 +41,7 @@ enum {
  * @outdata: Outgoing data to EC
  * @outsize: Outgoing length in bytes
  * @indata: Where to put the incoming data from EC
- * @insize: Incoming length in bytes (filled in by EC)
+ * @insize: Max number of bytes to accept from EC
  * @result: EC's response to the command (separate from communication failure)
  */
 struct cros_ec_command {
@@ -64,9 +64,9 @@ struct cros_ec_command {
  * sleep at the last suspend
  * @event_notifier: interrupt event notifier for transport devices
  * @cmd_xfer: send command to EC and get response
- *     Returns 0 if the communication succeeded, but that doesn't mean the EC
- *     was happy with the command it got. Caller should check msg.result for
- *     the EC's result code.
+ *     Returns the number of bytes received if the communication succeeded, but
+ *     that doesn't mean the EC was happy with the command. The caller
+ *     should check msg.result for the EC's result code.
  *
  * @priv: Private data
  * @irq: Interrupt to use