linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] platform/chrome: Make cros_ec_pd_command() reusable
@ 2021-09-30  2:23 Prashant Malani
  2021-09-30  2:23 ` [PATCH 1/5] platform/chrome: cros_usbpd_notify: Rename cros_ec_pd_command() Prashant Malani
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Prashant Malani @ 2021-09-30  2:23 UTC (permalink / raw)
  To: linux-kernel
  Cc: Prashant Malani, Benson Leung, Enric Balletbo i Serra,
	Guenter Roeck, Gustavo A. R. Silva

This is a short series to relocate and rename cros_ec_pd_command() to
cros_ec_proto.c. This function is useful for sending host command
messages, so the 1st 4 patches move it a more central location, and
modify the arguments to allow other users to use it.

The final patch updates cros-ec-typec to use the new function and get
rid of its own copy.

Prashant Malani (5):
  platform/chrome: cros_usbpd_notify: Rename cros_ec_pd_command()
  platform/chrome: cros_usbpd_notify: Move ec_command()
  platform/chrome: cros_ec_proto: Make data pointers void
  platform/chrome: cros_ec_proto: Add version for ec_command
  platform/chrome: cros_ec_typec: Use cros_ec_command()

 drivers/platform/chrome/cros_ec_proto.c     | 48 ++++++++++++++
 drivers/platform/chrome/cros_ec_typec.c     | 69 ++++++---------------
 drivers/platform/chrome/cros_usbpd_notify.c | 50 +--------------
 include/linux/platform_data/cros_ec_proto.h |  3 +
 4 files changed, 72 insertions(+), 98 deletions(-)

-- 
2.33.0.685.g46640cef36-goog


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

* [PATCH 1/5] platform/chrome: cros_usbpd_notify: Rename cros_ec_pd_command()
  2021-09-30  2:23 [PATCH 0/5] platform/chrome: Make cros_ec_pd_command() reusable Prashant Malani
@ 2021-09-30  2:23 ` Prashant Malani
  2021-09-30  2:23 ` [PATCH 2/5] platform/chrome: cros_usbpd_notify: Move ec_command() Prashant Malani
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Prashant Malani @ 2021-09-30  2:23 UTC (permalink / raw)
  To: linux-kernel
  Cc: Prashant Malani, Benson Leung, Enric Balletbo i Serra,
	Guenter Roeck, Gustavo A. R. Silva

Rename cros_ec_pd_command()_to cros_ec_command() since it can be used
for sending any host command, and not just PD related ones.

This patch does not introduce any functional changes.

Signed-off-by: Prashant Malani <pmalani@chromium.org>
---
 drivers/platform/chrome/cros_usbpd_notify.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/drivers/platform/chrome/cros_usbpd_notify.c b/drivers/platform/chrome/cros_usbpd_notify.c
index 48a6617aa12f..e718055f4313 100644
--- a/drivers/platform/chrome/cros_usbpd_notify.c
+++ b/drivers/platform/chrome/cros_usbpd_notify.c
@@ -54,7 +54,7 @@ void cros_usbpd_unregister_notify(struct notifier_block *nb)
 EXPORT_SYMBOL_GPL(cros_usbpd_unregister_notify);
 
 /**
- * cros_ec_pd_command - Send a command to the EC.
+ * cros_ec_command - Send a command to the EC.
  *
  * @ec_dev: EC device
  * @command: EC command
@@ -65,12 +65,12 @@ EXPORT_SYMBOL_GPL(cros_usbpd_unregister_notify);
  *
  * Return: >= 0 on success, negative error number on failure.
  */
-static int cros_ec_pd_command(struct cros_ec_device *ec_dev,
-			      int command,
-			      uint8_t *outdata,
-			      int outsize,
-			      uint8_t *indata,
-			      int insize)
+static int cros_ec_command(struct cros_ec_device *ec_dev,
+			   int command,
+			   uint8_t *outdata,
+			   int outsize,
+			   uint8_t *indata,
+			   int insize)
 {
 	struct cros_ec_command *msg;
 	int ret;
@@ -115,10 +115,8 @@ static void cros_usbpd_get_event_and_notify(struct device  *dev,
 	}
 
 	/* Check for PD host events on EC. */
-	ret = cros_ec_pd_command(ec_dev, EC_CMD_PD_HOST_EVENT_STATUS,
-				 NULL, 0,
-				 (uint8_t *)&host_event_status,
-				 sizeof(host_event_status));
+	ret = cros_ec_command(ec_dev, EC_CMD_PD_HOST_EVENT_STATUS,
+			      NULL, 0, (uint8_t *)&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;
-- 
2.33.0.685.g46640cef36-goog


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

* [PATCH 2/5] platform/chrome: cros_usbpd_notify: Move ec_command()
  2021-09-30  2:23 [PATCH 0/5] platform/chrome: Make cros_ec_pd_command() reusable Prashant Malani
  2021-09-30  2:23 ` [PATCH 1/5] platform/chrome: cros_usbpd_notify: Rename cros_ec_pd_command() Prashant Malani
