Re: [PATCH v2 05/10] mfd: cros_ec: Use struct cros_ec_command to communicate with the EC
On Wed, 18 Jun 2014, Doug Anderson wrote: > From: Bill Richardson > > This is some internal structure reorganization / renaming to prepare > for future patches that will add a userspace API to cros_ec. There > should be no visible changes. > > Signed-off-by: Bill Richardson > Signed-off-by: Doug Anderson > Acked-by: Lee Jones > --- > Changes in v2: None > > drivers/mfd/cros_ec.c | 28 ++-- > drivers/mfd/cros_ec_i2c.c | 24 > drivers/mfd/cros_ec_spi.c | 16 > include/linux/mfd/cros_ec.h | 35 ++- > 4 files changed, 52 insertions(+), 51 deletions(-) Patch applied with Simon's Reviewed-by. Clause: There is a chance that this patch might not be seen in -next for ~24-48hrs. If it's not there by 72hrs, feel free to poke. > diff --git a/drivers/mfd/cros_ec.c b/drivers/mfd/cros_ec.c > index 04e053c..2e86c28 100644 > --- a/drivers/mfd/cros_ec.c > +++ b/drivers/mfd/cros_ec.c > @@ -25,22 +25,22 @@ > #include > > int cros_ec_prepare_tx(struct cros_ec_device *ec_dev, > -struct cros_ec_msg *msg) > +struct cros_ec_command *msg) > { > uint8_t *out; > int csum, i; > > - BUG_ON(msg->out_len > EC_PROTO2_MAX_PARAM_SIZE); > + BUG_ON(msg->outsize > EC_PROTO2_MAX_PARAM_SIZE); > out = ec_dev->dout; > out[0] = EC_CMD_VERSION0 + msg->version; > - out[1] = msg->cmd; > - out[2] = msg->out_len; > + out[1] = msg->command; > + out[2] = msg->outsize; > csum = out[0] + out[1] + out[2]; > - for (i = 0; i < msg->out_len; i++) > - csum += out[EC_MSG_TX_HEADER_BYTES + i] = msg->out_buf[i]; > - out[EC_MSG_TX_HEADER_BYTES + msg->out_len] = (uint8_t)(csum & 0xff); > + for (i = 0; i < msg->outsize; i++) > + csum += out[EC_MSG_TX_HEADER_BYTES + i] = msg->outdata[i]; > + out[EC_MSG_TX_HEADER_BYTES + msg->outsize] = (uint8_t)(csum & 0xff); > > - return EC_MSG_TX_PROTO_BYTES + msg->out_len; > + return EC_MSG_TX_PROTO_BYTES + msg->outsize; > } > EXPORT_SYMBOL(cros_ec_prepare_tx); > > @@ -48,14 +48,14 @@ static int cros_ec_command_sendrecv(struct cros_ec_device > *ec_dev, > uint16_t cmd, void *out_buf, int out_len, > void *in_buf, int in_len) > { > - struct cros_ec_msg msg; > + struct cros_ec_command msg; > > msg.version = cmd >> 8; > - msg.cmd = cmd & 0xff; > - msg.out_buf = out_buf; > - msg.out_len = out_len; > - msg.in_buf = in_buf; > - msg.in_len = in_len; > + msg.command = cmd & 0xff; > + msg.outdata = out_buf; > + msg.outsize = out_len; > + msg.indata = in_buf; > + msg.insize = in_len; > > return ec_dev->cmd_xfer(ec_dev, ); > } > diff --git a/drivers/mfd/cros_ec_i2c.c b/drivers/mfd/cros_ec_i2c.c > index 777e529..37ed12f 100644 > --- a/drivers/mfd/cros_ec_i2c.c > +++ b/drivers/mfd/cros_ec_i2c.c > @@ -30,7 +30,7 @@ static inline struct cros_ec_device *to_ec_dev(struct > device *dev) > } > > static int cros_ec_cmd_xfer_i2c(struct cros_ec_device *ec_dev, > - struct cros_ec_msg *msg) > + struct cros_ec_command *msg) > { > struct i2c_client *client = ec_dev->priv; > int ret = -ENOMEM; > @@ -50,7 +50,7 @@ static int cros_ec_cmd_xfer_i2c(struct cros_ec_device > *ec_dev, >* allocate larger packet (one byte for checksum, one byte for >* length, and one for result code) >*/ > - packet_len = msg->in_len + 3; > + packet_len = msg->insize + 3; > in_buf = kzalloc(packet_len, GFP_KERNEL); > if (!in_buf) > goto done; > @@ -61,7 +61,7 @@ static int cros_ec_cmd_xfer_i2c(struct cros_ec_device > *ec_dev, >* allocate larger packet (one byte for checksum, one for >* command code, one for length, and one for command version) >*/ > - packet_len = msg->out_len + 4; > + packet_len = msg->outsize + 4; > out_buf = kzalloc(packet_len, GFP_KERNEL); > if (!out_buf) > goto done; > @@ -69,16 +69,16 @@ static int cros_ec_cmd_xfer_i2c(struct cros_ec_device > *ec_dev, > i2c_msg[0].buf = (char *)out_buf; > > out_buf[0] = EC_CMD_VERSION0 + msg->version; > - out_buf[1] = msg->cmd; > - out_buf[2] = msg->out_len; > + out_buf[1] = msg->command; > + out_buf[2] = msg->outsize; > > /* copy message payload and compute checksum */ > sum = out_buf[0] + out_buf[1] + out_buf[2]; > - for (i = 0; i < msg->out_len; i++) { > - out_buf[3 + i] = msg->out_buf[i]; > + for (i = 0; i < msg->outsize; i++) { > + out_buf[3 + i] = msg->outdata[i]; > sum += out_buf[3 + i]; > } > - out_buf[3 + msg->out_len] = sum; > + out_buf[3 + msg->outsize] = sum; > > /* send command to EC and read answer */ > ret = i2c_transfer(client->adapter, i2c_msg,
Re: [PATCH v2 05/10] mfd: cros_ec: Use struct cros_ec_command to communicate with the EC
On Wed, 18 Jun 2014, Doug Anderson wrote: From: Bill Richardson wfric...@chromium.org This is some internal structure reorganization / renaming to prepare for future patches that will add a userspace API to cros_ec. There should be no visible changes. Signed-off-by: Bill Richardson wfric...@chromium.org Signed-off-by: Doug Anderson diand...@chromium.org Acked-by: Lee Jones lee.jo...@linaro.org --- Changes in v2: None drivers/mfd/cros_ec.c | 28 ++-- drivers/mfd/cros_ec_i2c.c | 24 drivers/mfd/cros_ec_spi.c | 16 include/linux/mfd/cros_ec.h | 35 ++- 4 files changed, 52 insertions(+), 51 deletions(-) Patch applied with Simon's Reviewed-by. Clause: There is a chance that this patch might not be seen in -next for ~24-48hrs. If it's not there by 72hrs, feel free to poke. diff --git a/drivers/mfd/cros_ec.c b/drivers/mfd/cros_ec.c index 04e053c..2e86c28 100644 --- a/drivers/mfd/cros_ec.c +++ b/drivers/mfd/cros_ec.c @@ -25,22 +25,22 @@ #include linux/mfd/cros_ec_commands.h int cros_ec_prepare_tx(struct cros_ec_device *ec_dev, -struct cros_ec_msg *msg) +struct cros_ec_command *msg) { uint8_t *out; int csum, i; - BUG_ON(msg-out_len EC_PROTO2_MAX_PARAM_SIZE); + BUG_ON(msg-outsize EC_PROTO2_MAX_PARAM_SIZE); out = ec_dev-dout; out[0] = EC_CMD_VERSION0 + msg-version; - out[1] = msg-cmd; - out[2] = msg-out_len; + out[1] = msg-command; + out[2] = msg-outsize; csum = out[0] + out[1] + out[2]; - for (i = 0; i msg-out_len; i++) - csum += out[EC_MSG_TX_HEADER_BYTES + i] = msg-out_buf[i]; - out[EC_MSG_TX_HEADER_BYTES + msg-out_len] = (uint8_t)(csum 0xff); + for (i = 0; i msg-outsize; i++) + csum += out[EC_MSG_TX_HEADER_BYTES + i] = msg-outdata[i]; + out[EC_MSG_TX_HEADER_BYTES + msg-outsize] = (uint8_t)(csum 0xff); - return EC_MSG_TX_PROTO_BYTES + msg-out_len; + return EC_MSG_TX_PROTO_BYTES + msg-outsize; } EXPORT_SYMBOL(cros_ec_prepare_tx); @@ -48,14 +48,14 @@ static int cros_ec_command_sendrecv(struct cros_ec_device *ec_dev, uint16_t cmd, void *out_buf, int out_len, void *in_buf, int in_len) { - struct cros_ec_msg msg; + struct cros_ec_command msg; msg.version = cmd 8; - msg.cmd = cmd 0xff; - msg.out_buf = out_buf; - msg.out_len = out_len; - msg.in_buf = in_buf; - msg.in_len = in_len; + msg.command = cmd 0xff; + msg.outdata = out_buf; + msg.outsize = out_len; + msg.indata = in_buf; + msg.insize = in_len; return ec_dev-cmd_xfer(ec_dev, msg); } diff --git a/drivers/mfd/cros_ec_i2c.c b/drivers/mfd/cros_ec_i2c.c index 777e529..37ed12f 100644 --- a/drivers/mfd/cros_ec_i2c.c +++ b/drivers/mfd/cros_ec_i2c.c @@ -30,7 +30,7 @@ static inline struct cros_ec_device *to_ec_dev(struct device *dev) } static int cros_ec_cmd_xfer_i2c(struct cros_ec_device *ec_dev, - struct cros_ec_msg *msg) + struct cros_ec_command *msg) { struct i2c_client *client = ec_dev-priv; int ret = -ENOMEM; @@ -50,7 +50,7 @@ static int cros_ec_cmd_xfer_i2c(struct cros_ec_device *ec_dev, * allocate larger packet (one byte for checksum, one byte for * length, and one for result code) */ - packet_len = msg-in_len + 3; + packet_len = msg-insize + 3; in_buf = kzalloc(packet_len, GFP_KERNEL); if (!in_buf) goto done; @@ -61,7 +61,7 @@ static int cros_ec_cmd_xfer_i2c(struct cros_ec_device *ec_dev, * allocate larger packet (one byte for checksum, one for * command code, one for length, and one for command version) */ - packet_len = msg-out_len + 4; + packet_len = msg-outsize + 4; out_buf = kzalloc(packet_len, GFP_KERNEL); if (!out_buf) goto done; @@ -69,16 +69,16 @@ static int cros_ec_cmd_xfer_i2c(struct cros_ec_device *ec_dev, i2c_msg[0].buf = (char *)out_buf; out_buf[0] = EC_CMD_VERSION0 + msg-version; - out_buf[1] = msg-cmd; - out_buf[2] = msg-out_len; + out_buf[1] = msg-command; + out_buf[2] = msg-outsize; /* copy message payload and compute checksum */ sum = out_buf[0] + out_buf[1] + out_buf[2]; - for (i = 0; i msg-out_len; i++) { - out_buf[3 + i] = msg-out_buf[i]; + for (i = 0; i msg-outsize; i++) { + out_buf[3 + i] = msg-outdata[i]; sum += out_buf[3 + i]; } - out_buf[3 + msg-out_len] = sum; + out_buf[3 + msg-outsize] = sum; /* send command to EC and read answer */ ret = i2c_transfer(client-adapter, i2c_msg, 2); @@ -94,20 +94,20 @@ static int
Re: [PATCH v2 05/10] mfd: cros_ec: Use struct cros_ec_command to communicate with the EC
On 18 June 2014 12:14, Doug Anderson wrote: > From: Bill Richardson > > This is some internal structure reorganization / renaming to prepare > for future patches that will add a userspace API to cros_ec. There > should be no visible changes. > > Signed-off-by: Bill Richardson > Signed-off-by: Doug Anderson > Acked-by: Lee Jones Reviewed-by: Simon Glass -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v2 05/10] mfd: cros_ec: Use struct cros_ec_command to communicate with the EC
On 18 June 2014 12:14, Doug Anderson diand...@chromium.org wrote: From: Bill Richardson wfric...@chromium.org This is some internal structure reorganization / renaming to prepare for future patches that will add a userspace API to cros_ec. There should be no visible changes. Signed-off-by: Bill Richardson wfric...@chromium.org Signed-off-by: Doug Anderson diand...@chromium.org Acked-by: Lee Jones lee.jo...@linaro.org Reviewed-by: Simon Glass s...@chromium.org -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v2 05/10] mfd: cros_ec: Use struct cros_ec_command to communicate with the EC
From: Bill Richardson This is some internal structure reorganization / renaming to prepare for future patches that will add a userspace API to cros_ec. There should be no visible changes. Signed-off-by: Bill Richardson Signed-off-by: Doug Anderson Acked-by: Lee Jones --- Changes in v2: None drivers/mfd/cros_ec.c | 28 ++-- drivers/mfd/cros_ec_i2c.c | 24 drivers/mfd/cros_ec_spi.c | 16 include/linux/mfd/cros_ec.h | 35 ++- 4 files changed, 52 insertions(+), 51 deletions(-) diff --git a/drivers/mfd/cros_ec.c b/drivers/mfd/cros_ec.c index 04e053c..2e86c28 100644 --- a/drivers/mfd/cros_ec.c +++ b/drivers/mfd/cros_ec.c @@ -25,22 +25,22 @@ #include int cros_ec_prepare_tx(struct cros_ec_device *ec_dev, - struct cros_ec_msg *msg) + struct cros_ec_command *msg) { uint8_t *out; int csum, i; - BUG_ON(msg->out_len > EC_PROTO2_MAX_PARAM_SIZE); + BUG_ON(msg->outsize > EC_PROTO2_MAX_PARAM_SIZE); out = ec_dev->dout; out[0] = EC_CMD_VERSION0 + msg->version; - out[1] = msg->cmd; - out[2] = msg->out_len; + out[1] = msg->command; + out[2] = msg->outsize; csum = out[0] + out[1] + out[2]; - for (i = 0; i < msg->out_len; i++) - csum += out[EC_MSG_TX_HEADER_BYTES + i] = msg->out_buf[i]; - out[EC_MSG_TX_HEADER_BYTES + msg->out_len] = (uint8_t)(csum & 0xff); + for (i = 0; i < msg->outsize; i++) + csum += out[EC_MSG_TX_HEADER_BYTES + i] = msg->outdata[i]; + out[EC_MSG_TX_HEADER_BYTES + msg->outsize] = (uint8_t)(csum & 0xff); - return EC_MSG_TX_PROTO_BYTES + msg->out_len; + return EC_MSG_TX_PROTO_BYTES + msg->outsize; } EXPORT_SYMBOL(cros_ec_prepare_tx); @@ -48,14 +48,14 @@ static int cros_ec_command_sendrecv(struct cros_ec_device *ec_dev, uint16_t cmd, void *out_buf, int out_len, void *in_buf, int in_len) { - struct cros_ec_msg msg; + struct cros_ec_command msg; msg.version = cmd >> 8; - msg.cmd = cmd & 0xff; - msg.out_buf = out_buf; - msg.out_len = out_len; - msg.in_buf = in_buf; - msg.in_len = in_len; + msg.command = cmd & 0xff; + msg.outdata = out_buf; + msg.outsize = out_len; + msg.indata = in_buf; + msg.insize = in_len; return ec_dev->cmd_xfer(ec_dev, ); } diff --git a/drivers/mfd/cros_ec_i2c.c b/drivers/mfd/cros_ec_i2c.c index 777e529..37ed12f 100644 --- a/drivers/mfd/cros_ec_i2c.c +++ b/drivers/mfd/cros_ec_i2c.c @@ -30,7 +30,7 @@ static inline struct cros_ec_device *to_ec_dev(struct device *dev) } static int cros_ec_cmd_xfer_i2c(struct cros_ec_device *ec_dev, - struct cros_ec_msg *msg) + struct cros_ec_command *msg) { struct i2c_client *client = ec_dev->priv; int ret = -ENOMEM; @@ -50,7 +50,7 @@ static int cros_ec_cmd_xfer_i2c(struct cros_ec_device *ec_dev, * allocate larger packet (one byte for checksum, one byte for * length, and one for result code) */ - packet_len = msg->in_len + 3; + packet_len = msg->insize + 3; in_buf = kzalloc(packet_len, GFP_KERNEL); if (!in_buf) goto done; @@ -61,7 +61,7 @@ static int cros_ec_cmd_xfer_i2c(struct cros_ec_device *ec_dev, * allocate larger packet (one byte for checksum, one for * command code, one for length, and one for command version) */ - packet_len = msg->out_len + 4; + packet_len = msg->outsize + 4; out_buf = kzalloc(packet_len, GFP_KERNEL); if (!out_buf) goto done; @@ -69,16 +69,16 @@ static int cros_ec_cmd_xfer_i2c(struct cros_ec_device *ec_dev, i2c_msg[0].buf = (char *)out_buf; out_buf[0] = EC_CMD_VERSION0 + msg->version; - out_buf[1] = msg->cmd; - out_buf[2] = msg->out_len; + out_buf[1] = msg->command; + out_buf[2] = msg->outsize; /* copy message payload and compute checksum */ sum = out_buf[0] + out_buf[1] + out_buf[2]; - for (i = 0; i < msg->out_len; i++) { - out_buf[3 + i] = msg->out_buf[i]; + for (i = 0; i < msg->outsize; i++) { + out_buf[3 + i] = msg->outdata[i]; sum += out_buf[3 + i]; } - out_buf[3 + msg->out_len] = sum; + out_buf[3 + msg->outsize] = sum; /* send command to EC and read answer */ ret = i2c_transfer(client->adapter, i2c_msg, 2); @@ -94,20 +94,20 @@ static int cros_ec_cmd_xfer_i2c(struct cros_ec_device *ec_dev, /* check response error code */ if (i2c_msg[1].buf[0]) { dev_warn(ec_dev->dev, "command 0x%02x returned an error %d\n", -msg->cmd, i2c_msg[1].buf[0]); +
[PATCH v2 05/10] mfd: cros_ec: Use struct cros_ec_command to communicate with the EC
From: Bill Richardson wfric...@chromium.org This is some internal structure reorganization / renaming to prepare for future patches that will add a userspace API to cros_ec. There should be no visible changes. Signed-off-by: Bill Richardson wfric...@chromium.org Signed-off-by: Doug Anderson diand...@chromium.org Acked-by: Lee Jones lee.jo...@linaro.org --- Changes in v2: None drivers/mfd/cros_ec.c | 28 ++-- drivers/mfd/cros_ec_i2c.c | 24 drivers/mfd/cros_ec_spi.c | 16 include/linux/mfd/cros_ec.h | 35 ++- 4 files changed, 52 insertions(+), 51 deletions(-) diff --git a/drivers/mfd/cros_ec.c b/drivers/mfd/cros_ec.c index 04e053c..2e86c28 100644 --- a/drivers/mfd/cros_ec.c +++ b/drivers/mfd/cros_ec.c @@ -25,22 +25,22 @@ #include linux/mfd/cros_ec_commands.h int cros_ec_prepare_tx(struct cros_ec_device *ec_dev, - struct cros_ec_msg *msg) + struct cros_ec_command *msg) { uint8_t *out; int csum, i; - BUG_ON(msg-out_len EC_PROTO2_MAX_PARAM_SIZE); + BUG_ON(msg-outsize EC_PROTO2_MAX_PARAM_SIZE); out = ec_dev-dout; out[0] = EC_CMD_VERSION0 + msg-version; - out[1] = msg-cmd; - out[2] = msg-out_len; + out[1] = msg-command; + out[2] = msg-outsize; csum = out[0] + out[1] + out[2]; - for (i = 0; i msg-out_len; i++) - csum += out[EC_MSG_TX_HEADER_BYTES + i] = msg-out_buf[i]; - out[EC_MSG_TX_HEADER_BYTES + msg-out_len] = (uint8_t)(csum 0xff); + for (i = 0; i msg-outsize; i++) + csum += out[EC_MSG_TX_HEADER_BYTES + i] = msg-outdata[i]; + out[EC_MSG_TX_HEADER_BYTES + msg-outsize] = (uint8_t)(csum 0xff); - return EC_MSG_TX_PROTO_BYTES + msg-out_len; + return EC_MSG_TX_PROTO_BYTES + msg-outsize; } EXPORT_SYMBOL(cros_ec_prepare_tx); @@ -48,14 +48,14 @@ static int cros_ec_command_sendrecv(struct cros_ec_device *ec_dev, uint16_t cmd, void *out_buf, int out_len, void *in_buf, int in_len) { - struct cros_ec_msg msg; + struct cros_ec_command msg; msg.version = cmd 8; - msg.cmd = cmd 0xff; - msg.out_buf = out_buf; - msg.out_len = out_len; - msg.in_buf = in_buf; - msg.in_len = in_len; + msg.command = cmd 0xff; + msg.outdata = out_buf; + msg.outsize = out_len; + msg.indata = in_buf; + msg.insize = in_len; return ec_dev-cmd_xfer(ec_dev, msg); } diff --git a/drivers/mfd/cros_ec_i2c.c b/drivers/mfd/cros_ec_i2c.c index 777e529..37ed12f 100644 --- a/drivers/mfd/cros_ec_i2c.c +++ b/drivers/mfd/cros_ec_i2c.c @@ -30,7 +30,7 @@ static inline struct cros_ec_device *to_ec_dev(struct device *dev) } static int cros_ec_cmd_xfer_i2c(struct cros_ec_device *ec_dev, - struct cros_ec_msg *msg) + struct cros_ec_command *msg) { struct i2c_client *client = ec_dev-priv; int ret = -ENOMEM; @@ -50,7 +50,7 @@ static int cros_ec_cmd_xfer_i2c(struct cros_ec_device *ec_dev, * allocate larger packet (one byte for checksum, one byte for * length, and one for result code) */ - packet_len = msg-in_len + 3; + packet_len = msg-insize + 3; in_buf = kzalloc(packet_len, GFP_KERNEL); if (!in_buf) goto done; @@ -61,7 +61,7 @@ static int cros_ec_cmd_xfer_i2c(struct cros_ec_device *ec_dev, * allocate larger packet (one byte for checksum, one for * command code, one for length, and one for command version) */ - packet_len = msg-out_len + 4; + packet_len = msg-outsize + 4; out_buf = kzalloc(packet_len, GFP_KERNEL); if (!out_buf) goto done; @@ -69,16 +69,16 @@ static int cros_ec_cmd_xfer_i2c(struct cros_ec_device *ec_dev, i2c_msg[0].buf = (char *)out_buf; out_buf[0] = EC_CMD_VERSION0 + msg-version; - out_buf[1] = msg-cmd; - out_buf[2] = msg-out_len; + out_buf[1] = msg-command; + out_buf[2] = msg-outsize; /* copy message payload and compute checksum */ sum = out_buf[0] + out_buf[1] + out_buf[2]; - for (i = 0; i msg-out_len; i++) { - out_buf[3 + i] = msg-out_buf[i]; + for (i = 0; i msg-outsize; i++) { + out_buf[3 + i] = msg-outdata[i]; sum += out_buf[3 + i]; } - out_buf[3 + msg-out_len] = sum; + out_buf[3 + msg-outsize] = sum; /* send command to EC and read answer */ ret = i2c_transfer(client-adapter, i2c_msg, 2); @@ -94,20 +94,20 @@ static int cros_ec_cmd_xfer_i2c(struct cros_ec_device *ec_dev, /* check response error code */ if (i2c_msg[1].buf[0]) { dev_warn(ec_dev-dev, command 0x%02x returned an error %d\n, -