Skip to content

Commit 810be30

Browse files
author
Tzung-Bi Shih
committed
platform/chrome: cros_ec_proto: separate cros_ec_xfer_command()
cros_ec_send_command() has extra logic to handle EC_RES_IN_PROGRESS. Separate the command transfer part into cros_ec_xfer_command() so that other functions can re-use it. Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220718050914.2267370-6-tzungbi@kernel.org
1 parent da95f69 commit 810be30

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

drivers/platform/chrome/cros_ec_proto.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ static int prepare_tx_legacy(struct cros_ec_device *ec_dev,
107107
return EC_MSG_TX_PROTO_BYTES + msg->outsize;
108108
}
109109

110-
static int cros_ec_send_command(struct cros_ec_device *ec_dev, struct cros_ec_command *msg)
110+
static int cros_ec_xfer_command(struct cros_ec_device *ec_dev, struct cros_ec_command *msg)
111111
{
112112
int ret;
113113
int (*xfer_fxn)(struct cros_ec_device *ec, struct cros_ec_command *msg);
@@ -123,14 +123,21 @@ static int cros_ec_send_command(struct cros_ec_device *ec_dev, struct cros_ec_co
123123
* the EC is trying to use protocol v2, on an underlying
124124
* communication mechanism that does not support v2.
125125
*/
126-
dev_err_once(ec_dev->dev,
127-
"missing EC transfer API, cannot send command\n");
126+
dev_err_once(ec_dev->dev, "missing EC transfer API, cannot send command\n");
128127
return -EIO;
129128
}
130129

131130
trace_cros_ec_request_start(msg);
132131
ret = (*xfer_fxn)(ec_dev, msg);
133132
trace_cros_ec_request_done(msg, ret);
133+
134+
return ret;
135+
}
136+
137+
static int cros_ec_send_command(struct cros_ec_device *ec_dev, struct cros_ec_command *msg)
138+
{
139+
int ret = cros_ec_xfer_command(ec_dev, msg);
140+
134141
if (msg->result == EC_RES_IN_PROGRESS) {
135142
int i;
136143
struct cros_ec_command *status_msg;

0 commit comments

Comments
 (0)