@ 2021-09-30  2:23 ` Prashant Malani
  2021-09-30  2:23 ` [PATCH 3/5] platform/chrome: cros_ec_proto: Make data pointers void Prashant Malani
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Prashant Malani @ 2021-09-30  2:23 UTC (permalink / raw)
  To: linux-kernel
  Cc: Prashant Malani, Benson Leung, Enric Balletbo i Serra,
	Guenter Roeck, Gustavo A. R. Silva

cros_ec_command() can be used by other modules too. So, move it to a
common location and export it.

This patch does not introduce any functional changes.

Signed-off-by: Prashant Malani <pmalani@chromium.org>
---
 drivers/platform/chrome/cros_ec_proto.c     | 45 +++++++++++++++++++++
 drivers/platform/chrome/cros_usbpd_notify.c | 44 --------------------
 include/linux/platform_data/cros_ec_proto.h |  3 ++
 3 files changed, 48 insertions(+), 44 deletions(-)

diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/chrome/cros_ec_proto.c
index a34cf58c5ef7..67009b604630 100644
--- a/drivers/platform/chrome/cros_ec_proto.c
+++ b/drivers/platform/chrome/cros_ec_proto.c
@@ -910,3 +910,48 @@ int cros_ec_get_sensor_count(struct cros_ec_dev *ec)
 	return sensor_count;
 }
 EXPORT_SYMBOL_GPL(cros_ec_get_sensor_count);
+
+/**
+ * cros_ec_command - Send a command to the EC.
+ *
+ * @ec_dev: EC device
+ * @command: EC command
+ * @outdata: EC command output data
+ * @outsize: Size of outdata
+ * @indata: EC command input data
+ * @insize: Size of indata
+ *
+ * Return: >= 0 on success, negative error number on failure.
+ */
+int cros_ec_command(struct cros_ec_device *ec_dev,
+		    int command,
+		    uint8_t *outdata,
+		    int outsize,
+		    uint8_t *indata,
+		    int insize)
+{
+	struct cros_ec_command *msg;
+	int ret;
+
+	msg = kzalloc(sizeof(*msg) + max(insize, outsize), GFP_KERNEL);
+	if (!msg)
+		return -ENOMEM;
+
+	msg->command = command;
+	msg->outsize = outsize;
+	msg->insize = insize;
+
+	if (outsize)
+		memcpy(msg->data, outdata, outsize);
+
+	ret = cros_ec_cmd_xfer_status(ec_dev, msg);
+	if (ret < 0)
+		goto error;
+
+	if (insize)
+		memcpy(indata, msg->data, insize);
+error:
+	kfree(msg);
+	return ret;
+}
+EXPORT_SYMBOL_GPL(cros_ec_command);
diff --git a/drivers/platform/chrome/cros_usbpd_notify.c b/drivers/platform/chrome/cros_usbpd_notify.c
index e718055f4313..39afdad897ce 100644
--- a/drivers/platform/chrome/cros_usbpd_notify.c
+++ b/drivers/platform/chrome/cros_usbpd_notify.c
@@ -53,50 +53,6 @@ void cros_usbpd_unregister_notify(struct notifier_block *nb)
 }
 EXPORT_SYMBOL_GPL(cros_usbpd_unregister_notify);
 
