static int send_command_proto3(struct cros_ec_dev *dev, int cmd, int cmd_version, const void *dout, int dout_len, uint8_t **dinp, int din_len) { struct dm_cros_ec_ops *ops; int out_bytes, in_bytes; int rv; /* Create request packet */ out_bytes = create_proto3_request(dev, cmd, cmd_version, dout, dout_len); if (out_bytes < 0) return out_bytes; /* Prepare response buffer */ in_bytes = prepare_proto3_response_buffer(dev, din_len); if (in_bytes < 0) return in_bytes; ops = dm_cros_ec_get_ops(dev->dev); rv = ops->packet ? ops->packet(dev->dev, out_bytes, in_bytes) : -ENOSYS; if (rv < 0) return rv; /* Process the response */ return handle_proto3_response(dev, dinp, din_len); }
static int send_command_proto3(struct chromeec_command *cec_command, crosec_io_t crosec_io, void *context) { int out_bytes, in_bytes; int rv; struct ec_command_v3 *cmd; struct ec_response_v3 *resp; if ((cmd = crosec_get_buffer(sizeof(*cmd), 1)) == NULL) return -EC_RES_ERROR; if ((resp = crosec_get_buffer(sizeof(*resp), 0)) == NULL) return -EC_RES_ERROR; /* Create request packet */ out_bytes = create_proto3_request(cec_command, cmd); if (out_bytes < 0) { return out_bytes; } /* Prepare response buffer */ in_bytes = prepare_proto3_response_buffer(cec_command, resp); if (in_bytes < 0) { return in_bytes; } rv = crosec_io(out_bytes, in_bytes, context); if (rv != 0) { printk(BIOS_ERR, "%s: failed to complete I/O: Err = %#x.\n", __func__, rv >= 0 ? rv : -rv); return -EC_RES_ERROR; } /* Process the response */ return handle_proto3_response(resp, cec_command); }
static int send_command_proto3(struct cros_ec_dev *dev, int cmd, int cmd_version, const void *dout, int dout_len, uint8_t **dinp, int din_len) { int out_bytes, in_bytes; int rv; /* Create request packet */ out_bytes = create_proto3_request(dev, cmd, cmd_version, dout, dout_len); if (out_bytes < 0) return out_bytes; /* Prepare response buffer */ in_bytes = prepare_proto3_response_buffer(dev, din_len); if (in_bytes < 0) return in_bytes; switch (dev->interface) { #ifdef CONFIG_CROS_EC_SPI case CROS_EC_IF_SPI: rv = cros_ec_spi_packet(dev, out_bytes, in_bytes); break; #endif #ifdef CONFIG_CROS_EC_SANDBOX case CROS_EC_IF_SANDBOX: rv = cros_ec_sandbox_packet(dev, out_bytes, in_bytes); break; #endif case CROS_EC_IF_NONE: /* TODO: support protocol 3 for LPC, I2C; for now fall through */ default: debug("%s: Unsupported interface\n", __func__); rv = -1; } if (rv < 0) return rv; /* Process the response */ return handle_proto3_response(dev, dinp, din_len); }