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>
Subject: [PATCH v2 05/17] platform/chrome: sensorhub: Use cros_ec_cmd()
Date: Wed,  5 Feb 2020 11:00:03 -0800	[thread overview]
Message-ID: <20200205190028.183069-6-pmalani@chromium.org> (raw)
In-Reply-To: <20200205190028.183069-1-pmalani@chromium.org>

Update the register() function to use the new cros_ec_cmd() function
instead 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/platform/chrome/cros_ec_sensorhub.c | 30 +++++++++------------
 1 file changed, 13 insertions(+), 17 deletions(-)

diff --git a/drivers/platform/chrome/cros_ec_sensorhub.c b/drivers/platform/chrome/cros_ec_sensorhub.c
index 79fefd3bb0fa61..3ccf98af89453c 100644
--- a/drivers/platform/chrome/cros_ec_sensorhub.c
+++ b/drivers/platform/chrome/cros_ec_sensorhub.c
@@ -53,7 +53,7 @@ static int cros_ec_sensorhub_register(struct device *dev,
 	struct cros_ec_dev *ec = sensorhub->ec;
 	struct ec_params_motion_sense *params;
 	struct ec_response_motion_sense *resp;
-	struct cros_ec_command *msg;
+	void *ec_buf;
 	int ret, i, sensor_num;
 	char *name;
 
@@ -70,27 +70,24 @@ static int cros_ec_sensorhub_register(struct device *dev,
 		return -EINVAL;
 	}
 
-	/* Prepare a message to send INFO command to each sensor. */
-	msg = kzalloc(sizeof(*msg) + max(sizeof(*params), sizeof(*resp)),
-		      GFP_KERNEL);
-	if (!msg)
+	ec_buf = kzalloc(max(sizeof(*params), sizeof(*resp)), GFP_KERNEL);
+	if (!ec_buf)
 		return -ENOMEM;
 
-	msg->version = 1;
-	msg->command = EC_CMD_MOTION_SENSE_CMD + ec->cmd_offset;
-	msg->outsize = sizeof(*params);
-	msg->insize = sizeof(*resp);
-	params = (struct ec_params_motion_sense *)msg->data;
-	resp = (struct ec_response_motion_sense *)msg->data;
+	params = ec_buf;
+	resp = ec_buf;
 
 	for (i = 0; i < sensor_num; i++) {
 		params->cmd = MOTIONSENSE_CMD_INFO;
 		params->info.sensor_num = i;
 
-		ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg);
+		ret = cros_ec_cmd(ec->ec_dev, 1,
+				  EC_CMD_MOTION_SENSE_CMD + ec->cmd_offset,
+				  params, sizeof(*params), resp, sizeof(*resp),
+				  NULL);
 		if (ret < 0) {
-			dev_warn(dev, "no info for EC sensor %d : %d/%d\n",
-				 i, ret, msg->result);
+			dev_warn(dev, "no info for EC sensor %d : %d\n",
+				 i, ret);
 			continue;
 		}
 
@@ -140,11 +137,10 @@ static int cros_ec_sensorhub_register(struct device *dev,
 			goto error;
 	}
 
-	kfree(msg);
-	return 0;
+	ret =  0;
 
 error:
-	kfree(msg);
+	kfree(ec_buf);
 	return ret;
 }
 
-- 
2.25.0.341.g760bfbb309-goog


  parent reply	other threads:[~2020-02-05 19:06 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20200205190028.183069-1-pmalani@chromium.org>
2020-02-05 18:59 ` [PATCH v2 02/17] platform/chrome: chardev: Use cros_ec_cmd() Prashant Malani
2020-02-05 18:59 ` [PATCH v2 03/17] platform/chrome: proto: " Prashant Malani
2020-02-05 19:00 ` [PATCH v2 04/17] platform/chrome: usbpd_logger: " Prashant Malani
2020-02-05 19:00 ` Prashant Malani [this message]
2020-02-05 19:00 ` [PATCH v2 06/17] platform/chrome: debugfs: " Prashant Malani
2020-02-05 19:00 ` [PATCH v2 07/17] platform/chrome: sysfs: " Prashant Malani
2020-02-05 19:00 ` [PATCH v2 08/17] extcon: cros_ec: " Prashant Malani
2020-02-05 19:00 ` [PATCH v2 09/17] hid: google-hammer: " Prashant Malani
2020-02-05 19:00 ` [PATCH v2 10/17] iio: cros_ec: " Prashant Malani
2020-02-05 19:42   ` Gwendal Grignou
2020-02-06 12:17   ` Jonathan Cameron
2020-02-06 13:45     ` Enric Balletbo i Serra
2020-02-06 18:49       ` Prashant Malani
2020-02-07 18:47         ` Gwendal Grignou
2020-02-10 11:03           ` Enric Balletbo i Serra
2020-02-10 20:14             ` Prashant Malani
2020-02-18 18:30               ` Prashant Malani
2020-02-20 16:07                 ` Enric Balletbo i Serra
2020-02-25  1:26                   ` Prashant Malani
2020-02-05 19:00 ` [PATCH v2 11/17] ASoC: cros_ec_codec: " Prashant Malani
2020-02-06 11:53   ` Mark Brown
2020-02-05 19:00 ` [PATCH v2 12/17] power: supply: cros: " Prashant Malani
2020-02-24 17:13   ` Sebastian Reichel
2020-02-05 19:00 ` [PATCH v2 13/17] pwm: cros-ec: Remove cros_ec_cmd_xfer_status() Prashant Malani
2020-02-05 19:00 ` [PATCH v2 14/17] rtc: cros-ec: Use cros_ec_cmd() Prashant Malani
2020-02-05 20:04   ` Alexandre Belloni
2020-02-05 19:00 ` [PATCH v2 15/17] media: cros-ec-cec: " Prashant Malani
2020-06-24 12:04   ` Hans Verkuil

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=20200205190028.183069-6-pmalani@chromium.org \
    --to=pmalani@chromium.org \
    --cc=bleung@chromium.org \
    --cc=enric.balletbo@collabora.com \
    --cc=groeck@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    /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).