2020-02-05 19:24:43

by Prashant Malani

[permalink] [raw]
Subject: [PATCH v2 16/17] i2c: cros-ec-tunnel: Use cros_ec_cmd()

Replace cros_ec_cmd_xfer_status() calls with the new function
cros_ec_cmd() which takes care of the EC message struct setup and
subsequent cleanup (which is a common pattern among users of
cros_ec_cmd_xfer_status).

Signed-off-by: Prashant Malani <[email protected]>
---

Changes in v2:
- Updated to use new function name and parameter list.

drivers/i2c/busses/i2c-cros-ec-tunnel.c | 22 ++++++++--------------
1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/drivers/i2c/busses/i2c-cros-ec-tunnel.c b/drivers/i2c/busses/i2c-cros-ec-tunnel.c
index 958161c71985d9..d0e0db2008d1ca 100644
--- a/drivers/i2c/busses/i2c-cros-ec-tunnel.c
+++ b/drivers/i2c/busses/i2c-cros-ec-tunnel.c
@@ -179,9 +179,8 @@ static int ec_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg i2c_msgs[],
const u16 bus_num = bus->remote_bus;
int request_len;
int response_len;
- int alloc_size;
int result;
- struct cros_ec_command *msg;
+ void *ec_buf;

request_len = ec_i2c_count_message(i2c_msgs, num);
if (request_len < 0) {
@@ -196,36 +195,31 @@ static int ec_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg i2c_msgs[],
return response_len;
}

- alloc_size = max(request_len, response_len);
- msg = kmalloc(sizeof(*msg) + alloc_size, GFP_KERNEL);
- if (!msg)
+ ec_buf = kmalloc(max(request_len, response_len), GFP_KERNEL);
+ if (!ec_buf)
return -ENOMEM;

- result = ec_i2c_construct_message(msg->data, i2c_msgs, num, bus_num);
+ result = ec_i2c_construct_message(ec_buf, i2c_msgs, num, bus_num);
if (result) {
dev_err(dev, "Error constructing EC i2c message %d\n", result);
goto exit;
}

- msg->version = 0;
- msg->command = EC_CMD_I2C_PASSTHRU;
- msg->outsize = request_len;
- msg->insize = response_len;
-
- result = cros_ec_cmd_xfer_status(bus->ec, msg);
+ result = cros_ec_cmd(bus->ec, 0, EC_CMD_I2C_PASSTHRU, ec_buf,
+ request_len, ec_buf, response_len, NULL);
if (result < 0) {
dev_err(dev, "Error transferring EC i2c message %d\n", result);
goto exit;
}

- result = ec_i2c_parse_response(msg->data, i2c_msgs, &num);
+ result = ec_i2c_parse_response(ec_buf, i2c_msgs, &num);
if (result < 0)
goto exit;

/* Indicate success by saying how many messages were sent */
result = num;
exit:
- kfree(msg);
+ kfree(ec_buf);
return result;
}

--
2.25.0.341.g760bfbb309-goog


2020-02-22 12:55:27

by Wolfram Sang

[permalink] [raw]
Subject: Re: [PATCH v2 16/17] i2c: cros-ec-tunnel: Use cros_ec_cmd()

On Wed, Feb 05, 2020 at 11:22:51AM -0800, Prashant Malani wrote:
> Replace cros_ec_cmd_xfer_status() calls with the new function
> cros_ec_cmd() which takes care of the EC message struct setup and
> subsequent cleanup (which is a common pattern among users of
> cros_ec_cmd_xfer_status).
>
> Signed-off-by: Prashant Malani <[email protected]>

I guess the plan is that this series goes upstream as a whole via some
chrome-tree? In that case:

Acked-by: Wolfram Sang <[email protected]>


Attachments:
(No filename) (504.00 B)
signature.asc (849.00 B)
Download all attachments