Replace send_ec_host_command() with cros_ec_send_cmd_msg() which does the same thing, but is defined in a common location in platform/chrome and exposed for other modules to use. This allows us to remove send_ec_host_command() entirely. Signed-off-by: Prashant Malani <pmalani@xxxxxxxxxxxx> --- sound/soc/codecs/cros_ec_codec.c | 71 ++++++++++---------------------- 1 file changed, 21 insertions(+), 50 deletions(-) diff --git a/sound/soc/codecs/cros_ec_codec.c b/sound/soc/codecs/cros_ec_codec.c index 6a24f570c5e86f..49adb07d766963 100644 --- a/sound/soc/codecs/cros_ec_codec.c +++ b/sound/soc/codecs/cros_ec_codec.c @@ -69,38 +69,6 @@ static int ec_codec_capable(struct cros_ec_codec_priv *priv, uint8_t cap) return priv->ec_capabilities & BIT(cap); } -static int send_ec_host_command(struct cros_ec_device *ec_dev, uint32_t cmd, - uint8_t *out, size_t outsize, - uint8_t *in, size_t insize) -{ - int ret; - struct cros_ec_command *msg; - - msg = kmalloc(sizeof(*msg) + max(outsize, insize), GFP_KERNEL); - if (!msg) - return -ENOMEM; - - msg->version = 0; - msg->command = cmd; - msg->outsize = outsize; - msg->insize = insize; - - if (outsize) - memcpy(msg->data, out, outsize); - - ret = cros_ec_cmd_xfer_status(ec_dev, msg); - if (ret < 0) - goto error; - - if (insize) - memcpy(in, msg->data, insize); - - ret = 0; -error: - kfree(msg); - return ret; -} - static int calculate_sha256(struct cros_ec_codec_priv *priv, uint8_t *buf, uint32_t size, uint8_t *digest) { @@ -149,7 +117,7 @@ static int dmic_get_gain(struct snd_kcontrol *kcontrol, p.cmd = EC_CODEC_DMIC_GET_GAIN_IDX; p.get_gain_idx_param.channel = EC_CODEC_DMIC_CHANNEL_0; - ret = send_ec_host_command(priv->ec_device, EC_CMD_EC_CODEC_DMIC, + ret = cros_ec_send_cmd_msg(priv->ec_device, 0, EC_CMD_EC_CODEC_DMIC, (uint8_t *)&p, sizeof(p), (uint8_t *)&r, sizeof(r)); if (ret < 0) @@ -158,7 +126,7 @@ static int dmic_get_gain(struct snd_kcontrol *kcontrol, p.cmd = EC_CODEC_DMIC_GET_GAIN_IDX; p.get_gain_idx_param.channel = EC_CODEC_DMIC_CHANNEL_1; - ret = send_ec_host_command(priv->ec_device, EC_CMD_EC_CODEC_DMIC, + ret = cros_ec_send_cmd_msg(priv->ec_device, 0, EC_CMD_EC_CODEC_DMIC, (uint8_t *)&p, sizeof(p), (uint8_t *)&r, sizeof(r)); if (ret < 0) @@ -191,7 +159,7 @@ static int dmic_put_gain(struct snd_kcontrol *kcontrol, p.cmd = EC_CODEC_DMIC_SET_GAIN_IDX; p.set_gain_idx_param.channel = EC_CODEC_DMIC_CHANNEL_0; p.set_gain_idx_param.gain = left; - ret = send_ec_host_command(priv->ec_device, EC_CMD_EC_CODEC_DMIC, + ret = cros_ec_send_cmd_msg(priv->ec_device, 0, EC_CMD_EC_CODEC_DMIC, (uint8_t *)&p, sizeof(p), NULL, 0); if (ret < 0) return ret; @@ -199,7 +167,7 @@ static int dmic_put_gain(struct snd_kcontrol *kcontrol, p.cmd = EC_CODEC_DMIC_SET_GAIN_IDX; p.set_gain_idx_param.channel = EC_CODEC_DMIC_CHANNEL_1; p.set_gain_idx_param.gain = right; - return send_ec_host_command(priv->ec_device, EC_CMD_EC_CODEC_DMIC, + return cros_ec_send_cmd_msg(priv->ec_device, 0, EC_CMD_EC_CODEC_DMIC, (uint8_t *)&p, sizeof(p), NULL, 0); } @@ -231,7 +199,7 @@ static int dmic_probe(struct snd_soc_component *component) p.cmd = EC_CODEC_DMIC_GET_MAX_GAIN; - ret = send_ec_host_command(priv->ec_device, EC_CMD_EC_CODEC_DMIC, + ret = cros_ec_send_cmd_msg(priv->ec_device, 0, EC_CMD_EC_CODEC_DMIC, (uint8_t *)&p, sizeof(p), (uint8_t *)&r, sizeof(r)); if (ret < 0) { @@ -279,7 +247,7 @@ static int i2s_rx_hw_params(struct snd_pcm_substream *substream, p.cmd = EC_CODEC_I2S_RX_SET_SAMPLE_DEPTH; p.set_sample_depth_param.depth = depth; - ret = send_ec_host_command(priv->ec_device, EC_CMD_EC_CODEC_I2S_RX, + ret = cros_ec_send_cmd_msg(priv->ec_device, 0, EC_CMD_EC_CODEC_I2S_RX, (uint8_t *)&p, sizeof(p), NULL, 0); if (ret < 0) return ret; @@ -289,7 +257,7 @@ static int i2s_rx_hw_params(struct snd_pcm_substream *substream, p.cmd = EC_CODEC_I2S_RX_SET_BCLK; p.set_bclk_param.bclk = snd_soc_params_to_bclk(params); - return send_ec_host_command(priv->ec_device, EC_CMD_EC_CODEC_I2S_RX, + return cros_ec_send_cmd_msg(priv->ec_device, 0, EC_CMD_EC_CODEC_I2S_RX, (uint8_t *)&p, sizeof(p), NULL, 0); } @@ -333,7 +301,7 @@ static int i2s_rx_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) p.cmd = EC_CODEC_I2S_RX_SET_DAIFMT; p.set_daifmt_param.daifmt = daifmt; - return send_ec_host_command(priv->ec_device, EC_CMD_EC_CODEC_I2S_RX, + return cros_ec_send_cmd_msg(priv->ec_device, 0, EC_CMD_EC_CODEC_I2S_RX, (uint8_t *)&p, sizeof(p), NULL, 0); } @@ -364,7 +332,7 @@ static int i2s_rx_event(struct snd_soc_dapm_widget *w, return 0; } - return send_ec_host_command(priv->ec_device, EC_CMD_EC_CODEC_I2S_RX, + return cros_ec_send_cmd_msg(priv->ec_device, 0, EC_CMD_EC_CODEC_I2S_RX, (uint8_t *)&p, sizeof(p), NULL, 0); } @@ -415,7 +383,7 @@ static void *wov_map_shm(struct cros_ec_codec_priv *priv, p.cmd = EC_CODEC_GET_SHM_ADDR; p.get_shm_addr_param.shm_id = shm_id; - if (send_ec_host_command(priv->ec_device, EC_CMD_EC_CODEC, + if (cros_ec_send_cmd_msg(priv->ec_device, 0, EC_CMD_EC_CODEC, (uint8_t *)&p, sizeof(p), (uint8_t *)&r, sizeof(r)) < 0) { dev_err(priv->dev, "failed to EC_CODEC_GET_SHM_ADDR\n"); @@ -453,7 +421,7 @@ static void *wov_map_shm(struct cros_ec_codec_priv *priv, p.set_shm_addr_param.phys_addr = priv->ap_shm_last_alloc; p.set_shm_addr_param.len = req; p.set_shm_addr_param.shm_id = shm_id; - if (send_ec_host_command(priv->ec_device, EC_CMD_EC_CODEC, + if (cros_ec_send_cmd_msg(priv->ec_device, 0, EC_CMD_EC_CODEC, (uint8_t *)&p, sizeof(p), NULL, 0) < 0) { dev_err(priv->dev, "failed to EC_CODEC_SET_SHM_ADDR\n"); @@ -571,7 +539,7 @@ static int wov_read_audio_shm(struct cros_ec_codec_priv *priv) int ret; p.cmd = EC_CODEC_WOV_READ_AUDIO_SHM; - ret = send_ec_host_command(priv->ec_device, EC_CMD_EC_CODEC_WOV, + ret = cros_ec_send_cmd_msg(priv->ec_device, 0, EC_CMD_EC_CODEC_WOV, (uint8_t *)&p, sizeof(p), (uint8_t *)&r, sizeof(r)); if (ret) { @@ -596,7 +564,8 @@ static int wov_read_audio(struct cros_ec_codec_priv *priv) while (remain >= 0) { p.cmd = EC_CODEC_WOV_READ_AUDIO; - ret = send_ec_host_command(priv->ec_device, EC_CMD_EC_CODEC_WOV, + ret = cros_ec_send_cmd_msg(priv->ec_device, 0, + EC_CMD_EC_CODEC_WOV, (uint8_t *)&p, sizeof(p), (uint8_t *)&r, sizeof(r)); if (ret) { @@ -669,7 +638,8 @@ static int wov_enable_put(struct snd_kcontrol *kcontrol, else p.cmd = EC_CODEC_WOV_DISABLE; - ret = send_ec_host_command(priv->ec_device, EC_CMD_EC_CODEC_WOV, + ret = cros_ec_send_cmd_msg(priv->ec_device, 0, + EC_CMD_EC_CODEC_WOV, (uint8_t *)&p, sizeof(p), NULL, 0); if (ret) { dev_err(priv->dev, "failed to %s wov\n", @@ -716,7 +686,7 @@ static int wov_set_lang_shm(struct cros_ec_codec_priv *priv, p.cmd = EC_CODEC_WOV_SET_LANG_SHM; memcpy(pp->hash, digest, SHA256_DIGEST_SIZE); pp->total_len = size; - ret = send_ec_host_command(priv->ec_device, EC_CMD_EC_CODEC_WOV, + ret = cros_ec_send_cmd_msg(priv->ec_device, 0, EC_CMD_EC_CODEC_WOV, (uint8_t *)&p, sizeof(p), NULL, 0); if (ret) { dev_err(priv->dev, "failed to EC_CODEC_WOV_SET_LANG_SHM\n"); @@ -743,7 +713,8 @@ static int wov_set_lang(struct cros_ec_codec_priv *priv, pp->offset = i; memcpy(pp->buf, buf + i, req); pp->len = req; - ret = send_ec_host_command(priv->ec_device, EC_CMD_EC_CODEC_WOV, + ret = cros_ec_send_cmd_msg(priv->ec_device, 0, + EC_CMD_EC_CODEC_WOV, (uint8_t *)&p, sizeof(p), NULL, 0); if (ret) { dev_err(priv->dev, "failed to EC_CODEC_WOV_SET_LANG\n"); @@ -782,7 +753,7 @@ static int wov_hotword_model_put(struct snd_kcontrol *kcontrol, goto leave; p.cmd = EC_CODEC_WOV_GET_LANG; - ret = send_ec_host_command(priv->ec_device, EC_CMD_EC_CODEC_WOV, + ret = cros_ec_send_cmd_msg(priv->ec_device, 0, EC_CMD_EC_CODEC_WOV, (uint8_t *)&p, sizeof(p), (uint8_t *)&r, sizeof(r)); if (ret) @@ -1020,7 +991,7 @@ static int cros_ec_codec_platform_probe(struct platform_device *pdev) atomic_set(&priv->dmic_probed, 0); p.cmd = EC_CODEC_GET_CAPABILITIES; - ret = send_ec_host_command(priv->ec_device, EC_CMD_EC_CODEC, + ret = cros_ec_send_cmd_msg(priv->ec_device, 0, EC_CMD_EC_CODEC, (uint8_t *)&p, sizeof(p), (uint8_t *)&r, sizeof(r)); if (ret) { -- 2.25.0.341.g760bfbb309-goog _______________________________________________ Alsa-devel mailing list Alsa-devel@xxxxxxxxxxxxxxxx https://mailman.alsa-project.org/mailman/listinfo/alsa-devel