[v2,16/17] i2c: cros-ec-tunnel: Use cros_ec_cmd()
diff mbox series

Message ID 20200205192253.187649-1-pmalani@chromium.org
State Awaiting Upstream
Headers show
Series
  • Untitled series #156977
Related show

Commit Message

Prashant Malani Feb. 5, 2020, 7:22 p.m. UTC
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 <pmalani@chromium.org>
---

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(-)

Comments

Wolfram Sang Feb. 22, 2020, 12:53 p.m. UTC | #1
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 <pmalani@chromium.org>

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

Acked-by: Wolfram Sang <wsa@the-dreams.de>

Patch
diff mbox series

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;
 }