diff options
author | Srinivas Kandagatla <srinivas.kandagatla@linaro.org> | 2015-06-09 09:34:21 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2015-06-09 12:18:58 -0400 |
commit | 21e904bcf9b2e57e0599e9dddff558ffd0ce5f59 (patch) | |
tree | 1c7917db32a57f7ee9ebf97455a80c010018586f /sound/soc/qcom | |
parent | 6cc8ae94813dffe7ff5ba88da0fe25a697e3e8a3 (diff) |
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: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/qcom')
-rw-r--r-- | sound/soc/qcom/storm.c | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/sound/soc/qcom/storm.c b/sound/soc/qcom/storm.c index b8bd296190ad..ee0661377672 100644 --- a/sound/soc/qcom/storm.c +++ b/sound/soc/qcom/storm.c | |||
@@ -69,11 +69,6 @@ static struct snd_soc_dai_link storm_dai_link = { | |||
69 | .ops = &storm_soc_ops, | 69 | .ops = &storm_soc_ops, |
70 | }; | 70 | }; |
71 | 71 | ||
72 | static struct snd_soc_card storm_soc_card = { | ||
73 | .name = "ipq806x-storm", | ||
74 | .dev = NULL, | ||
75 | }; | ||
76 | |||
77 | static int storm_parse_of(struct snd_soc_card *card) | 72 | static int storm_parse_of(struct snd_soc_card *card) |
78 | { | 73 | { |
79 | struct snd_soc_dai_link *dai_link = card->dai_link; | 74 | 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 | 94 | ||
100 | static int storm_platform_probe(struct platform_device *pdev) | 95 | static int storm_platform_probe(struct platform_device *pdev) |
101 | { | 96 | { |
102 | struct snd_soc_card *card = &storm_soc_card; | 97 | struct snd_soc_card *card; |
103 | int ret; | 98 | int ret; |
104 | 99 | ||
105 | if (card->dev) { | 100 | card = devm_kzalloc(&pdev->dev, sizeof(*card), GFP_KERNEL); |
106 | dev_err(&pdev->dev, "%s() error, existing soundcard\n", | 101 | if (!card) |
107 | __func__); | 102 | return -ENOMEM; |
108 | return -ENODEV; | 103 | |
109 | } | ||
110 | card->dev = &pdev->dev; | 104 | card->dev = &pdev->dev; |
111 | platform_set_drvdata(pdev, card); | 105 | platform_set_drvdata(pdev, card); |
112 | 106 | ||
@@ -129,7 +123,6 @@ static int storm_platform_probe(struct platform_device *pdev) | |||
129 | 123 | ||
130 | ret = devm_snd_soc_register_card(&pdev->dev, card); | 124 | ret = devm_snd_soc_register_card(&pdev->dev, card); |
131 | if (ret == -EPROBE_DEFER) { | 125 | if (ret == -EPROBE_DEFER) { |
132 | card->dev = NULL; | ||
133 | return ret; | 126 | return ret; |
134 | } else if (ret) { | 127 | } else if (ret) { |
135 | dev_err(&pdev->dev, "%s() error registering soundcard: %d\n", | 128 | dev_err(&pdev->dev, "%s() error registering soundcard: %d\n", |