All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] platform/chrome: cros_ec_command() improvements
@ 2022-06-06 20:17 Prashant Malani
  2022-06-06 20:18 ` [PATCH 1/3] regulator: cros-ec: Use common cros_ec_command() Prashant Malani
                   ` (4 more replies)
  0 siblings, 5 replies; 14+ messages in thread
From: Prashant Malani @ 2022-06-06 20:17 UTC (permalink / raw)
  To: linux-kernel
  Cc: bleung, Prashant Malani, Brian Norris,
	open list:CHROME HARDWARE PLATFORM SUPPORT,
	Enric Balletbo i Serra, Guenter Roeck, Lee Jones, Liam Girdwood,
	Mark Brown, Tzung-Bi Shih

This is a short series related to cros_ec_command(). The first patch
updates a couple of Cros EC regulator callsites to use the common
cros_ec_command(). The next couple of patches do a rename and argument
type update.

Prashant Malani (3):
  regulator: cros-ec: Use common cros_ec_command()
  platform/chrome: cros_ec_proto: Rename cros_ec_command function
  platform/chrome: cros_ec_proto: Update size arg types

 drivers/mfd/cros_ec_dev.c                   |  4 +--
 drivers/platform/chrome/cros_ec_proto.c     | 22 ++++++------
 drivers/platform/chrome/cros_ec_typec.c     | 39 ++++++++++-----------
 drivers/platform/chrome/cros_usbpd_notify.c |  4 +--
 drivers/regulator/cros-ec-regulator.c       | 36 ++-----------------
 include/linux/platform_data/cros_ec_proto.h |  4 +--
 6 files changed, 39 insertions(+), 70 deletions(-)

-- 
2.36.1.255.ge46751e96f-goog


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

* [PATCH 1/3] regulator: cros-ec: Use common cros_ec_command()
  2022-06-06 20:17 [PATCH 0/3] platform/chrome: cros_ec_command() improvements Prashant Malani
@ 2022-06-06 20:18 ` Prashant Malani
  2022-06-06 23:31   ` Stephen Boyd
                     ` (2 more replies)
  2022-06-06 20:18 ` [PATCH 2/3] platform/chrome: cros_ec_proto: Rename cros_ec_command function Prashant Malani
                   ` (3 subsequent siblings)
  4 siblings, 3 replies; 14+ messages in thread
From: Prashant Malani @ 2022-06-06 20:18 UTC (permalink / raw)
  To: linux-kernel
  Cc: bleung, Prashant Malani, Stephen Boyd,
	open list:CHROME HARDWARE PLATFORM SUPPORT, Daisuke Nojiri,
	Enric Balletbo i Serra, Guenter Roeck, Lee Jones, Liam Girdwood,
	Mark Brown, Tzung-Bi Shih

Reduce code duplication by using the common cros_ec_command() function
instead of the locally defined variant.

Cc: Stephen Boyd <swboyd@chromium.org>
Signed-off-by: Prashant Malani <pmalani@chromium.org>
---
 drivers/regulator/cros-ec-regulator.c | 54 ++++++---------------------
 1 file changed, 12 insertions(+), 42 deletions(-)

diff --git a/drivers/regulator/cros-ec-regulator.c b/drivers/regulator/cros-ec-regulator.c
index c4754f3cf233..1c5fc74a4776 100644
--- a/drivers/regulator/cros-ec-regulator.c
+++ b/drivers/regulator/cros-ec-regulator.c
@@ -22,36 +22,6 @@ struct cros_ec_regulator_data {
 	u16 num_voltages;
 };
 
-static int cros_ec_cmd(struct cros_ec_device *ec, u32 version, u32 command,
-		       void *outdata, u32 outsize, void *indata, u32 insize)
-{
-	struct cros_ec_command *msg;
-	int ret;
-
-	msg = kzalloc(sizeof(*msg) + max(outsize, insize), GFP_KERNEL);
-	if (!msg)
-		return -ENOMEM;
-
-	msg->version = version;
-	msg->command = command;
-	msg->outsize = outsize;
-	msg->insize = insize;
-
-	if (outdata && outsize > 0)
-		memcpy(msg->data, outdata, outsize);
-
-	ret = cros_ec_cmd_xfer_status(ec, msg);
-	if (ret < 0)
-		goto cleanup;
-
-	if (insize)
-		memcpy(indata, msg->data, insize);
-
-cleanup:
-	kfree(msg);
-	return ret;
-}
-
 static int cros_ec_regulator_enable(struct regulator_dev *dev)
 {
 	struct cros_ec_regulator_data *data = rdev_get_drvdata(dev);
@@ -60,8 +30,8 @@ static int cros_ec_regulator_enable(struct regulator_dev *dev)
 		.enable = 1,
 	};
 
-	return cros_ec_cmd(data->ec_dev, 0, EC_CMD_REGULATOR_ENABLE, &cmd,
-			  sizeof(cmd), NULL, 0);
+	return cros_ec_command(data->ec_dev, 0, EC_CMD_REGULATOR_ENABLE, &cmd,
+			       sizeof(cmd), NULL, 0);
 }
 
 static int cros_ec_regulator_disable(struct regulator_dev *dev)
@@ -72,8 +42,8 @@ static int cros_ec_regulator_disable(struct regulator_dev *dev)
 		.enable = 0,
 	};
 
-	return cros_ec_cmd(data->ec_dev, 0, EC_CMD_REGULATOR_ENABLE, &cmd,
-			  sizeof(cmd), NULL, 0);
+	return cros_ec_command(data->ec_dev, 0, EC_CMD_REGULATOR_ENABLE, &cmd,
+			       sizeof(cmd), NULL, 0);
 }
 
 static int cros_ec_regulator_is_enabled(struct regulator_dev *dev)
@@ -85,8 +55,8 @@ static int cros_ec_regulator_is_enabled(struct regulator_dev *dev)
 	struct ec_response_regulator_is_enabled resp;
 	int ret;
 
-	ret = cros_ec_cmd(data->ec_dev, 0, EC_CMD_REGULATOR_IS_ENABLED, &cmd,
-			  sizeof(cmd), &resp, sizeof(resp));
+	ret = cros_ec_command(data->ec_dev, 0, EC_CMD_REGULATOR_IS_ENABLED, &cmd,
+			      sizeof(cmd), &resp, sizeof(resp));
 	if (ret < 0)
 		return ret;
 	return resp.enabled;
@@ -112,8 +82,8 @@ static int cros_ec_regulator_get_voltage(struct regulator_dev *dev)
 	struct ec_response_regulator_get_voltage resp;
 	int ret;
 
-	ret = cros_ec_cmd(data->ec_dev, 0, EC_CMD_REGULATOR_GET_VOLTAGE, &cmd,
-			  sizeof(cmd), &resp, sizeof(resp));
+	ret = cros_ec_command(data->ec_dev, 0, EC_CMD_REGULATOR_GET_VOLTAGE, &cmd,
+			      sizeof(cmd), &resp, sizeof(resp));
 	if (ret < 0)
 		return ret;
 	return resp.voltage_mv * 1000;
@@ -138,8 +108,8 @@ static int cros_ec_regulator_set_voltage(struct regulator_dev *dev, int min_uV,
 	if (min_mV > max_mV)
 		return -EINVAL;
 
-	return cros_ec_cmd(data->ec_dev, 0, EC_CMD_REGULATOR_SET_VOLTAGE, &cmd,
-			   sizeof(cmd), NULL, 0);
+	return cros_ec_command(data->ec_dev, 0, EC_CMD_REGULATOR_SET_VOLTAGE, &cmd,
+			       sizeof(cmd), NULL, 0);
 }
 
 static const struct regulator_ops cros_ec_regulator_voltage_ops = {
@@ -160,8 +130,8 @@ static int cros_ec_regulator_init_info(struct device *dev,
 	struct ec_response_regulator_get_info resp;
 	int ret;
 
-	ret = cros_ec_cmd(data->ec_dev, 0, EC_CMD_REGULATOR_GET_INFO, &cmd,
-			   sizeof(cmd), &resp, sizeof(resp));
+	ret = cros_ec_command(data->ec_dev, 0, EC_CMD_REGULATOR_GET_INFO, &cmd,
+			      sizeof(cmd), &resp, sizeof(resp));
 	if (ret < 0)
 		return ret;
 
-- 
2.36.1.255.ge46751e96f-goog


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

* [PATCH 2/3] platform/chrome: cros_ec_proto: Rename cros_ec_command function
  2022-06-06 20:17 [PATCH 0/3] platform/chrome: cros_ec_command() improvements Prashant Malani
  2022-06-06 20:18 ` [PATCH 1/3] regulator: cros-ec: Use common cros_ec_command() Prashant Malani
