Skip to content
Snippets Groups Projects
Commit 66d6e044 authored by Daniel Baluta's avatar Daniel Baluta Committed by Leonard Crestez
Browse files

MLK-18497-10: ASoC: fsl: dsp: Refactor fsl_dsp_{open|close}


DSP driver now supports two interfaces. Old ioctl chardev based
interface and ALSA compress interface.

Because some part of the open/close code is common introduce
two new functions which encapsulate the common functionality.

Reviewed-by: default avatarCosmin-Gabriel Samoila <cosmin.samoila@nxp.com>
Signed-off-by: default avatarShengjiu Wang <shengjiu.wang@nxp.com>
Signed-off-by: default avatarDaniel Baluta <daniel.baluta@nxp.com>
(cherry picked from commit 61d764aa7352e135f7c700689c9266aa255445b0)
Signed-off-by: default avatarVipul Kumar <vipul_kumar@mentor.com>
Signed-off-by: default avatarSrikanth Krishnakar <Srikanth_Krishnakar@mentor.com>
Signed-off-by: default avatarVipul Kumar <vipul_kumar@mentor.com>
parent f01b0a67
No related branches found
No related tags found
No related merge requests found
......@@ -351,22 +351,11 @@ void resource_release(struct fsl_dsp *dsp_priv)
xf_proxy_init(&dsp_priv->proxy);
}
static int fsl_dsp_open(struct inode *inode, struct file *file)
int fsl_dsp_open_func(struct fsl_dsp *dsp_priv, struct xf_client *client)
{
struct fsl_dsp *dsp_priv = dev_get_drvdata(dsp_miscdev.parent);
struct device *dev = dsp_priv->dev;
struct xf_client *client;
int ret = 0;
/* ...basic sanity checks */
if (!inode || !file)
return -EINVAL;
/* ...allocate new proxy client object */
client = xf_client_alloc(dsp_priv);
if (IS_ERR(client))
return PTR_ERR(client);
/* ...initialize waiting queue */
init_waitqueue_head(&client->wait);
......@@ -381,8 +370,6 @@ static int fsl_dsp_open(struct inode *inode, struct file *file)
client->global = (void *)dsp_priv;
file->private_data = (void *)client;
pm_runtime_get_sync(dev);
mutex_lock(&dsp_priv->dsp_mutex);
......@@ -393,18 +380,35 @@ static int fsl_dsp_open(struct inode *inode, struct file *file)
return ret;
}
static int fsl_dsp_close(struct inode *inode, struct file *file)
static int fsl_dsp_open(struct inode *inode, struct file *file)
{
struct fsl_dsp *dsp_priv;
struct device *dev;
struct xf_proxy *proxy;
struct fsl_dsp *dsp_priv = dev_get_drvdata(dsp_miscdev.parent);
struct xf_client *client;
int ret = 0;
/* ...basic sanity checks */
client = xf_get_client(file);
if (!inode || !file)
return -EINVAL;
/* ...allocate new proxy client object */
client = xf_client_alloc(dsp_priv);
if (IS_ERR(client))
return PTR_ERR(client);
fsl_dsp_open_func(dsp_priv, client);
file->private_data = (void *)client;
return ret;
}
int fsl_dsp_close_func(struct xf_client *client)
{
struct fsl_dsp *dsp_priv;
struct device *dev;
struct xf_proxy *proxy;
/* ...basic sanity checks */
proxy = client->proxy;
/* release all pending messages */
......@@ -432,6 +436,20 @@ static int fsl_dsp_close(struct inode *inode, struct file *file)
return 0;
}
static int fsl_dsp_close(struct inode *inode, struct file *file)
{
struct xf_client *client;
/* ...basic sanity checks */
client = xf_get_client(file);
if (IS_ERR(client))
return PTR_ERR(client);
fsl_dsp_close_func(client);
return 0;
}
/* ...wait until data is available in the response queue */
static unsigned int fsl_dsp_poll(struct file *file, poll_table *wait)
{
......
......@@ -141,4 +141,7 @@ void *memset_dsp(void *dest, int c, size_t count);
struct xf_client *xf_client_lookup(struct fsl_dsp *dsp_priv, u32 id);
struct xf_client *xf_client_alloc(struct fsl_dsp *dsp_priv);
int fsl_dsp_open_func(struct fsl_dsp *dsp_priv, struct xf_client *client);
int fsl_dsp_close_func(struct xf_client *client);
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment