Commit 21e904bc authored by Srinivas Kandagatla's avatar Srinivas Kandagatla Committed by Mark Brown

ASoC: qcom: storm: allocate snd_soc_card struct dynamically.

This patch moves static allocation of snd_soc_card to dynamic allocation,
the reason to do this is to avoid holding up any dangling pointers
in this static structures. And I see no use for having this struct as static
given that the card->name is also populated dynamically from dt.
Signed-off-by: default avatarSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 6cc8ae94
...@@ -69,11 +69,6 @@ static struct snd_soc_dai_link storm_dai_link = { ...@@ -69,11 +69,6 @@ static struct snd_soc_dai_link storm_dai_link = {
.ops = &storm_soc_ops, .ops = &storm_soc_ops,
}; };
static struct snd_soc_card storm_soc_card = {
.name = "ipq806x-storm",
.dev = NULL,
};
static int storm_parse_of(struct snd_soc_card *card) static int storm_parse_of(struct snd_soc_card *card)
{ {
struct snd_soc_dai_link *dai_link = card->dai_link; struct snd_soc_dai_link *dai_link = card->dai_link;
...@@ -99,14 +94,13 @@ static int storm_parse_of(struct snd_soc_card *card) ...@@ -99,14 +94,13 @@ static int storm_parse_of(struct snd_soc_card *card)
static int storm_platform_probe(struct platform_device *pdev) static int storm_platform_probe(struct platform_device *pdev)
{ {
struct snd_soc_card *card = &storm_soc_card; struct snd_soc_card *card;
int ret; int ret;
if (card->dev) { card = devm_kzalloc(&pdev->dev, sizeof(*card), GFP_KERNEL);
dev_err(&pdev->dev, "%s() error, existing soundcard\n", if (!card)
__func__); return -ENOMEM;
return -ENODEV;
}
card->dev = &pdev->dev; card->dev = &pdev->dev;
platform_set_drvdata(pdev, card); platform_set_drvdata(pdev, card);
...@@ -129,7 +123,6 @@ static int storm_platform_probe(struct platform_device *pdev) ...@@ -129,7 +123,6 @@ static int storm_platform_probe(struct platform_device *pdev)
ret = devm_snd_soc_register_card(&pdev->dev, card); ret = devm_snd_soc_register_card(&pdev->dev, card);
if (ret == -EPROBE_DEFER) { if (ret == -EPROBE_DEFER) {
card->dev = NULL;
return ret; return ret;
} else if (ret) { } else if (ret) {
dev_err(&pdev->dev, "%s() error registering soundcard: %d\n", dev_err(&pdev->dev, "%s() error registering soundcard: %d\n",
......
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