Skip to content

Commit

Permalink
firmware: imx: Introduce imx_dsp_setup_channels
Browse files Browse the repository at this point in the history
Create a separate function that sets up DSP mailbox channels
so that imx_dsp_probe function will be easier to read.

Signed-off-by: Daniel Baluta <[email protected]>
Reviewed-by: Paul Olaru <[email protected]>
Signed-off-by: Shawn Guo <[email protected]>
  • Loading branch information
dbaluta authored and Shawn Guo committed Nov 16, 2020
1 parent 0b7a8e5 commit 4d3f4f0
Showing 1 changed file with 26 additions and 15 deletions.
41 changes: 26 additions & 15 deletions drivers/firmware/imx/imx-dsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,15 @@ static void imx_dsp_handle_rx(struct mbox_client *c, void *msg)
}
}

static int imx_dsp_probe(struct platform_device *pdev)
static int imx_dsp_setup_channels(struct imx_dsp_ipc *dsp_ipc)
{
struct device *dev = &pdev->dev;
struct imx_dsp_ipc *dsp_ipc;
struct device *dev = dsp_ipc->dev;
struct imx_dsp_chan *dsp_chan;
struct mbox_client *cl;
char *chan_name;
int ret;
int i, j;

device_set_of_node_from_dev(&pdev->dev, pdev->dev.parent);

dsp_ipc = devm_kzalloc(dev, sizeof(*dsp_ipc), GFP_KERNEL);
if (!dsp_ipc)
return -ENOMEM;

for (i = 0; i < DSP_MU_CHAN_NUM; i++) {
if (i < 2)
chan_name = kasprintf(GFP_KERNEL, "txdb%d", i);
Expand Down Expand Up @@ -108,12 +101,6 @@ static int imx_dsp_probe(struct platform_device *pdev)
kfree(chan_name);
}

dsp_ipc->dev = dev;

dev_set_drvdata(dev, dsp_ipc);

dev_info(dev, "NXP i.MX DSP IPC initialized\n");

return 0;
out:
kfree(chan_name);
Expand All @@ -125,6 +112,30 @@ static int imx_dsp_probe(struct platform_device *pdev)
return ret;
}

static int imx_dsp_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct imx_dsp_ipc *dsp_ipc;
int ret;

device_set_of_node_from_dev(&pdev->dev, pdev->dev.parent);

dsp_ipc = devm_kzalloc(dev, sizeof(*dsp_ipc), GFP_KERNEL);
if (!dsp_ipc)
return -ENOMEM;

dsp_ipc->dev = dev;
dev_set_drvdata(dev, dsp_ipc);

ret = imx_dsp_setup_channels(dsp_ipc);
if (ret < 0)
return ret;

dev_info(dev, "NXP i.MX DSP IPC initialized\n");

return 0;
}

static int imx_dsp_remove(struct platform_device *pdev)
{
struct imx_dsp_chan *dsp_chan;
Expand Down

0 comments on commit 4d3f4f0

Please sign in to comment.