mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-11-01 17:08:10 +00:00
ASoC: SOF: imx: Use the generic helper to get the reply
Make use of the generic snd_sof_ipc_process_reply() from the core instead the local implementation. snd_sof_ipc_process_reply() handles the reply retrieving and the ipc reply Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com> Reviewed-by: Rander Wang <rander.wang@intel.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com> Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com> Link: https://lore.kernel.org/r/20211116152137.52129-3-daniel.baluta@oss.nxp.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
8ae77801c8
commit
18c45f2703
2 changed files with 2 additions and 72 deletions
|
@ -59,40 +59,6 @@ struct imx8_priv {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static void imx8_get_reply(struct snd_sof_dev *sdev)
|
|
||||||
{
|
|
||||||
struct snd_sof_ipc_msg *msg = sdev->msg;
|
|
||||||
struct sof_ipc_reply reply;
|
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
if (!msg) {
|
|
||||||
dev_warn(sdev->dev, "unexpected ipc interrupt\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* get reply */
|
|
||||||
sof_mailbox_read(sdev, sdev->host_box.offset, &reply, sizeof(reply));
|
|
||||||
|
|
||||||
if (reply.error < 0) {
|
|
||||||
memcpy(msg->reply_data, &reply, sizeof(reply));
|
|
||||||
ret = reply.error;
|
|
||||||
} else {
|
|
||||||
/* reply has correct size? */
|
|
||||||
if (reply.hdr.size != msg->reply_size) {
|
|
||||||
dev_err(sdev->dev, "error: reply expected %zu got %u bytes\n",
|
|
||||||
msg->reply_size, reply.hdr.size);
|
|
||||||
ret = -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* read the message */
|
|
||||||
if (msg->reply_size > 0)
|
|
||||||
sof_mailbox_read(sdev, sdev->host_box.offset,
|
|
||||||
msg->reply_data, msg->reply_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
msg->reply_error = ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int imx8_get_mailbox_offset(struct snd_sof_dev *sdev)
|
static int imx8_get_mailbox_offset(struct snd_sof_dev *sdev)
|
||||||
{
|
{
|
||||||
return MBOX_OFFSET;
|
return MBOX_OFFSET;
|
||||||
|
@ -109,8 +75,7 @@ static void imx8_dsp_handle_reply(struct imx_dsp_ipc *ipc)
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
spin_lock_irqsave(&priv->sdev->ipc_lock, flags);
|
spin_lock_irqsave(&priv->sdev->ipc_lock, flags);
|
||||||
imx8_get_reply(priv->sdev);
|
snd_sof_ipc_process_reply(priv->sdev, 0);
|
||||||
snd_sof_ipc_reply(priv->sdev, 0);
|
|
||||||
spin_unlock_irqrestore(&priv->sdev->ipc_lock, flags);
|
spin_unlock_irqrestore(&priv->sdev->ipc_lock, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,40 +32,6 @@ struct imx8m_priv {
|
||||||
struct platform_device *ipc_dev;
|
struct platform_device *ipc_dev;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void imx8m_get_reply(struct snd_sof_dev *sdev)
|
|
||||||
{
|
|
||||||
struct snd_sof_ipc_msg *msg = sdev->msg;
|
|
||||||
struct sof_ipc_reply reply;
|
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
if (!msg) {
|
|
||||||
dev_warn(sdev->dev, "unexpected ipc interrupt\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* get reply */
|
|
||||||
sof_mailbox_read(sdev, sdev->host_box.offset, &reply, sizeof(reply));
|
|
||||||
|
|
||||||
if (reply.error < 0) {
|
|
||||||
memcpy(msg->reply_data, &reply, sizeof(reply));
|
|
||||||
ret = reply.error;
|
|
||||||
} else {
|
|
||||||
/* reply has correct size? */
|
|
||||||
if (reply.hdr.size != msg->reply_size) {
|
|
||||||
dev_err(sdev->dev, "error: reply expected %zu got %u bytes\n",
|
|
||||||
msg->reply_size, reply.hdr.size);
|
|
||||||
ret = -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* read the message */
|
|
||||||
if (msg->reply_size > 0)
|
|
||||||
sof_mailbox_read(sdev, sdev->host_box.offset,
|
|
||||||
msg->reply_data, msg->reply_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
msg->reply_error = ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int imx8m_get_mailbox_offset(struct snd_sof_dev *sdev)
|
static int imx8m_get_mailbox_offset(struct snd_sof_dev *sdev)
|
||||||
{
|
{
|
||||||
return MBOX_OFFSET;
|
return MBOX_OFFSET;
|
||||||
|
@ -82,8 +48,7 @@ static void imx8m_dsp_handle_reply(struct imx_dsp_ipc *ipc)
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
spin_lock_irqsave(&priv->sdev->ipc_lock, flags);
|
spin_lock_irqsave(&priv->sdev->ipc_lock, flags);
|
||||||
imx8m_get_reply(priv->sdev);
|
snd_sof_ipc_process_reply(priv->sdev, 0);
|
||||||
snd_sof_ipc_reply(priv->sdev, 0);
|
|
||||||
spin_unlock_irqrestore(&priv->sdev->ipc_lock, flags);
|
spin_unlock_irqrestore(&priv->sdev->ipc_lock, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue