linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 16/17] i2c: cros-ec-tunnel: Use cros_ec_cmd()
@ 2020-02-05 19:22 Prashant Malani
  2020-02-22 12:53 ` Wolfram Sang
  0 siblings, 1 reply; 2+ messages in thread
From: Prashant Malani @ 2020-02-05 19:22 UTC (permalink / raw)
  To: linux-kernel
  Cc: Prashant Malani, Benson Leung, Enric Balletbo i Serra,
	Guenter Roeck, Wolfram Sang, Gwendal Grignou, Lee Jones,
	Chanwoo Choi, Akshu Agrawal,
	open list:I2C SUBSYSTEM HOST DRIVERS

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

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2 16/17] i2c: cros-ec-tunnel: Use cros_ec_cmd()
  2020-02-05 19:22 [PATCH v2 16/17] i2c: cros-ec-tunnel: Use cros_ec_cmd() Prashant Malani
@ 2020-02-22 12:53 ` Wolfram Sang
  0 siblings, 0 replies; 2+ messages in thread
From: Wolfram Sang @ 2020-02-22 12:53 UTC (permalink / raw)
  To: Prashant Malani
  Cc: linux-kernel, Benson Leung, Enric Balletbo i Serra,
	Guenter Roeck, Gwendal Grignou, Lee Jones, Chanwoo Choi,
	Akshu Agrawal, open list:I2C SUBSYSTEM HOST DRIVERS

[-- Attachment #1: Type: text/plain, Size: 504 bytes --]

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>


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-02-22 12:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-05 19:22 [PATCH v2 16/17] i2c: cros-ec-tunnel: Use cros_ec_cmd() Prashant Malani
2020-02-22 12:53 ` Wolfram Sang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).