-/**
- * cros_ec_command - Send a command to the EC.
- *
- * @ec_dev: EC device
- * @command: EC command
- * @outdata: EC command output data
- * @outsize: Size of outdata
- * @indata: EC command input data
- * @insize: Size of indata
- *
- * Return: >= 0 on success, negative error number on failure.
- */
-static int cros_ec_command(struct cros_ec_device *ec_dev,
-			   int command,
-			   uint8_t *outdata,
-			   int outsize,
-			   uint8_t *indata,
-			   int insize)
-{
-	struct cros_ec_command *msg;
-	int ret;
-
-	msg = kzalloc(sizeof(*msg) + max(insize, outsize), GFP_KERNEL);
-	if (!msg)
-		return -ENOMEM;
-
-	msg->command = command;
-	msg->outsize = outsize;
-	msg->insize = insize;
-
-	if (outsize)
-		memcpy(msg->data, outdata, outsize);
-
-	ret = cros_ec_cmd_xfer_status(ec_dev, msg);
-	if (ret < 0)
-		goto error;
-
-	if (insize)
-		memcpy(indata, msg->data, insize);
-error:
-	kfree(msg);
-	return ret;
-}
-
 static void cros_usbpd_get_event_and_notify(struct device  *dev,
 					    struct cros_ec_device *ec_dev)
 {
diff --git a/include/linux/platform_data/cros_ec_proto.h b/include/linux/platform_data/cros_ec_proto.h
index 55844ece0b32..20b17c43caeb 100644
--- a/include/linux/platform_data/cros_ec_proto.h
+++ b/include/linux/platform_data/cros_ec_proto.h
@@ -231,6 +231,9 @@ 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, int command, uint8_t *outdata, int outsize,
+		    uint8_t *indata, int insize);
+
 /**
  * cros_ec_get_time_ns() - Return time in ns.
  *
-- 
2.33.0.685.g46640cef36-goog


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

* [PATCH 3/5] platform/chrome: cros_ec_proto: Make data pointers void
  2021-09-30  2:23 [PATCH 0/5] platform/chrome: Make cros_ec_pd_command() reusable Prashant Malani
  2021-09-30  2:23 ` [PATCH 1/5] platform/chrome: cros_usbpd_notify: Rename cros_ec_pd_command() Prashant Malani
  2021-09-30  2:23 ` [PATCH 2/5] platform/chrome: cros_usbpd_notify: Move ec_command() Prashant Malani
@ 2021-09-30  2:23 ` Prashant Malani
  2021-09-30  2:23 ` [PATCH 4/5] platform/chrome: cros_ec_proto: Add version for ec_command Prashant Malani
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Prashant Malani @ 2021-09-30  2:23 UTC (permalink / raw)
  To: linux-kernel
  Cc: Prashant Malani, Benson Leung, Enric Balletbo i Serra,
	Guenter Roeck, Gustavo A. R. Silva

Convert the input and output data pointers for cros_ec_command() to
void pointers so that the callers don't have to cast their custom
structs to uint8_t *.

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

diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/chrome/cros_ec_proto.c
index 67009b604630..fd114b57bca2 100644
--- a/drivers/platform/chrome/cros_ec_proto.c
+++ b/drivers/platform/chrome/cros_ec_proto.c
@@ -925,9 +925,9 @@ EXPORT_SYMBOL_GPL(cros_ec_get_sensor_count);
  */
 int cros_ec_command(struct cros_ec_device *ec_dev,
 		    int command,
-		    uint8_t *outdata,
+		    void *outdata,
 		    int outsize,
-		    uint8_t *indata,
+		    void *indata,
 		    int insize)
 {
 	struct cros_ec_command *msg;
diff --git a/drivers/platform/chrome/cros_usbpd_notify.c b/drivers/platform/chrome/cros_usbpd_notify.c
index 39afdad897ce..860509474f05 100644
--- a/drivers/platform/chrome/cros_usbpd_notify.c
+++ b/drivers/platform/chrome/cros_usbpd_notify.c
@@ -72,7 +72,7 @@ static void cros_usbpd_get_event_and_notify(struct device  *dev,
 
 	/* Check for PD host events on EC. */
 	ret = cros_ec_command(ec_dev, EC_CMD_PD_HOST_EVENT_STATUS,
-			      NULL, 0, (uint8_t *)&host_event_status, sizeof(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/include/linux/platform_data/cros_ec_proto.h b/include/linux/platform_data/cros_ec_proto.h
index 20b17c43caeb..f833473c5f44 100644
--- a/include/linux/platform_data/cros_ec_proto.h
+++ b/include/linux/platform_data/cros_ec_proto.h
@@ -231,8 +231,8 @@ 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, int command, uint8_t *outdata, int outsize,
-		    uint8_t *indata, int insize);
+int cros_ec_command(struct cros_ec_device *ec_dev, int command, void *outdata, int outsize,
+		    void *indata, int insize);
 
 /**
  * cros_ec_get_time_ns() - Return time in ns.
-- 
2.33.0.685.g46640cef36-goog


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

* [PATCH 4/5] platform/chrome: cros_ec_proto: Add version for ec_command
  2021-09-30  2:23 [PATCH 0/5] platform/chrome: Make cros_ec_pd_command() reusable Prashant Malani
                   ` (2 preceding siblings ...)
  2021-09-30  2:23 ` [PATCH 3/5] platform/chrome: cros_ec_proto: Make data pointers void Prashant Malani
@ 2021-09-30  2:23 ` Prashant Malani
  2021-09-30  2:23 ` [PATCH 5/5] platform/chrome: cros_ec_typec: Use cros_ec_command() Prashant Malani
  2021-09-30  7:25 ` [PATCH 0/5] platform/chrome: Make cros_ec_pd_command() reusable Enric Balletbo i Serra
  5 siblings, 0 replies; 7+ messages in thread
From: Prashant Malani @ 2021-09-30  2:23 UTC (permalink / raw)
  To: linux-kernel
  Cc: Prashant Malani, Benson Leung, Enric Balletbo i Serra,
	Guenter Roeck, Gustavo A. R. Silva

Add a version parameter to cros_ec_command() for callers that may want
to specify which version of the host command they would like to use.

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

diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/chrome/cros_ec_proto.c
index fd114b57bca2..a9f1867e5d8f 100644
--- a/drivers/platform/chrome/cros_ec_proto.c
+++ b/drivers/platform/chrome/cros_ec_proto.c
@@ -915,6 +915,7 @@ EXPORT_SYMBOL_GPL(cros_ec_get_sensor_count);
  * cros_ec_command - Send a command to the EC.
  *
  * @ec_dev: EC device
+ * @version: EC command version
  * @command: EC command
  * @outdata: EC command output data
  * @outsize: Size of outdata
@@ -924,6 +925,7 @@ 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,
@@ -937,6 +939,7 @@ int cros_ec_command(struct cros_ec_device *ec_dev,
 	if (!msg)
 		return -ENOMEM;
 
+	msg->version = version;
 	msg->command = command;
 	msg->outsize = outsize;
 	msg->insize = insize;
diff --git a/drivers/platform/chrome/cros_usbpd_notify.c b/drivers/platform/chrome/cros_usbpd_notify.c
index 860509474f05..91ce6be91aac 100644
--- a/drivers/platform/chrome/cros_usbpd_notify.c
+++ b/drivers/platform/chrome/cros_usbpd_notify.c
@@ -71,7 +71,7 @@ static void cros_usbpd_get_event_and_notify(struct device  *dev,
 	}
 
 	/* Check for PD host events on EC. */
-	ret = cros_ec_command(ec_dev, EC_CMD_PD_HOST_EVENT_STATUS,
+	ret = cros_ec_command(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);
diff --git a/include/linux/platform_data/cros_ec_proto.h b/include/linux/platform_data/cros_ec_proto.h
index f833473c5f44..9d370816a419 100644
--- a/include/linux/platform_data/cros_ec_proto.h
+++ b/include/linux/platform_data/cros_ec_proto.h
@@ -231,8 +231,8 @@ 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, int command, void *outdata, int outsize,
-		    void *indata, int insize);
+int cros_ec_command(struct cros_ec_device *ec_dev, unsigned int version, int command, void *outdata,
+		    int outsize, void *indata, int insize);
 
 /**
  * cros_ec_get_time_ns() - Return time in ns.
-- 
2.33.0.685.g46640cef36-goog


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

* [PATCH 5/5] platform/chrome: cros_ec_typec: Use cros_ec_command()
  2021-09-30  2:23 [PATCH 0/5] platform/chrome: Make cros_ec_pd_command() reusable Prashant Malani
                   ` (3 preceding siblings ...)
  2021-09-30  2:23 ` [PATCH 4/5] platform/chrome: cros_ec_proto: Add version for ec_command Prashant Malani
@ 2021-09-30  2:23 ` Prashant Malani
  2021-09-30  7:25 ` [PATCH 0/5] platform/chrome: Make cros_ec_pd_command() reusable Enric Balletbo i Serra
  5 siblings, 0 replies; 7+ messages in thread
From: Prashant Malani @ 2021-09-30  2:23 UTC (permalink / raw)
  To: linux-kernel
  Cc: Prashant Malani, Benson Leung, Enric Balletbo i Serra, Guenter Roeck

Re-use the existing cros_ec_command() instead of relying on a duplicate
version.

Signed-off-by: Prashant Malani <pmalani@chromium.org>
---
 drivers/platform/chrome/cros_ec_typec.c | 69 +++++++------------------
 1 file changed, 19 insertions(+), 50 deletions(-)

diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
index 7b3afb6cda5d..5de0bfb0bc4d 100644
--- a/drivers/platform/chrome/cros_ec_typec.c
+++ b/drivers/platform/chrome/cros_ec_typec.c
@@ -379,37 +379,6 @@ static int cros_typec_init_ports(struct cros_typec_data *typec)
 	return ret;
 }
 
-static int cros_typec_ec_command(struct cros_typec_data *typec,
-				 unsigned int version,
-				 unsigned int command,
-				 void *outdata,
-				 unsigned int outsize,
-				 void *indata,
-				 unsigned int 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 (outsize)
-		memcpy(msg->data, outdata, outsize);
-
-	ret = cros_ec_cmd_xfer_status(typec->ec, msg);
-	if (ret >= 0 && insize)
-		memcpy(indata, msg->data, insize);
-
-	kfree(msg);
-	return ret;
-}
-
 static int cros_typec_usb_safe_state(struct cros_typec_port *port)
 {
 	port->state.mode = TYPEC_STATE_SAFE;
@@ -596,8 +565,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_typec_ec_command(typec, 0, EC_CMD_USB_PD_MUX_ACK, &mux_ack,
-				  sizeof(mux_ack), NULL, 0) < 0)
+	if (cros_ec_command(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);
@@ -668,8 +637,8 @@ static int cros_typec_get_mux_info(struct cros_typec_data *typec, int port_num,
 		.port = port_num,
 	};
 
-	return cros_typec_ec_command(typec, 0, EC_CMD_USB_PD_MUX_INFO, &req,
-				     sizeof(req), resp, sizeof(*resp));
+	return cros_ec_command(typec->ec, 0, EC_CMD_USB_PD_MUX_INFO, &req,
+			       sizeof(req), resp, sizeof(*resp));
 }
 
 /*
@@ -776,8 +745,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_typec_ec_command(typec, 0, EC_CMD_TYPEC_DISCOVERY, &req, sizeof(req),
-				    disc, 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);
 	if (ret < 0) {
 		dev_err(typec->dev, "Failed to get SOP' discovery data for port: %d\n", port_num);
 		goto sop_prime_disc_exit;
@@ -859,8 +828,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_typec_ec_command(typec, 0, EC_CMD_TYPEC_DISCOVERY, &req, sizeof(req),
-				    sop_disc, 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);
 	if (ret < 0) {
 		dev_err(typec->dev, "Failed to get SOP discovery data for port: %d\n", port_num);
 		goto disc_exit;
@@ -892,8 +861,8 @@ static int cros_typec_send_clear_event(struct cros_typec_data *typec, int port_n
 		.clear_events_mask = events_mask,
 	};
 
-	return cros_typec_ec_command(typec, 0, EC_CMD_TYPEC_CONTROL, &req,
-				     sizeof(req), NULL, 0);
+	return cros_ec_command(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)
@@ -904,8 +873,8 @@ static void cros_typec_handle_status(struct cros_typec_data *typec, int port_num
 	};
 	int ret;
 
-	ret = cros_typec_ec_command(typec, 0, EC_CMD_TYPEC_STATUS, &req, sizeof(req),
-				    &resp, sizeof(resp));
+	ret = cros_ec_command(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;
@@ -983,9 +952,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_typec_ec_command(typec, typec->pd_ctrl_ver,
-				    EC_CMD_USB_PD_CONTROL, &req, sizeof(req),
-				    &resp, sizeof(resp));
+	ret = cros_ec_command(typec->ec, typec->pd_ctrl_ver,
+			      EC_CMD_USB_PD_CONTROL, &req, sizeof(req),
+			      &resp, sizeof(resp));
 	if (ret < 0)
 		return ret;
 
@@ -1035,8 +1004,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_typec_ec_command(typec, 1, EC_CMD_GET_CMD_VERSIONS,
-				    &req_v1, sizeof(req_v1), &resp,
+	ret = cros_ec_command(typec->ec, 1, EC_CMD_GET_CMD_VERSIONS,
+			      &req_v1, sizeof(req_v1), &resp,
 				    sizeof(resp));
 	if (ret < 0)
 		return ret;
@@ -1119,8 +1088,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_typec_ec_command(typec, 0, EC_CMD_USB_PD_PORTS, NULL, 0,
-				    &resp, sizeof(resp));
+	ret = cros_ec_command(typec->ec, 0, EC_CMD_USB_PD_PORTS, NULL, 0,
+			      &resp, sizeof(resp));
 	if (ret < 0)
 		return ret;
 
-- 
2.33.0.685.g46640cef36-goog


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

* Re: [PATCH 0/5] platform/chrome: Make cros_ec_pd_command() reusable
  2021-09-30  2:23 [PATCH 0/5] platform/chrome: Make cros_ec_pd_command() reusable Prashant Malani
                   ` (4 preceding siblings ...)
  2021-09-30  2:23 ` [PATCH 5/5] platform/chrome: cros_ec_typec: Use cros_ec_command() Prashant Malani
@ 2021-09-30  7:25 ` Enric Balletbo i Serra
  5 siblings, 0 replies; 7+ messages in thread
From: Enric Balletbo i Serra @ 2021-09-30  7:25 UTC (permalink / raw)
  To: Prashant Malani, linux-kernel
  Cc: Benson Leung, Guenter Roeck, Gustavo A. R. Silva

Hi Prashant,


On 30/9/21 4:23, Prashant Malani wrote:
> This is a short series to relocate and rename cros_ec_pd_command() to
> cros_ec_proto.c. This function is useful for sending host command
> messages, so the 1st 4 patches move it a more central location, and
> modify the arguments to allow other users to use it.
> 

Nice patchset! let's hope we can remove at some point all the custom
implementations in the different cros_ec drivers of the cros_ec_command
function. Give some days to run some tests.

Thanks,
  Enric

> The final patch updates cros-ec-typec to use the new function and get
> rid of its own copy.
> 
> Prashant Malani (5):
>   platform/chrome: cros_usbpd_notify: Rename cros_ec_pd_command()
>   platform/chrome: cros_usbpd_notify: Move ec_command()
>   platform/chrome: cros_ec_proto: Make data pointers void
>   platform/chrome: cros_ec_proto: Add version for ec_command
>   platform/chrome: cros_ec_typec: Use cros_ec_command()
> 
>  drivers/platform/chrome/cros_ec_proto.c     | 48 ++++++++++++++
>  drivers/platform/chrome/cros_ec_typec.c     | 69 ++++++---------------
>  drivers/platform/chrome/cros_usbpd_notify.c | 50 +--------------
>  include/linux/platform_data/cros_ec_proto.h |  3 +
>  4 files changed, 72 insertions(+), 98 deletions(-)
> 

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

end of thread, other threads:[~2021-09-30  7:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-30  2:23 [PATCH 0/5] platform/chrome: Make cros_ec_pd_command() reusable Prashant Malani
2021-09-30  2:23 ` [PATCH 1/5] platform/chrome: cros_usbpd_notify: Rename cros_ec_pd_command() Prashant Malani
2021-09-30  2:23 ` [PATCH 2/5] platform/chrome: cros_usbpd_notify: Move ec_command() Prashant Malani
2021-09-30  2:23 ` [PATCH 3/5] platform/chrome: cros_ec_proto: Make data pointers void Prashant Malani
2021-09-30  2:23 ` [PATCH 4/5] platform/chrome: cros_ec_proto: Add version for ec_command Prashant Malani
2021-09-30  2:23 ` [PATCH 5/5] platform/chrome: cros_ec_typec: Use cros_ec_command() Prashant Malani
2021-09-30  7:25 ` [PATCH 0/5] platform/chrome: Make cros_ec_pd_command() reusable Enric Balletbo i Serra

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