linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Prashant Malani <pmalani@chromium.org>
To: linux-kernel@vger.kernel.org
Cc: Prashant Malani <pmalani@chromium.org>,
	Benson Leung <bleung@chromium.org>,
	Enric Balletbo i Serra <enric.balletbo@collabora.com>,
	Guenter Roeck <groeck@chromium.org>,
	Wolfram Sang <wsa@the-dreams.de>,
	Jonathan Cameron <Jonathan.Cameron@huawei.com>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Akshu Agrawal <akshu.agrawal@amd.com>,
	linux-i2c@vger.kernel.org (open list:I2C SUBSYSTEM HOST DRIVERS)
Subject: [PATCH 16/17] i2c: cros-ec-tunnel: Use cros_ec_send_cmd_msg()
Date: Thu, 30 Jan 2020 12:31:08 -0800	[thread overview]
Message-ID: <20200130203106.201894-17-pmalani@chromium.org> (raw)
In-Reply-To: <20200130203106.201894-1-pmalani@chromium.org>

Replace cros_ec_cmd_xfer_status() calls with the new function
cros_ec_send_cmd_msg() 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>
---
 drivers/i2c/busses/i2c-cros-ec-tunnel.c | 23 +++++++++--------------
 1 file changed, 9 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..50161dff912298 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,32 @@ 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_send_cmd_msg(bus->ec, 0, EC_CMD_I2C_PASSTHRU,
+				      ec_buf, request_len,
+				      ec_buf, response_len);
 	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


  parent reply	other threads:[~2020-01-30 20:36 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-30 20:30 [PATCH 00/17] platform/chrome: Replace cros_ec_cmd_xfer_status Prashant Malani
2020-01-30 20:30 ` [PATCH 01/17] platform/chrome: Add EC command msg wrapper Prashant Malani
2020-02-03 15:27   ` Enric Balletbo i Serra
2020-02-03 18:24     ` Prashant Malani
2020-01-30 20:30 ` [PATCH 02/17] platform/chrome: chardev: Use send_cmd_msg() Prashant Malani
2020-01-30 20:30 ` [PATCH 03/17] platform/chrome: proto: Use send_cmd_msg Prashant Malani
2020-01-30 20:30 ` [PATCH 04/17] platform/chrome: usbpd_logger: Use cmd_send_msg() Prashant Malani
2020-01-30 20:30 ` [PATCH 05/17] platform/chrome: sensorhub: Use send_cmd_msg() Prashant Malani
2020-01-30 20:30 ` [PATCH 06/17] platform/chrome: debugfs: " Prashant Malani
2020-01-30 20:30 ` [PATCH 07/17] platform/chrome: sysfs: " Prashant Malani
2020-01-30 20:30 ` [PATCH 08/17] extcon: cros_ec: Use cros_ec_send_cmd_msg() Prashant Malani
2020-01-30 20:30 ` [PATCH 09/17] hid: google-hammer: " Prashant Malani
2020-01-30 20:30 ` [PATCH 10/17] iio: cros_ec: " Prashant Malani
2020-02-02  9:43   ` Jonathan Cameron
2020-02-03 18:31     ` Prashant Malani
2020-01-30 20:30 ` [PATCH 11/17] ASoC: cros_ec_codec: " Prashant Malani
2020-02-01 11:03   ` Mark Brown
2020-02-03 18:42     ` Prashant Malani
2020-01-30 20:30 ` [PATCH 12/17] power: supply: cros: " Prashant Malani
2020-01-30 20:31 ` [PATCH 13/17] pwm: cros-ec: Remove cros_ec_cmd_xfer_status() Prashant Malani
2020-02-03 15:33   ` Enric Balletbo i Serra
2020-02-03 18:26     ` Prashant Malani
2020-02-03 18:39       ` Prashant Malani
2020-01-30 20:31 ` [PATCH 14/17] rtc: cros-ec: Use cros_ec_send_cmd_msg() Prashant Malani
2020-01-30 20:31 ` [PATCH 15/17] media: cros-ec-cec: " Prashant Malani
2020-02-02 22:08   ` kbuild test robot
2020-02-03  5:35   ` kbuild test robot
2020-01-30 20:31 ` Prashant Malani [this message]
2020-01-30 20:31 ` [PATCH 17/17] platform/chrome: Drop cros_ec_cmd_xfer_status() Prashant Malani
2020-02-03 15:35   ` Enric Balletbo i Serra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200130203106.201894-17-pmalani@chromium.org \
    --to=pmalani@chromium.org \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=akshu.agrawal@amd.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=bleung@chromium.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=enric.balletbo@collabora.com \
    --cc=groeck@chromium.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wsa@the-dreams.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).