@ 2022-06-06 20:18 ` Prashant Malani
  2022-06-06 23:32   ` Stephen Boyd
                     ` (2 more replies)
  2022-06-06 20:18 ` [PATCH 3/3] platform/chrome: cros_ec_proto: Update size arg types Prashant Malani
                   ` (2 subsequent siblings)
  4 siblings, 3 replies; 14+ messages in thread
From: Prashant Malani @ 2022-06-06 20:18 UTC (permalink / raw)
  To: linux-kernel
  Cc: bleung, Prashant Malani, Stephen Boyd, Brian Norris,
	open list:CHROME HARDWARE PLATFORM SUPPORT,
	Enric Balletbo i Serra, Guenter Roeck, Lee Jones, Liam Girdwood,
	Mark Brown, Tzung-Bi Shih

cros_ec_command() is the name of a function as well as a struct, as such
it can confuse indexing tools (like ctags). Avoid this by renaming it to
cros_ec_cmd(). Update all the callsites to use the new name.

This patch is a find-and-replace, so should not introduce any functional
changes.

Suggested-by: Stephen Boyd <swboyd@chromium.org>
Signed-off-by: Prashant Malani <pmalani@chromium.org>
---
 drivers/mfd/cros_ec_dev.c                   |  4 +--
 drivers/platform/chrome/cros_ec_proto.c     | 22 ++++++------
 drivers/platform/chrome/cros_ec_typec.c     | 39 ++++++++++-----------
 drivers/platform/chrome/cros_usbpd_notify.c |  4 +--
 drivers/regulator/cros-ec-regulator.c       | 24 ++++++-------
 include/linux/platform_data/cros_ec_proto.h |  2 +-
 6 files changed, 47 insertions(+), 48 deletions(-)

diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c
index 596731caf407..02d4271dfe06 100644
--- a/drivers/mfd/cros_ec_dev.c
+++ b/drivers/mfd/cros_ec_dev.c
@@ -250,8 +250,8 @@ static int ec_device_probe(struct platform_device *pdev)
 	 * The PCHG device cannot be detected by sending EC_FEATURE_GET_CMD, but
 	 * it can be detected by querying the number of peripheral chargers.
 	 */
-	retval = cros_ec_command(ec->ec_dev, 0, EC_CMD_PCHG_COUNT, NULL, 0,
-				 &pchg_count, sizeof(pchg_count));
+	retval = cros_ec_cmd(ec->ec_dev, 0, EC_CMD_PCHG_COUNT, NULL, 0,
+			     &pchg_count, sizeof(pchg_count));
 	if (retval >= 0 && pchg_count.port_count) {
 		retval = mfd_add_hotplug_devices(ec->dev,
 					cros_ec_pchg_cells,
diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/chrome/cros_ec_proto.c
index 13ced9d2dd71..b6bea183ee28 100644
--- a/drivers/platform/chrome/cros_ec_proto.c
+++ b/drivers/platform/chrome/cros_ec_proto.c
@@ -860,8 +860,8 @@ bool cros_ec_check_features(struct cros_ec_dev *ec, int feature)
 
 	if (features->flags[0] == -1U && features->flags[1] == -1U) {
 		/* features bitmap not read yet */
-		ret = cros_ec_command(ec->ec_dev, 0, EC_CMD_GET_FEATURES + ec->cmd_offset,
-				      NULL, 0, features, sizeof(*features));
+		ret = cros_ec_cmd(ec->ec_dev, 0, EC_CMD_GET_FEATURES + ec->cmd_offset,
+				  NULL, 0, features, sizeof(*features));
 		if (ret < 0) {
 			dev_warn(ec->dev, "cannot get EC features: %d\n", ret);
 			memset(features, 0, sizeof(*features));
@@ -942,7 +942,7 @@ int cros_ec_get_sensor_count(struct cros_ec_dev *ec)
 EXPORT_SYMBOL_GPL(cros_ec_get_sensor_count);
 
 /**
- * cros_ec_command - Send a command to the EC.
+ * cros_ec_cmd - Send a command to the EC.
  *
  * @ec_dev: EC device
  * @version: EC command version
@@ -954,13 +954,13 @@ EXPORT_SYMBOL_GPL(cros_ec_get_sensor_count);
  *
  * Return: >= 0 on success, negative error number on failure.
  */
-int cros_ec_command(struct cros_ec_device *ec_dev,
-		    unsigned int version,
-		    int command,
-		    void *outdata,
-		    int outsize,
-		    void *indata,
-		    int insize)
+int cros_ec_cmd(struct cros_ec_device *ec_dev,
+		unsigned int version,
+		int command,
+		void *outdata,
+		int outsize,
+		void *indata,
+		int insize)
 {
 	struct cros_ec_command *msg;
 	int ret;
@@ -987,4 +987,4 @@ int cros_ec_command(struct cros_ec_device *ec_dev,
 	kfree(msg);
 	return ret;
 }
-EXPORT_SYMBOL_GPL(cros_ec_command);
+EXPORT_SYMBOL_GPL(cros_ec_cmd);
diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
index 7cb2e35c4ded..d6088ba447af 100644
--- a/drivers/platform/chrome/cros_ec_typec.c
+++ b/drivers/platform/chrome/cros_ec_typec.c
@@ -525,8 +525,8 @@ static int cros_typec_configure_mux(struct cros_typec_data *typec, int port_num,
 	enum typec_orientation orientation;
 	int ret;
 
-	ret = cros_ec_command(typec->ec, 0, EC_CMD_USB_PD_MUX_INFO,
-			      &req, sizeof(req), &resp, sizeof(resp));
+	ret = cros_ec_cmd(typec->ec, 0, EC_CMD_USB_PD_MUX_INFO,
+			  &req, sizeof(req), &resp, sizeof(resp));
 	if (ret < 0) {
 		dev_warn(typec->dev, "Failed to get mux info for port: %d, err = %d\n",
 			 port_num, ret);
@@ -585,8 +585,8 @@ static int cros_typec_configure_mux(struct cros_typec_data *typec, int port_num,
 	/* Sending Acknowledgment to EC */
 	mux_ack.port = port_num;
 
-	if (cros_ec_command(typec->ec, 0, EC_CMD_USB_PD_MUX_ACK, &mux_ack,
-			    sizeof(mux_ack), NULL, 0) < 0)
+	if (cros_ec_cmd(typec->ec, 0, EC_CMD_USB_PD_MUX_ACK, &mux_ack,
+			sizeof(mux_ack), NULL, 0) < 0)
 		dev_warn(typec->dev,
 			 "Failed to send Mux ACK to EC for port: %d\n",
 			 port_num);
@@ -754,8 +754,8 @@ static int cros_typec_handle_sop_prime_disc(struct cros_typec_data *typec, int p
 	int ret = 0;
 
 	memset(disc, 0, EC_PROTO2_MAX_RESPONSE_SIZE);
-	ret = cros_ec_command(typec->ec, 0, EC_CMD_TYPEC_DISCOVERY, &req, sizeof(req),
-			      disc, EC_PROTO2_MAX_RESPONSE_SIZE);
+	ret = cros_ec_cmd(typec->ec, 0, EC_CMD_TYPEC_DISCOVERY, &req, sizeof(req),
+			  disc, EC_PROTO2_MAX_RESPONSE_SIZE);
 	if (ret < 0) {
 		dev_err(typec->dev, "Failed to get SOP' discovery data for port: %d\n", port_num);
 		goto sop_prime_disc_exit;
@@ -837,8 +837,8 @@ static int cros_typec_handle_sop_disc(struct cros_typec_data *typec, int port_nu
 	typec_partner_set_pd_revision(port->partner, pd_revision);
 
 	memset(sop_disc, 0, EC_PROTO2_MAX_RESPONSE_SIZE);
-	ret = cros_ec_command(typec->ec, 0, EC_CMD_TYPEC_DISCOVERY, &req, sizeof(req),
-			      sop_disc, EC_PROTO2_MAX_RESPONSE_SIZE);
+	ret = cros_ec_cmd(typec->ec, 0, EC_CMD_TYPEC_DISCOVERY, &req, sizeof(req),
+			  sop_disc, EC_PROTO2_MAX_RESPONSE_SIZE);
 	if (ret < 0) {
 		dev_err(typec->dev, "Failed to get SOP discovery data for port: %d\n", port_num);
 		goto disc_exit;
@@ -870,8 +870,8 @@ static int cros_typec_send_clear_event(struct cros_typec_data *typec, int port_n
 		.clear_events_mask = events_mask,
 	};
 
-	return cros_ec_command(typec->ec, 0, EC_CMD_TYPEC_CONTROL, &req,
-			       sizeof(req), NULL, 0);
+	return cros_ec_cmd(typec->ec, 0, EC_CMD_TYPEC_CONTROL, &req,
+			   sizeof(req), NULL, 0);
 }
 
 static void cros_typec_handle_status(struct cros_typec_data *typec, int port_num)
@@ -882,8 +882,8 @@ static void cros_typec_handle_status(struct cros_typec_data *typec, int port_num
 	};
 	int ret;
 
-	ret = cros_ec_command(typec->ec, 0, EC_CMD_TYPEC_STATUS, &req, sizeof(req),
-			      &resp, sizeof(resp));
+	ret = cros_ec_cmd(typec->ec, 0, EC_CMD_TYPEC_STATUS, &req, sizeof(req),
+			  &resp, sizeof(resp));
 	if (ret < 0) {
 		dev_warn(typec->dev, "EC_CMD_TYPEC_STATUS failed for port: %d\n", port_num);
 		return;
@@ -960,9 +960,9 @@ static int cros_typec_port_update(struct cros_typec_data *typec, int port_num)
 	req.mux = USB_PD_CTRL_MUX_NO_CHANGE;
 	req.swap = USB_PD_CTRL_SWAP_NONE;
 
-	ret = cros_ec_command(typec->ec, typec->pd_ctrl_ver,
-			      EC_CMD_USB_PD_CONTROL, &req, sizeof(req),
-			      &resp, sizeof(resp));
+	ret = cros_ec_cmd(typec->ec, typec->pd_ctrl_ver,
+			  EC_CMD_USB_PD_CONTROL, &req, sizeof(req),
+			  &resp, sizeof(resp));
 	if (ret < 0)
 		return ret;
 
@@ -997,9 +997,8 @@ static int cros_typec_get_cmd_version(struct cros_typec_data *typec)
 
 	/* We're interested in the PD control command version. */
 	req_v1.cmd = EC_CMD_USB_PD_CONTROL;
-	ret = cros_ec_command(typec->ec, 1, EC_CMD_GET_CMD_VERSIONS,
-			      &req_v1, sizeof(req_v1), &resp,
-				    sizeof(resp));
+	ret = cros_ec_cmd(typec->ec, 1, EC_CMD_GET_CMD_VERSIONS,
+			  &req_v1, sizeof(req_v1), &resp, sizeof(resp));
 	if (ret < 0)
 		return ret;
 
@@ -1090,8 +1089,8 @@ static int cros_typec_probe(struct platform_device *pdev)
 	typec->typec_cmd_supported = cros_ec_check_features(ec_dev, EC_FEATURE_TYPEC_CMD);
 	typec->needs_mux_ack = cros_ec_check_features(ec_dev, EC_FEATURE_TYPEC_MUX_REQUIRE_AP_ACK);
 
-	ret = cros_ec_command(typec->ec, 0, EC_CMD_USB_PD_PORTS, NULL, 0,
-			      &resp, sizeof(resp));
+	ret = cros_ec_cmd(typec->ec, 0, EC_CMD_USB_PD_PORTS, NULL, 0,
+			  &resp, sizeof(resp));
 	if (ret < 0)
 		return ret;
 
diff --git a/drivers/platform/chrome/cros_usbpd_notify.c b/drivers/platform/chrome/cros_usbpd_notify.c
index 91ce6be91aac..4b5a81c9dc6d 100644
--- a/drivers/platform/chrome/cros_usbpd_notify.c
+++ b/drivers/platform/chrome/cros_usbpd_notify.c
@@ -71,8 +71,8 @@ static void cros_usbpd_get_event_and_notify(struct device  *dev,
 	}
 
 	/* Check for PD host events on EC. */
-	ret = cros_ec_command(ec_dev, 0, EC_CMD_PD_HOST_EVENT_STATUS,
-			      NULL, 0, &host_event_status, sizeof(host_event_status));
+	ret = cros_ec_cmd(ec_dev, 0, EC_CMD_PD_HOST_EVENT_STATUS,
+			  NULL, 0, &host_event_status, sizeof(host_event_status));
 	if (ret < 0) {
 		dev_warn(dev, "Can't get host event status (err: %d)\n", ret);
 		goto send_notify;
diff --git a/drivers/regulator/cros-ec-regulator.c b/drivers/regulator/cros-ec-regulator.c
index 1c5fc74a4776..1591636f86c3 100644
--- a/drivers/regulator/cros-ec-regulator.c
+++ b/drivers/regulator/cros-ec-regulator.c
@@ -30,8 +30,8 @@ static int cros_ec_regulator_enable(struct regulator_dev *dev)
 		.enable = 1,
 	};
 
-	return cros_ec_command(data->ec_dev, 0, EC_CMD_REGULATOR_ENABLE, &cmd,
-			       sizeof(cmd), NULL, 0);
+	return cros_ec_cmd(data->ec_dev, 0, EC_CMD_REGULATOR_ENABLE, &cmd,
+			   sizeof(cmd), NULL, 0);
 }
 
 static int cros_ec_regulator_disable(struct regulator_dev *dev)
@@ -42,8 +42,8 @@ static int cros_ec_regulator_disable(struct regulator_dev *dev)
 		.enable = 0,
 	};
 
-	return cros_ec_command(data->ec_dev, 0, EC_CMD_REGULATOR_ENABLE, &cmd,
-			       sizeof(cmd), NULL, 0);
+	return cros_ec_cmd(data->ec_dev, 0, EC_CMD_REGULATOR_ENABLE, &cmd,
+			   sizeof(cmd), NULL, 0);
 }
 
 static int cros_ec_regulator_is_enabled(struct regulator_dev *dev)
@@ -55,8 +55,8 @@ static int cros_ec_regulator_is_enabled(struct regulator_dev *dev)
 	struct ec_response_regulator_is_enabled resp;
 	int ret;
 
-	ret = cros_ec_command(data->ec_dev, 0, EC_CMD_REGULATOR_IS_ENABLED, &cmd,
-			      sizeof(cmd), &resp, sizeof(resp));
+	ret = cros_ec_cmd(data->ec_dev, 0, EC_CMD_REGULATOR_IS_ENABLED, &cmd,
+			  sizeof(cmd), &resp, sizeof(resp));
 	if (ret < 0)
 		return ret;
 	return resp.enabled;
@@ -82,8 +82,8 @@ static int cros_ec_regulator_get_voltage(struct regulator_dev *dev)
 	struct ec_response_regulator_get_voltage resp;
 	int ret;
 
-	ret = cros_ec_command(data->ec_dev, 0, EC_CMD_REGULATOR_GET_VOLTAGE, &cmd,
-			      sizeof(cmd), &resp, sizeof(resp));
+	ret = cros_ec_cmd(data->ec_dev, 0, EC_CMD_REGULATOR_GET_VOLTAGE, &cmd,
+			  sizeof(cmd), &resp, sizeof(resp));
 	if (ret < 0)
 		return ret;
 	return resp.voltage_mv * 1000;
@@ -108,8 +108,8 @@ static int cros_ec_regulator_set_voltage(struct regulator_dev *dev, int min_uV,
 	if (min_mV > max_mV)
 		return -EINVAL;
 
-	return cros_ec_command(data->ec_dev, 0, EC_CMD_REGULATOR_SET_VOLTAGE, &cmd,
-			       sizeof(cmd), NULL, 0);
+	return cros_ec_cmd(data->ec_dev, 0, EC_CMD_REGULATOR_SET_VOLTAGE, &cmd,
+			   sizeof(cmd), NULL, 0);
 }
 
 static const struct regulator_ops cros_ec_regulator_voltage_ops = {
@@ -130,8 +130,8 @@ static int cros_ec_regulator_init_info(struct device *dev,
 	struct ec_response_regulator_get_info resp;
 	int ret;
 
-	ret = cros_ec_command(data->ec_dev, 0, EC_CMD_REGULATOR_GET_INFO, &cmd,
-			      sizeof(cmd), &resp, sizeof(resp));
+	ret = cros_ec_cmd(data->ec_dev, 0, EC_CMD_REGULATOR_GET_INFO, &cmd,
+			  sizeof(cmd), &resp, sizeof(resp));
 	if (ret < 0)
 		return ret;
 
diff --git a/include/linux/platform_data/cros_ec_proto.h b/include/linux/platform_data/cros_ec_proto.h
index 138fd912c808..816da4eef3e5 100644
--- a/include/linux/platform_data/cros_ec_proto.h
+++ b/include/linux/platform_data/cros_ec_proto.h
@@ -231,7 +231,7 @@ bool cros_ec_check_features(struct cros_ec_dev *ec, int feature);
 
 int cros_ec_get_sensor_count(struct cros_ec_dev *ec);
 
-int cros_ec_command(struct cros_ec_device *ec_dev, unsigned int version, int command, void *outdata,
+int cros_ec_cmd(struct cros_ec_device *ec_dev, unsigned int version, int command, void *outdata,
 		    int outsize, void *indata, int insize);
 
 /**
-- 
2.36.1.255.ge46751e96f-goog


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

* [PATCH 3/3] platform/chrome: cros_ec_proto: Update size arg types
  2022-06-06 20:17 [PATCH 0/3] platform/chrome: cros_ec_command() improvements Prashant Malani
  2022-06-06 20:18 ` [PATCH 1/3] regulator: cros-ec: Use common cros_ec_command() Prashant Malani
  2022-06-06 20:18 ` [PATCH 2/3] platform/chrome: cros_ec_proto: Rename cros_ec_command function Prashant Malani
@ 2022-06-06 20:18 ` Prashant Malani
  2022-06-06 23:34   ` Stephen Boyd
  2022-06-07 14:41   ` Guenter Roeck
  2022-06-08  8:20 ` [PATCH 0/3] platform/chrome: cros_ec_command() improvements patchwork-bot+chrome-platform
  2022-06-10  2:30 ` patchwork-bot+chrome-platform
  4 siblings, 2 replies; 14+ messages in thread
