Commit 8f8a5488 authored by Arnaud Pouliquen's avatar Arnaud Pouliquen Committed by Mark Brown

ASoC: stm32: sai: simplify dai driver initialisation

Suppress the useless dynamic allocation of the dai driver structure.
Signed-off-by: default avatarArnaud Pouliquen <arnaud.pouliquen@st.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 93f38ef6
...@@ -109,7 +109,7 @@ struct stm32_sai_sub_data { ...@@ -109,7 +109,7 @@ struct stm32_sai_sub_data {
struct regmap *regmap; struct regmap *regmap;
const struct regmap_config *regmap_config; const struct regmap_config *regmap_config;
struct snd_dmaengine_dai_dma_data dma_params; struct snd_dmaengine_dai_dma_data dma_params;
struct snd_soc_dai_driver *cpu_dai_drv; struct snd_soc_dai_driver cpu_dai_drv;
struct snd_soc_dai *cpu_dai; struct snd_soc_dai *cpu_dai;
struct snd_pcm_substream *substream; struct snd_pcm_substream *substream;
struct stm32_sai_data *pdata; struct stm32_sai_data *pdata;
...@@ -1204,8 +1204,7 @@ static const struct snd_pcm_hardware stm32_sai_pcm_hw = { ...@@ -1204,8 +1204,7 @@ static const struct snd_pcm_hardware stm32_sai_pcm_hw = {
.periods_max = 8, .periods_max = 8,
}; };
static struct snd_soc_dai_driver stm32_sai_playback_dai[] = { static struct snd_soc_dai_driver stm32_sai_playback_dai = {
{
.probe = stm32_sai_dai_probe, .probe = stm32_sai_dai_probe,
.pcm_new = stm32_sai_pcm_new, .pcm_new = stm32_sai_pcm_new,
.id = 1, /* avoid call to fmt_single_name() */ .id = 1, /* avoid call to fmt_single_name() */
...@@ -1222,11 +1221,9 @@ static struct snd_soc_dai_driver stm32_sai_playback_dai[] = { ...@@ -1222,11 +1221,9 @@ static struct snd_soc_dai_driver stm32_sai_playback_dai[] = {
SNDRV_PCM_FMTBIT_S32_LE, SNDRV_PCM_FMTBIT_S32_LE,
}, },
.ops = &stm32_sai_pcm_dai_ops, .ops = &stm32_sai_pcm_dai_ops,
}
}; };
static struct snd_soc_dai_driver stm32_sai_capture_dai[] = { static struct snd_soc_dai_driver stm32_sai_capture_dai = {
{
.probe = stm32_sai_dai_probe, .probe = stm32_sai_dai_probe,
.id = 1, /* avoid call to fmt_single_name() */ .id = 1, /* avoid call to fmt_single_name() */
.capture = { .capture = {
...@@ -1242,7 +1239,6 @@ static struct snd_soc_dai_driver stm32_sai_capture_dai[] = { ...@@ -1242,7 +1239,6 @@ static struct snd_soc_dai_driver stm32_sai_capture_dai[] = {
SNDRV_PCM_FMTBIT_S32_LE, SNDRV_PCM_FMTBIT_S32_LE,
}, },
.ops = &stm32_sai_pcm_dai_ops, .ops = &stm32_sai_pcm_dai_ops,
}
}; };
static const struct snd_dmaengine_pcm_config stm32_sai_pcm_config = { static const struct snd_dmaengine_pcm_config stm32_sai_pcm_config = {
...@@ -1411,29 +1407,6 @@ static int stm32_sai_sub_parse_of(struct platform_device *pdev, ...@@ -1411,29 +1407,6 @@ static int stm32_sai_sub_parse_of(struct platform_device *pdev,
return 0; return 0;
} }
static int stm32_sai_sub_dais_init(struct platform_device *pdev,
struct stm32_sai_sub_data *sai)
{
sai->cpu_dai_drv = devm_kzalloc(&pdev->dev,
sizeof(struct snd_soc_dai_driver),
GFP_KERNEL);
if (!sai->cpu_dai_drv)
return -ENOMEM;
if (STM_SAI_IS_PLAYBACK(sai)) {
memcpy(sai->cpu_dai_drv, &stm32_sai_playback_dai,
sizeof(stm32_sai_playback_dai));
sai->cpu_dai_drv->playback.stream_name = sai->cpu_dai_drv->name;
} else {
memcpy(sai->cpu_dai_drv, &stm32_sai_capture_dai,
sizeof(stm32_sai_capture_dai));
sai->cpu_dai_drv->capture.stream_name = sai->cpu_dai_drv->name;
}
sai->cpu_dai_drv->name = dev_name(&pdev->dev);
return 0;
}
static int stm32_sai_sub_probe(struct platform_device *pdev) static int stm32_sai_sub_probe(struct platform_device *pdev)
{ {
struct stm32_sai_sub_data *sai; struct stm32_sai_sub_data *sai;
...@@ -1465,9 +1438,11 @@ static int stm32_sai_sub_probe(struct platform_device *pdev) ...@@ -1465,9 +1438,11 @@ static int stm32_sai_sub_probe(struct platform_device *pdev)
if (ret) if (ret)
return ret; return ret;
ret = stm32_sai_sub_dais_init(pdev, sai); if (STM_SAI_IS_PLAYBACK(sai))
if (ret) sai->cpu_dai_drv = stm32_sai_playback_dai;
return ret; else
sai->cpu_dai_drv = stm32_sai_capture_dai;
sai->cpu_dai_drv.name = dev_name(&pdev->dev);
ret = devm_request_irq(&pdev->dev, sai->pdata->irq, stm32_sai_isr, ret = devm_request_irq(&pdev->dev, sai->pdata->irq, stm32_sai_isr,
IRQF_SHARED, dev_name(&pdev->dev), sai); IRQF_SHARED, dev_name(&pdev->dev), sai);
...@@ -1477,7 +1452,7 @@ static int stm32_sai_sub_probe(struct platform_device *pdev) ...@@ -1477,7 +1452,7 @@ static int stm32_sai_sub_probe(struct platform_device *pdev)
} }
ret = devm_snd_soc_register_component(&pdev->dev, &stm32_component, ret = devm_snd_soc_register_component(&pdev->dev, &stm32_component,
sai->cpu_dai_drv, 1); &sai->cpu_dai_drv, 1);
if (ret) if (ret)
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment