Skip to content

Commit 71d3ae7

Browse files
author
Tzung-Bi Shih
committed
platform/chrome: correct cros_ec_prepare_tx() usage
cros_ec_prepare_tx() returns either: - >= 0 for number of prepared bytes. - < 0 for -errno. Correct the comment and make sure all callers check the return code. Reviewed-by: Guenter Roeck <[email protected]> Signed-off-by: Tzung-Bi Shih <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 42701e7 commit 71d3ae7

File tree

6 files changed

+14
-2
lines changed

6 files changed

+14
-2
lines changed

drivers/platform/chrome/cros_ec_i2c.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ static int cros_ec_pkt_xfer_i2c(struct cros_ec_device *ec_dev,
8989

9090
ec_dev->dout++;
9191
ret = cros_ec_prepare_tx(ec_dev, msg);
92+
if (ret < 0)
93+
goto done;
9294
ec_dev->dout--;
9395

9496
/* send command to EC and read answer */

drivers/platform/chrome/cros_ec_ishtp.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,9 @@ static int cros_ec_pkt_xfer_ish(struct cros_ec_device *ec_dev,
521521
out_msg->hdr.status = 0;
522522

523523
ec_dev->dout += OUT_MSG_EC_REQUEST_PREAMBLE;
524-
cros_ec_prepare_tx(ec_dev, msg);
524+
rv = cros_ec_prepare_tx(ec_dev, msg);
525+
if (rv < 0)
526+
goto end_error;
525527
ec_dev->dout -= OUT_MSG_EC_REQUEST_PREAMBLE;
526528

527529
dev_dbg(dev,

drivers/platform/chrome/cros_ec_lpc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ static int cros_ec_pkt_xfer_lpc(struct cros_ec_device *ec,
147147
u8 *dout;
148148

149149
ret = cros_ec_prepare_tx(ec, msg);
150+
if (ret < 0)
151+
goto done;
150152

151153
/* Write buffer */
152154
cros_ec_lpc_ops.write(EC_LPC_ADDR_HOST_PACKET, ret, ec->dout);

drivers/platform/chrome/cros_ec_proto.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ static int send_command(struct cros_ec_device *ec_dev,
164164
* only SPI uses it. Once LPC uses the same protocol it can start using it.
165165
* I2C could use it now, with a refactor of the existing code.
166166
*
167-
* Return: 0 on success or negative error code.
167+
* Return: number of prepared bytes on success or negative error code.
168168
*/
169169
int cros_ec_prepare_tx(struct cros_ec_device *ec_dev,
170170
struct cros_ec_command *msg)

drivers/platform/chrome/cros_ec_rpmsg.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ static int cros_ec_pkt_xfer_rpmsg(struct cros_ec_device *ec_dev,
8989

9090
ec_msg->result = 0;
9191
len = cros_ec_prepare_tx(ec_dev, ec_msg);
92+
if (len < 0)
93+
return len;
9294
dev_dbg(ec_dev->dev, "prepared, len=%d\n", len);
9395

9496
reinit_completion(&ec_rpmsg->xfer_ack);

drivers/platform/chrome/cros_ec_spi.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,8 @@ static int do_cros_ec_pkt_xfer_spi(struct cros_ec_device *ec_dev,
401401
unsigned long delay;
402402

403403
len = cros_ec_prepare_tx(ec_dev, ec_msg);
404+
if (len < 0)
405+
return len;
404406
dev_dbg(ec_dev->dev, "prepared, len=%d\n", len);
405407

406408
/* If it's too soon to do another transaction, wait */
@@ -544,6 +546,8 @@ static int do_cros_ec_cmd_xfer_spi(struct cros_ec_device *ec_dev,
544546
unsigned long delay;
545547

546548
len = cros_ec_prepare_tx(ec_dev, ec_msg);
549+
if (len < 0)
550+
return len;
547551
dev_dbg(ec_dev->dev, "prepared, len=%d\n", len);
548552

549553
/* If it's too soon to do another transaction, wait */

0 commit comments

Comments
 (0)