From: Prashant Malani @ 2022-06-06 20:18 UTC (permalink / raw)
  To: linux-kernel
  Cc: bleung, Prashant Malani, Stephen Boyd, Guenter Roeck,
	Enric Balletbo i Serra, Tzung-Bi Shih, Brian Norris,
	open list:CHROME HARDWARE PLATFORM SUPPORT

cros_ec_cmd() takes 2 size arguments. Update them to be of the more
appropriate type size_t.

Suggested-by: Stephen Boyd <swboyd@chromium.org>
Signed-off-by: Prashant Malani <pmalani@chromium.org>
---
 drivers/platform/chrome/cros_ec_proto.c     | 4 ++--
 include/linux/platform_data/cros_ec_proto.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/chrome/cros_ec_proto.c
index b6bea183ee28..cefabfe45551 100644
--- a/drivers/platform/chrome/cros_ec_proto.c
+++ b/drivers/platform/chrome/cros_ec_proto.c
@@ -958,9 +958,9 @@ int cros_ec_cmd(struct cros_ec_device *ec_dev,
 		unsigned int version,
 		int command,
 		void *outdata,
-		int outsize,
+		size_t outsize,
 		void *indata,
-		int insize)
+		size_t insize)
 {
 	struct cros_ec_command *msg;
 	int ret;
diff --git a/include/linux/platform_data/cros_ec_proto.h b/include/linux/platform_data/cros_ec_proto.h
index 816da4eef3e5..85e29300f63d 100644
--- a/include/linux/platform_data/cros_ec_proto.h
+++ b/include/linux/platform_data/cros_ec_proto.h
@@ -232,7 +232,7 @@ bool cros_ec_check_features(struct cros_ec_dev *ec, int feature);
 int cros_ec_get_sensor_count(struct cros_ec_dev *ec);
 
 int cros_ec_cmd(struct cros_ec_device *ec_dev, unsigned int version, int command, void *outdata,
-		    int outsize, void *indata, int insize);
+		    size_t outsize, void *indata, size_t insize);
 
 /**
  * cros_ec_get_time_ns() - Return time in ns.
-- 
2.36.1.255.ge46751e96f-goog


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

* Re: [PATCH 1/3] regulator: cros-ec: Use common cros_ec_command()
  2022-06-06 20:18 ` [PATCH 1/3] regulator: cros-ec: Use common cros_ec_command() Prashant Malani
@ 2022-06-06 23:31   ` Stephen Boyd
  2022-06-07 14:37   ` Guenter Roeck
  2022-06-07 15:31   ` Mark Brown
  2 siblings, 0 replies; 14+ messages in thread
From: Stephen Boyd @ 2022-06-06 23:31 UTC (permalink / raw)
  To: Prashant Malani, linux-kernel
  Cc: bleung, chrome-platform, Daisuke Nojiri, Enric Balletbo i Serra,
	Guenter Roeck, Lee Jones, Liam Girdwood, Mark Brown,
	Tzung-Bi Shih

Quoting Prashant Malani (2022-06-06 13:18:01)
> Reduce code duplication by using the common cros_ec_command() function
> instead of the locally defined variant.
>
> Cc: Stephen Boyd <swboyd@chromium.org>
> Signed-off-by: Prashant Malani <pmalani@chromium.org>
> ---

Reviewed-by: Stephen Boyd <swboyd@chromium.org>

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

* Re: [PATCH 2/3] platform/chrome: cros_ec_proto: Rename cros_ec_command function
  2022-06-06 20:18 ` [PATCH 2/3] platform/chrome: cros_ec_proto: Rename cros_ec_command function Prashant Malani
@ 2022-06-06 23:32   ` Stephen Boyd
  2022-06-07 14:38   ` Guenter Roeck
  2022-06-08  7:44   ` Lee Jones
  2 siblings, 0 replies; 14+ messages in thread
From: Stephen Boyd @ 2022-06-06 23:32 UTC (permalink / raw)
  To: Prashant Malani, linux-kernel
  Cc: bleung, Brian Norris, chrome-platform, Enric Balletbo i Serra,
	Guenter Roeck, Lee Jones, Liam Girdwood, Mark Brown,
	Tzung-Bi Shih

Quoting Prashant Malani (2022-06-06 13:18:03)
> cros_ec_command() is the name of a function as well as a struct, as such
> it can confuse indexing tools (like ctags). Avoid this by renaming it to
> cros_ec_cmd(). Update all the callsites to use the new name.
>
> This patch is a find-and-replace, so should not introduce any functional
> changes.
>
> Suggested-by: Stephen Boyd <swboyd@chromium.org>
> Signed-off-by: Prashant Malani <pmalani@chromium.org>
> ---

Reviewed-by: Stephen Boyd <swboyd@chromium.org>

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

* Re: [PATCH 3/3] platform/chrome: cros_ec_proto: Update size arg types
  2022-06-06 20:18 ` [PATCH 3/3] platform/chrome: cros_ec_proto: Update size arg types Prashant Malani
@ 2022-06-06 23:34   ` Stephen Boyd
  2022-06-07 14:41   ` Guenter Roeck
  1 sibling, 0 replies; 14+ messages in thread
From: Stephen Boyd @ 2022-06-06 23:34 UTC (permalink / raw)
  To: Prashant Malani, linux-kernel
  Cc: bleung, Guenter Roeck, Enric Balletbo i Serra, Tzung-Bi Shih,
	Brian Norris, chrome-platform

Quoting Prashant Malani (2022-06-06 13:18:05)
> cros_ec_cmd() takes 2 size arguments. Update them to be of the more
> appropriate type size_t.
>
> Suggested-by: Stephen Boyd <swboyd@chromium.org>
> Signed-off-by: Prashant Malani <pmalani@chromium.org>
> ---

Reviewed-by: Stephen Boyd <swboyd@chromium.org>

> diff --git a/include/linux/platform_data/cros_ec_proto.h b/include/linux/platform_data/cros_ec_proto.h
> index 816da4eef3e5..85e29300f63d 100644
> --- a/include/linux/platform_data/cros_ec_proto.h
> +++ b/include/linux/platform_data/cros_ec_proto.h
> @@ -232,7 +232,7 @@ bool cros_ec_check_features(struct cros_ec_dev *ec, int feature);
>  int cros_ec_get_sensor_count(struct cros_ec_dev *ec);
>
>  int cros_ec_cmd(struct cros_ec_device *ec_dev, unsigned int version, int command, void *outdata,
> -                   int outsize, void *indata, int insize);
> +                   size_t outsize, void *indata, size_t insize);

We should also mark 'outdata' as const in another patch because it's
being copied out and I assume unmodified by the callee. It's nice to
tell the caller that their data will be sent unmodified.

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

* Re: [PATCH 1/3] regulator: cros-ec: Use common cros_ec_command()
  2022-06-06 20:18 ` [PATCH 1/3] regulator: cros-ec: Use common cros_ec_command() Prashant Malani
  2022-06-06 23:31   ` Stephen Boyd
@ 2022-06-07 14:37   ` Guenter Roeck
  2022-06-07 15:31   ` Mark Brown
  2 siblings, 0 replies; 14+ messages in thread
From: Guenter Roeck @ 2022-06-07 14:37 UTC (permalink / raw)
  To: Prashant Malani
  Cc: linux-kernel, Benson Leung, Stephen Boyd,
	open list:CHROME HARDWARE PLATFORM SUPPORT, Daisuke Nojiri,
	Enric Balletbo i Serra, Guenter Roeck, Lee Jones, Liam Girdwood,
	Mark Brown, Tzung-Bi Shih

On Mon, Jun 6, 2022 at 1:19 PM Prashant Malani <pmalani@chromium.org> wrote:
>
> Reduce code duplication by using the common cros_ec_command() function
> instead of the locally defined variant.
>
> Cc: Stephen Boyd <swboyd@chromium.org>
> Signed-off-by: Prashant Malani <pmalani@chromium.org>

Reviewed-by: Guenter Roeck <groeck@chromium.org>

> ---
>  drivers/regulator/cros-ec-regulator.c | 54 ++++++---------------------
>  1 file changed, 12 insertions(+), 42 deletions(-)
>
> diff --git a/drivers/regulator/cros-ec-regulator.c b/drivers/regulator/cros-ec-regulator.c
> index c4754f3cf233..1c5fc74a4776 100644
> --- a/drivers/regulator/cros-ec-regulator.c
> +++ b/drivers/regulator/cros-ec-regulator.c
> @@ -22,36 +22,6 @@ struct cros_ec_regulator_data {
>         u16 num_voltages;
>  };
>
> -static int cros_ec_cmd(struct cros_ec_device *ec, u32 version, u32 command,
> -                      void *outdata, u32 outsize, void *indata, u32 insize)
> -{
> -       struct cros_ec_command *msg;
> -       int ret;
> -
> -       msg = kzalloc(sizeof(*msg) + max(outsize, insize), GFP_KERNEL);
> -       if (!msg)
> -               return -ENOMEM;
> -
> -       msg->version = version;
> -       msg->command = command;
> -       msg->outsize = outsize;
> -       msg->insize = insize;
> -
> -       if (outdata && outsize > 0)
> -               memcpy(msg->data, outdata, outsize);
> -
> -       ret = cros_ec_cmd_xfer_status(ec, msg);
> -       if (ret < 0)
> -               goto cleanup;
> -
> -       if (insize)
> -               memcpy(indata, msg->data, insize);
> -
> -cleanup:
> -       kfree(msg);
> -       return ret;
> -}
> -
>  static int cros_ec_regulator_enable(struct regulator_dev *dev)
>  {
>         struct cros_ec_regulator_data *data = rdev_get_drvdata(dev);
> @@ -60,8 +30,8 @@ static int cros_ec_regulator_enable(struct regulator_dev *dev)
>                 .enable = 1,
>         };
>
> -       return cros_ec_cmd(data->ec_dev, 0, EC_CMD_REGULATOR_ENABLE, &cmd,
> -                         sizeof(cmd), NULL, 0);
> +       return cros_ec_command(data->ec_dev, 0, EC_CMD_REGULATOR_ENABLE, &cmd,
> +                              sizeof(cmd), NULL, 0);
>  }
>
>  static int cros_ec_regulator_disable(struct regulator_dev *dev)
> @@ -72,8 +42,8 @@ static int cros_ec_regulator_disable(struct regulator_dev *dev)
>                 .enable = 0,
>         };
>
> -       return cros_ec_cmd(data->ec_dev, 0, EC_CMD_REGULATOR_ENABLE, &cmd,
> -                         sizeof(cmd), NULL, 0);
> +       return cros_ec_command(data->ec_dev, 0, EC_CMD_REGULATOR_ENABLE, &cmd,
> +                              sizeof(cmd), NULL, 0);
>  }
>
>  static int cros_ec_regulator_is_enabled(struct regulator_dev *dev)
> @@ -85,8 +55,8 @@ static int cros_ec_regulator_is_enabled(struct regulator_dev *dev)
>         struct ec_response_regulator_is_enabled resp;
>         int ret;
>
> -       ret = cros_ec_cmd(data->ec_dev, 0, EC_CMD_REGULATOR_IS_ENABLED, &cmd,
> -                         sizeof(cmd), &resp, sizeof(resp));
> +       ret = cros_ec_command(data->ec_dev, 0, EC_CMD_REGULATOR_IS_ENABLED, &cmd,
> +                             sizeof(cmd), &resp, sizeof(resp));
>         if (ret < 0)
>                 return ret;
>         return resp.enabled;
> @@ -112,8 +82,8 @@ static int cros_ec_regulator_get_voltage(struct regulator_dev *dev)
>         struct ec_response_regulator_get_voltage resp;
>         int ret;
>
> -       ret = cros_ec_cmd(data->ec_dev, 0, EC_CMD_REGULATOR_GET_VOLTAGE, &cmd,
> -                         sizeof(cmd), &resp, sizeof(resp));
> +       ret = cros_ec_command(data->ec_dev, 0, EC_CMD_REGULATOR_GET_VOLTAGE, &cmd,
> +                             sizeof(cmd), &resp, sizeof(resp));
>         if (ret < 0)
>                 return ret;
>         return resp.voltage_mv * 1000;
> @@ -138,8 +108,8 @@ static int cros_ec_regulator_set_voltage(struct regulator_dev *dev, int min_uV,
>         if (min_mV > max_mV)
>                 return -EINVAL;
>
> -       return cros_ec_cmd(data->ec_dev, 0, EC_CMD_REGULATOR_SET_VOLTAGE, &cmd,
> -                          sizeof(cmd), NULL, 0);
> +       return cros_ec_command(data->ec_dev, 0, EC_CMD_REGULATOR_SET_VOLTAGE, &cmd,
> +                              sizeof(cmd), NULL, 0);
>  }
>
>  static const struct regulator_ops cros_ec_regulator_voltage_ops = {
> @@ -160,8 +130,8 @@ static int cros_ec_regulator_init_info(struct device *dev,
>         struct ec_response_regulator_get_info resp;
>         int ret;
>
> -       ret = cros_ec_cmd(data->ec_dev, 0, EC_CMD_REGULATOR_GET_INFO, &cmd,
> -                          sizeof(cmd), &resp, sizeof(resp));
> +       ret = cros_ec_command(data->ec_dev, 0, EC_CMD_REGULATOR_GET_INFO, &cmd,
> +                             sizeof(cmd), &resp, sizeof(resp));
>         if (ret < 0)
>                 return ret;
>
> --
> 2.36.1.255.ge46751e96f-goog
>

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

* Re: [PATCH 2/3] platform/chrome: cros_ec_proto: Rename cros_ec_command function
  2022-06-06 20:18 ` [PATCH 2/3] platform/chrome: cros_ec_proto: Rename cros_ec_command function Prashant Malani
  2022-06-06 23:32   ` Stephen Boyd
@ 2022-06-07 14:38   ` Guenter Roeck
  2022-06-08  7:44   ` Lee Jones
  2 siblings, 0 replies; 14+ messages in thread
From: Guenter Roeck @ 2022-06-07 14:38 UTC (permalink / raw)
  To: Prashant Malani
  Cc: linux-kernel, Benson Leung, Stephen Boyd, Brian Norris,
	open list:CHROME HARDWARE PLATFORM SUPPORT,
	Enric Balletbo i Serra, Guenter Roeck, Lee Jones, Liam Girdwood,
	Mark Brown, Tzung-Bi Shih

On Mon, Jun 6, 2022 at 1:19 PM Prashant Malani <pmalani@chromium.org> wrote:
>
> cros_ec_command() is the name of a function as well as a struct, as such
> it can confuse indexing tools (like ctags). Avoid this by renaming it to
> cros_ec_cmd(). Update all the callsites to use the new name.
>
> This patch is a find-and-replace, so should not introduce any functional
> changes.
>
> Suggested-by: Stephen Boyd <swboyd@chromium.org>
> Signed-off-by: Prashant Malani <pmalani@chromium.org>

Reviewed-by: Guenter Roeck <groeck@chromium.org>

> ---
>  drivers/mfd/cros_ec_dev.c                   |  4 +--
>  drivers/platform/chrome/cros_ec_proto.c     | 22 ++++++------
>  drivers/platform/chrome/cros_ec_typec.c     | 39 ++++++++++-----------
>  drivers/platform/chrome/cros_usbpd_notify.c |  4 +--
>  drivers/regulator/cros-ec-regulator.c       | 24 ++++++-------
>  include/linux/platform_data/cros_ec_proto.h |  2 +-
>  6 files changed, 47 insertions(+), 48 deletions(-)
>
> diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c
> index 596731caf407..02d4271dfe06 100644
> --- a/drivers/mfd/cros_ec_dev.c
> +++ b/drivers/mfd/cros_ec_dev.c
> @@ -250,8 +250,8 @@ static int ec_device_probe(struct platform_device *pdev)
>          * The PCHG device cannot be detected by sending EC_FEATURE_GET_CMD, but
>          * it can be detected by querying the number of peripheral chargers.
>          */
> -       retval = cros_ec_command(ec->ec_dev, 0, EC_CMD_PCHG_COUNT, NULL, 0,
> -                                &pchg_count, sizeof(pchg_count));
> +       retval = cros_ec_cmd(ec->ec_dev, 0, EC_CMD_PCHG_COUNT, NULL, 0,
> +                            &pchg_count, sizeof(pchg_count));
>         if (retval >= 0 && pchg_count.port_count) {
>                 retval = mfd_add_hotplug_devices(ec->dev,
>                                         cros_ec_pchg_cells,
> diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/chrome/cros_ec_proto.c
> index 13ced9d2dd71..b6bea183ee28 100644
> --- a/drivers/platform/chrome/cros_ec_proto.c
> +++ b/drivers/platform/chrome/cros_ec_proto.c
> @@ -860,8 +860,8 @@ bool cros_ec_check_features(struct cros_ec_dev *ec, int feature)
>
>         if (features->flags[0] == -1U && features->flags[1] == -1U) {
>                 /* features bitmap not read yet */
> -               ret = cros_ec_command(ec->ec_dev, 0, EC_CMD_GET_FEATURES + ec->cmd_offset,
> -                                     NULL, 0, features, sizeof(*features));
> +               ret = cros_ec_cmd(ec->ec_dev, 0, EC_CMD_GET_FEATURES + ec->cmd_offset,
> +                                 NULL, 0, features, sizeof(*features));
>                 if (ret < 0) {
>                         dev_warn(ec->dev, "cannot get EC features: %d\n", ret);
>                         memset(features, 0, sizeof(*features));
> @@ -942,7 +942,7 @@ int cros_ec_get_sensor_count(struct cros_ec_dev *ec)
>  EXPORT_SYMBOL_GPL(cros_ec_get_sensor_count);
>
>  /**
> - * cros_ec_command - Send a command to the EC.
> + * cros_ec_cmd - Send a command to the EC.
>   *
>   * @ec_dev: EC device
>   * @version: EC command version
> @@ -954,13 +954,13 @@ EXPORT_SYMBOL_GPL(cros_ec_get_sensor_count);
>   *
>   * Return: >= 0 on success, negative error number on failure.
>   */
> -int cros_ec_command(struct cros_ec_device *ec_dev,
> -                   unsigned int version,
> -                   int command,
> -                   void *outdata,
> -                   int outsize,
> -                   void *indata,
> -                   int insize)
> +int cros_ec_cmd(struct cros_ec_device *ec_dev,
> +               unsigned int version,
> +               int command,
> +               void *outdata,
> +               int outsize,
> +               void *indata,
> +               int insize)
>  {
>         struct cros_ec_command *msg;
>         int ret;
> @@ -987,4 +987,4 @@ int cros_ec_command(struct cros_ec_device *ec_dev,
>         kfree(msg);
>         return ret;
>  }
> -EXPORT_SYMBOL_GPL(cros_ec_command);
> +EXPORT_SYMBOL_GPL(cros_ec_cmd);
> diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
> index 7cb2e35c4ded..d6088ba447af 100644
> --- a/drivers/platform/chrome/cros_ec_typec.c
> +++ b/drivers/platform/chrome/cros_ec_typec.c
> @@ -525,8 +525,8 @@ static int cros_typec_configure_mux(struct cros_typec_data *typec, int port_num,
>         enum typec_orientation orientation;
>         int ret;
>
> -       ret = cros_ec_command(typec->ec, 0, EC_CMD_USB_PD_MUX_INFO,
> -                             &req, sizeof(req), &resp, sizeof(resp));
> +       ret = cros_ec_cmd(typec->ec, 0, EC_CMD_USB_PD_MUX_INFO,
> +                         &req, sizeof(req), &resp, sizeof(resp));
>         if (ret < 0) {
>                 dev_warn(typec->dev, "Failed to get mux info for port: %d, err = %d\n",
>                          port_num, ret);
> @@ -585,8 +585,8 @@ static int cros_typec_configure_mux(struct cros_typec_data *typec, int port_num,
>         /* Sending Acknowledgment to EC */
>         mux_ack.port = port_num;
>
> -       if (cros_ec_command(typec->ec, 0, EC_CMD_USB_PD_MUX_ACK, &mux_ack,
> -                           sizeof(mux_ack), NULL, 0) < 0)
> +       if (cros_ec_cmd(typec->ec, 0, EC_CMD_USB_PD_MUX_ACK, &mux_ack,
> +                       sizeof(mux_ack), NULL, 0) < 0)
>                 dev_warn(typec->dev,
>                          "Failed to send Mux ACK to EC for port: %d\n",
>                          port_num);
> @@ -754,8 +754,8 @@ static int cros_typec_handle_sop_prime_disc(struct cros_typec_data *typec, int p
>         int ret = 0;
>
>         memset(disc, 0, EC_PROTO2_MAX_RESPONSE_SIZE);
> -       ret = cros_ec_command(typec->ec, 0, EC_CMD_TYPEC_DISCOVERY, &req, sizeof(req),
> -                             disc, EC_PROTO2_MAX_RESPONSE_SIZE);
> +       ret = cros_ec_cmd(typec->ec, 0, EC_CMD_TYPEC_DISCOVERY, &req, sizeof(req),
> +                         disc, EC_PROTO2_MAX_RESPONSE_SIZE);
>         if (ret < 0) {
>                 dev_err(typec->dev, "Failed to get SOP' discovery data for port: %d\n", port_num);
>                 goto sop_prime_disc_exit;
> @@ -837,8 +837,8 @@ static int cros_typec_handle_sop_disc(struct cros_typec_data *typec, int port_nu
>         typec_partner_set_pd_revision(port->partner, pd_revision);
>
>         memset(sop_disc, 0, EC_PROTO2_MAX_RESPONSE_SIZE);
> -       ret = cros_ec_command(typec->ec, 0, EC_CMD_TYPEC_DISCOVERY, &req, sizeof(req),
> -                             sop_disc, EC_PROTO2_MAX_RESPONSE_SIZE);
> +       ret = cros_ec_cmd(typec->ec, 0, EC_CMD_TYPEC_DISCOVERY, &req, sizeof(req),
> +                         sop_disc, EC_PROTO2_MAX_RESPONSE_SIZE);
>         if (ret < 0) {
>                 dev_err(typec->dev, "Failed to get SOP discovery data for port: %d\n", port_num);
>                 goto disc_exit;
> @@ -870,8 +870,8 @@ static int cros_typec_send_clear_event(struct cros_typec_data *typec, int port_n
>                 .clear_events_mask = events_mask,
>         };
>
> -       return cros_ec_command(typec->ec, 0, EC_CMD_TYPEC_CONTROL, &req,
> -                              sizeof(req), NULL, 0);
> +       return cros_ec_cmd(typec->ec, 0, EC_CMD_TYPEC_CONTROL, &req,
> +                          sizeof(req), NULL, 0);
>  }
>
>  static void cros_typec_handle_status(struct cros_typec_data *typec, int port_num)
> @@ -882,8 +882,8 @@ static void cros_typec_handle_status(struct cros_typec_data *typec, int port_num
>         };
>         int ret;
>
> -       ret = cros_ec_command(typec->ec, 0, EC_CMD_TYPEC_STATUS, &req, sizeof(req),
> -                             &resp, sizeof(resp));
> +       ret = cros_ec_cmd(typec->ec, 0, EC_CMD_TYPEC_STATUS, &req, sizeof(req),
> +                         &resp, sizeof(resp));
>         if (ret < 0) {
>                 dev_warn(typec->dev, "EC_CMD_TYPEC_STATUS failed for port: %d\n", port_num);
>                 return;
> @@ -960,9 +960,9 @@ static int cros_typec_port_update(struct cros_typec_data *typec, int port_num)
>         req.mux = USB_PD_CTRL_MUX_NO_CHANGE;
>         req.swap = USB_PD_CTRL_SWAP_NONE;
>
> -       ret = cros_ec_command(typec->ec, typec->pd_ctrl_ver,
> -                             EC_CMD_USB_PD_CONTROL, &req, sizeof(req),
> -                             &resp, sizeof(resp));
> +       ret = cros_ec_cmd(typec->ec, typec->pd_ctrl_ver,
> +                         EC_CMD_USB_PD_CONTROL, &req, sizeof(req),
> +                         &resp, sizeof(resp));
>         if (ret < 0)
>                 return ret;
>
> @@ -997,9 +997,8 @@ static int cros_typec_get_cmd_version(struct cros_typec_data *typec)
>
>         /* We're interested in the PD control command version. */
>         req_v1.cmd = EC_CMD_USB_PD_CONTROL;
> -       ret = cros_ec_command(typec->ec, 1, EC_CMD_GET_CMD_VERSIONS,
> -                             &req_v1, sizeof(req_v1), &resp,
> -                                   sizeof(resp));
> +       ret = cros_ec_cmd(typec->ec, 1, EC_CMD_GET_CMD_VERSIONS,
> +                         &req_v1, sizeof(req_v1), &resp, sizeof(resp));
>         if (ret < 0)
>                 return ret;
>
> @@ -1090,8 +1089,8 @@ static int cros_typec_probe(struct platform_device *pdev)
>         typec->typec_cmd_supported = cros_ec_check_features(ec_dev, EC_FEATURE_TYPEC_CMD);
>         typec->needs_mux_ack = cros_ec_check_features(ec_dev, EC_FEATURE_TYPEC_MUX_REQUIRE_AP_ACK);
>
> -       ret = cros_ec_command(typec->ec, 0, EC_CMD_USB_PD_PORTS, NULL, 0,
> -                             &resp, sizeof(resp));
> +       ret = cros_ec_cmd(typec->ec, 0, EC_CMD_USB_PD_PORTS, NULL, 0,
> +                         &resp, sizeof(resp));
>         if (ret < 0)
>                 return ret;
>
> diff --git a/drivers/platform/chrome/cros_usbpd_notify.c b/drivers/platform/chrome/cros_usbpd_notify.c
> index 91ce6be91aac..4b5a81c9dc6d 100644
> --- a/drivers/platform/chrome/cros_usbpd_notify.c
> +++ b/drivers/platform/chrome/cros_usbpd_notify.c
> @@ -71,8 +71,8 @@ static void cros_usbpd_get_event_and_notify(struct device  *dev,
>         }
>
>         /* Check for PD host events on EC. */
> -       ret = cros_ec_command(ec_dev, 0, EC_CMD_PD_HOST_EVENT_STATUS,
> -                             NULL, 0, &host_event_status, sizeof(host_event_status));
> +       ret = cros_ec_cmd(ec_dev, 0, EC_CMD_PD_HOST_EVENT_STATUS,
> +                         NULL, 0, &host_event_status, sizeof(host_event_status));
>         if (ret < 0) {
>                 dev_warn(dev, "Can't get host event status (err: %d)\n", ret);
>                 goto send_notify;
> diff --git a/drivers/regulator/cros-ec-regulator.c b/drivers/regulator/cros-ec-regulator.c
> index 1c5fc74a4776..1591636f86c3 100644
> --- a/drivers/regulator/cros-ec-regulator.c
> +++ b/drivers/regulator/cros-ec-regulator.c
> @@ -30,8 +30,8 @@ static int cros_ec_regulator_enable(struct regulator_dev *dev)
>                 .enable = 1,
>         };
>
> -       return cros_ec_command(data->ec_dev, 0, EC_CMD_REGULATOR_ENABLE, &cmd,
> -                              sizeof(cmd), NULL, 0);
> +       return cros_ec_cmd(data->ec_dev, 0, EC_CMD_REGULATOR_ENABLE, &cmd,
> +                          sizeof(cmd), NULL, 0);
>  }
>
>  static int cros_ec_regulator_disable(struct regulator_dev *dev)
> @@ -42,8 +42,8 @@ static int cros_ec_regulator_disable(struct regulator_dev *dev)
>                 .enable = 0,
>         };
>
> -       return cros_ec_command(data->ec_dev, 0, EC_CMD_REGULATOR_ENABLE, &cmd,
> -                              sizeof(cmd), NULL, 0);
> +       return cros_ec_cmd(data->ec_dev, 0, EC_CMD_REGULATOR_ENABLE, &cmd,
> +                          sizeof(cmd), NULL, 0);
>  }
>
>  static int cros_ec_regulator_is_enabled(struct regulator_dev *dev)
> @@ -55,8 +55,8 @@ static int cros_ec_regulator_is_enabled(struct regulator_dev *dev)
>         struct ec_response_regulator_is_enabled resp;
>         int ret;
>
> -       ret = cros_ec_command(data->ec_dev, 0, EC_CMD_REGULATOR_IS_ENABLED, &cmd,
> -                             sizeof(cmd), &resp, sizeof(resp));
> +       ret = cros_ec_cmd(data->ec_dev, 0, EC_CMD_REGULATOR_IS_ENABLED, &cmd,
> +                         sizeof(cmd), &resp, sizeof(resp));
>         if (ret < 0)
>                 return ret;
>         return resp.enabled;
> @@ -82,8 +82,8 @@ static int cros_ec_regulator_get_voltage(struct regulator_dev *dev)
>         struct ec_response_regulator_get_voltage resp;
>         int ret;
>
> -       ret = cros_ec_command(data->ec_dev, 0, EC_CMD_REGULATOR_GET_VOLTAGE, &cmd,
> -                             sizeof(cmd), &resp, sizeof(resp));
> +       ret = cros_ec_cmd(data->ec_dev, 0, EC_CMD_REGULATOR_GET_VOLTAGE, &cmd,
> +                         sizeof(cmd), &resp, sizeof(resp));
>         if (ret < 0)
>                 return ret;
>         return resp.voltage_mv * 1000;
> @@ -108,8 +108,8 @@ static int cros_ec_regulator_set_voltage(struct regulator_dev *dev, int min_uV,
>         if (min_mV > max_mV)
>                 return -EINVAL;
>
> -       return cros_ec_command(data->ec_dev, 0, EC_CMD_REGULATOR_SET_VOLTAGE, &cmd,
> -                              sizeof(cmd), NULL, 0);
> +       return cros_ec_cmd(data->ec_dev, 0, EC_CMD_REGULATOR_SET_VOLTAGE, &cmd,
> +                          sizeof(cmd), NULL, 0);
>  }
>
>  static const struct regulator_ops cros_ec_regulator_voltage_ops = {
> @@ -130,8 +130,8 @@ static int cros_ec_regulator_init_info(struct device *dev,
>         struct ec_response_regulator_get_info resp;
>         int ret;
>
> -       ret = cros_ec_command(data->ec_dev, 0, EC_CMD_REGULATOR_GET_INFO, &cmd,
> -                             sizeof(cmd), &resp, sizeof(resp));
> +       ret = cros_ec_cmd(data->ec_dev, 0, EC_CMD_REGULATOR_GET_INFO, &cmd,
> +                         sizeof(cmd), &resp, sizeof(resp));
>         if (ret < 0)
>                 return ret;
>
> diff --git a/include/linux/platform_data/cros_ec_proto.h b/include/linux/platform_data/cros_ec_proto.h
> index 138fd912c808..816da4eef3e5 100644
> --- a/include/linux/platform_data/cros_ec_proto.h
> +++ b/include/linux/platform_data/cros_ec_proto.h
> @@ -231,7 +231,7 @@ bool cros_ec_check_features(struct cros_ec_dev *ec, int feature);
>
>  int cros_ec_get_sensor_count(struct cros_ec_dev *ec);
>
> -int cros_ec_command(struct cros_ec_device *ec_dev, unsigned int version, int command, void *outdata,
> +int cros_ec_cmd(struct cros_ec_device *ec_dev, unsigned int version, int command, void *outdata,
>                     int outsize, void *indata, int insize);
>
>  /**
> --
> 2.36.1.255.ge46751e96f-goog
>

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

* Re: [PATCH 3/3] platform/chrome: cros_ec_proto: Update size arg types
  2022-06-06 20:18 ` [PATCH 3/3] platform/chrome: cros_ec_proto: Update size arg types Prashant Malani
  2022-06-06 23:34   ` Stephen Boyd
@ 2022-06-07 14:41   ` Guenter Roeck
  1 sibling, 0 replies; 14+ messages in thread
From: Guenter Roeck @ 2022-06-07 14:41 UTC (permalink / raw)
  To: Prashant Malani
  Cc: linux-kernel, Benson Leung, Stephen Boyd, Guenter Roeck,
	Enric Balletbo i Serra, Tzung-Bi Shih, Brian Norris,
	open list:CHROME HARDWARE PLATFORM SUPPORT

On Mon, Jun 6, 2022 at 1:20 PM Prashant Malani <pmalani@chromium.org> wrote:
>
> cros_ec_cmd() takes 2 size arguments. Update them to be of the more
> appropriate type size_t.
>
> Suggested-by: Stephen Boyd <swboyd@chromium.org>
> Signed-off-by: Prashant Malani <pmalani@chromium.org>

Reviewed-by: Guenter Roeck <groeck@chromium.org>

> ---
>  drivers/platform/chrome/cros_ec_proto.c     | 4 ++--
>  include/linux/platform_data/cros_ec_proto.h | 2 +-
>  2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/chrome/cros_ec_proto.c
> index b6bea183ee28..cefabfe45551 100644
> --- a/drivers/platform/chrome/cros_ec_proto.c
> +++ b/drivers/platform/chrome/cros_ec_proto.c
> @@ -958,9 +958,9 @@ int cros_ec_cmd(struct cros_ec_device *ec_dev,
>                 unsigned int version,
>                 int command,
>                 void *outdata,
> -               int outsize,
> +               size_t outsize,
>                 void *indata,
> -               int insize)
> +               size_t insize)
>  {
>         struct cros_ec_command *msg;
>         int ret;
> diff --git a/include/linux/platform_data/cros_ec_proto.h b/include/linux/platform_data/cros_ec_proto.h
> index 816da4eef3e5..85e29300f63d 100644
> --- a/include/linux/platform_data/cros_ec_proto.h
> +++ b/include/linux/platform_data/cros_ec_proto.h
> @@ -232,7 +232,7 @@ bool cros_ec_check_features(struct cros_ec_dev *ec, int feature);
>  int cros_ec_get_sensor_count(struct cros_ec_dev *ec);
>
>  int cros_ec_cmd(struct cros_ec_device *ec_dev, unsigned int version, int command, void *outdata,
> -                   int outsize, void *indata, int insize);
> +                   size_t outsize, void *indata, size_t insize);
>
>  /**
>   * cros_ec_get_time_ns() - Return time in ns.
> --
> 2.36.1.255.ge46751e96f-goog
>

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

* Re: [PATCH 1/3] regulator: cros-ec: Use common cros_ec_command()
  2022-06-06 20:18 ` [PATCH 1/3] regulator: cros-ec: Use common cros_ec_command() Prashant Malani
  2022-06-06 23:31   ` Stephen Boyd
  2022-06-07 14:37   ` Guenter Roeck
@ 2022-06-07 15:31   ` Mark Brown
  2 siblings, 0 replies; 14+ messages in thread
From: Mark Brown @ 2022-06-07 15:31 UTC (permalink / raw)
  To: Prashant Malani
  Cc: linux-kernel, bleung, Stephen Boyd,
	open list:CHROME HARDWARE PLATFORM SUPPORT, Daisuke Nojiri,
	Enric Balletbo i Serra, Guenter Roeck, Lee Jones, Liam Girdwood,
	Tzung-Bi Shih

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

On Mon, Jun 06, 2022 at 08:18:01PM +0000, Prashant Malani wrote:
> Reduce code duplication by using the common cros_ec_command() function
> instead of the locally defined variant.

Acked-by: Mark Brown <broonie@kernel.org>

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

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

* Re: [PATCH 2/3] platform/chrome: cros_ec_proto: Rename cros_ec_command function
  2022-06-06 20:18 ` [PATCH 2/3] platform/chrome: cros_ec_proto: Rename cros_ec_command function Prashant Malani
  2022-06-06 23:32   ` Stephen Boyd
  2022-06-07 14:38   ` Guenter Roeck
@ 2022-06-08  7:44   ` Lee Jones
  2 siblings, 0 replies; 14+ messages in thread
From: Lee Jones @ 2022-06-08  7:44 UTC (permalink / raw)
  To: Prashant Malani
  Cc: linux-kernel, bleung, Stephen Boyd, Brian Norris,
	open list:CHROME HARDWARE PLATFORM SUPPORT,
	Enric Balletbo i Serra, Guenter Roeck, Liam Girdwood, Mark Brown,
	Tzung-Bi Shih

On Mon, 06 Jun 2022, Prashant Malani wrote:

> cros_ec_command() is the name of a function as well as a struct, as such
> it can confuse indexing tools (like ctags). Avoid this by renaming it to
> cros_ec_cmd(). Update all the callsites to use the new name.
> 
> This patch is a find-and-replace, so should not introduce any functional
> changes.
> 
> Suggested-by: Stephen Boyd <swboyd@chromium.org>
> Signed-off-by: Prashant Malani <pmalani@chromium.org>
> ---
>  drivers/mfd/cros_ec_dev.c                   |  4 +--

Acked-by: Lee Jones <lee.jones@linaro.org>

>  drivers/platform/chrome/cros_ec_proto.c     | 22 ++++++------
>  drivers/platform/chrome/cros_ec_typec.c     | 39 ++++++++++-----------
>  drivers/platform/chrome/cros_usbpd_notify.c |  4 +--
>  drivers/regulator/cros-ec-regulator.c       | 24 ++++++-------
>  include/linux/platform_data/cros_ec_proto.h |  2 +-
>  6 files changed, 47 insertions(+), 48 deletions(-)

-- 
Lee Jones [李琼斯]
Principal Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* Re: [PATCH 0/3] platform/chrome: cros_ec_command() improvements
  2022-06-06 20:17 [PATCH 0/3] platform/chrome: cros_ec_command() improvements Prashant Malani
                   ` (2 preceding siblings ...)
  2022-06-06 20:18 ` [PATCH 3/3] platform/chrome: cros_ec_proto: Update size arg types Prashant Malani
@ 2022-06-08  8:20 ` patchwork-bot+chrome-platform
  2022-06-10  2:30 ` patchwork-bot+chrome-platform
  4 siblings, 0 replies; 14+ messages in thread
From: patchwork-bot+chrome-platform @ 2022-06-08  8:20 UTC (permalink / raw)
  To: Prashant Malani
  Cc: linux-kernel, bleung, briannorris, chrome-platform,
	enric.balletbo, groeck, lee.jones, lgirdwood, broonie, tzungbi

Hello:

This series was applied to chrome-platform/linux.git (for-kernelci)
by Tzung-Bi Shih <tzungbi@kernel.org>:

On Mon,  6 Jun 2022 20:17:59 +0000 you wrote:
> This is a short series related to cros_ec_command(). The first patch
> updates a couple of Cros EC regulator callsites to use the common
> cros_ec_command(). The next couple of patches do a rename and argument
> type update.
> 
> Prashant Malani (3):
>   regulator: cros-ec: Use common cros_ec_command()
>   platform/chrome: cros_ec_proto: Rename cros_ec_command function
>   platform/chrome: cros_ec_proto: Update size arg types
> 
> [...]

Here is the summary with links:
  - [1/3] regulator: cros-ec: Use common cros_ec_command()
    https://git.kernel.org/chrome-platform/c/015cd0043503
  - [2/3] platform/chrome: cros_ec_proto: Rename cros_ec_command function
    https://git.kernel.org/chrome-platform/c/b1d288d9c3c5
  - [3/3] platform/chrome: cros_ec_proto: Update size arg types
    https://git.kernel.org/chrome-platform/c/f87e15fbf6d8

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

* Re: [PATCH 0/3] platform/chrome: cros_ec_command() improvements
  2022-06-06 20:17 [PATCH 0/3] platform/chrome: cros_ec_command() improvements Prashant Malani
                   ` (3 preceding siblings ...)
  2022-06-08  8:20 ` [PATCH 0/3] platform/chrome: cros_ec_command() improvements patchwork-bot+chrome-platform
@ 2022-06-10  2:30 ` patchwork-bot+chrome-platform
  4 siblings, 0 replies; 14+ messages in thread
From: patchwork-bot+chrome-platform @ 2022-06-10  2:30 UTC (permalink / raw)
  To: Prashant Malani
  Cc: linux-kernel, bleung, briannorris, chrome-platform,
	enric.balletbo, groeck, lee.jones, lgirdwood, broonie, tzungbi

Hello:

This series was applied to chrome-platform/linux.git (for-next)
by Tzung-Bi Shih <tzungbi@kernel.org>:

On Mon,  6 Jun 2022 20:17:59 +0000 you wrote:
> This is a short series related to cros_ec_command(). The first patch
> updates a couple of Cros EC regulator callsites to use the common
> cros_ec_command(). The next couple of patches do a rename and argument
> type update.
> 
> Prashant Malani (3):
>   regulator: cros-ec: Use common cros_ec_command()
>   platform/chrome: cros_ec_proto: Rename cros_ec_command function
>   platform/chrome: cros_ec_proto: Update size arg types
> 
> [...]

Here is the summary with links:
  - [1/3] regulator: cros-ec: Use common cros_ec_command()
    https://git.kernel.org/chrome-platform/c/015cd0043503
  - [2/3] platform/chrome: cros_ec_proto: Rename cros_ec_command function
    https://git.kernel.org/chrome-platform/c/b1d288d9c3c5
  - [3/3] platform/chrome: cros_ec_proto: Update size arg types
    https://git.kernel.org/chrome-platform/c/f87e15fbf6d8

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2022-06-10  2:30 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-06 20:17 [PATCH 0/3] platform/chrome: cros_ec_command() improvements Prashant Malani
2022-06-06 20:18 ` [PATCH 1/3] regulator: cros-ec: Use common cros_ec_command() Prashant Malani
2022-06-06 23:31   ` Stephen Boyd
2022-06-07 14:37   ` Guenter Roeck
2022-06-07 15:31   ` Mark Brown
2022-06-06 20:18 ` [PATCH 2/3] platform/chrome: cros_ec_proto: Rename cros_ec_command function Prashant Malani
2022-06-06 23:32   ` Stephen Boyd
2022-06-07 14:38   ` Guenter Roeck
2022-06-08  7:44   ` Lee Jones
2022-06-06 20:18 ` [PATCH 3/3] platform/chrome: cros_ec_proto: Update size arg types Prashant Malani
2022-06-06 23:34   ` Stephen Boyd
2022-06-07 14:41   ` Guenter Roeck
2022-06-08  8:20 ` [PATCH 0/3] platform/chrome: cros_ec_command() improvements patchwork-bot+chrome-platform
2022-06-10  2:30 ` patchwork-bot+chrome-platform

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.