diff options
author | Sylwester Nawrocki <s.nawrocki@samsung.com> | 2019-09-20 09:02:11 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2019-09-23 17:14:35 -0400 |
commit | fb629fa2587d0c150792d87e3053664bfc8dc78c (patch) | |
tree | cbeff96bdc163b5bd069a8ed9bdfb8ef7f0498cb | |
parent | 147162f575152db80000fb3de26358264768ee9f (diff) |
ASoC: samsung: arndale: Add missing OF node dereferencing
Ensure there is no OF node references kept when the driver
is removed/unbound.
Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Acked-by: Krzysztof Kozlowski <krzk@kernel.org>
Link: https://lore.kernel.org/r/20190920130218.32690-3-s.nawrocki@samsung.com
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | sound/soc/samsung/arndale_rt5631.c | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/sound/soc/samsung/arndale_rt5631.c b/sound/soc/samsung/arndale_rt5631.c index c213913eb984..fd8c6642fb0d 100644 --- a/sound/soc/samsung/arndale_rt5631.c +++ b/sound/soc/samsung/arndale_rt5631.c | |||
@@ -5,6 +5,7 @@ | |||
5 | // Author: Claude <claude@insginal.co.kr> | 5 | // Author: Claude <claude@insginal.co.kr> |
6 | 6 | ||
7 | #include <linux/module.h> | 7 | #include <linux/module.h> |
8 | #include <linux/of_device.h> | ||
8 | #include <linux/platform_device.h> | 9 | #include <linux/platform_device.h> |
9 | #include <linux/clk.h> | 10 | #include <linux/clk.h> |
10 | 11 | ||
@@ -74,6 +75,17 @@ static struct snd_soc_card arndale_rt5631 = { | |||
74 | .num_links = ARRAY_SIZE(arndale_rt5631_dai), | 75 | .num_links = ARRAY_SIZE(arndale_rt5631_dai), |
75 | }; | 76 | }; |
76 | 77 | ||
78 | static void arndale_put_of_nodes(struct snd_soc_card *card) | ||
79 | { | ||
80 | struct snd_soc_dai_link *dai_link; | ||
81 | int i; | ||
82 | |||
83 | for_each_card_prelinks(card, i, dai_link) { | ||
84 | of_node_put(dai_link->cpus->of_node); | ||
85 | of_node_put(dai_link->codecs->of_node); | ||
86 | } | ||
87 | } | ||
88 | |||
77 | static int arndale_audio_probe(struct platform_device *pdev) | 89 | static int arndale_audio_probe(struct platform_device *pdev) |
78 | { | 90 | { |
79 | int n, ret; | 91 | int n, ret; |
@@ -103,18 +115,31 @@ static int arndale_audio_probe(struct platform_device *pdev) | |||
103 | if (!arndale_rt5631_dai[0].codecs->of_node) { | 115 | if (!arndale_rt5631_dai[0].codecs->of_node) { |
104 | dev_err(&pdev->dev, | 116 | dev_err(&pdev->dev, |
105 | "Property 'samsung,audio-codec' missing or invalid\n"); | 117 | "Property 'samsung,audio-codec' missing or invalid\n"); |
106 | return -EINVAL; | 118 | ret = -EINVAL; |
119 | goto err_put_of_nodes; | ||
107 | } | 120 | } |
108 | } | 121 | } |
109 | 122 | ||
110 | ret = devm_snd_soc_register_card(card->dev, card); | 123 | ret = devm_snd_soc_register_card(card->dev, card); |
124 | if (ret) { | ||
125 | dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", ret); | ||
126 | goto err_put_of_nodes; | ||
127 | } | ||
128 | return 0; | ||
111 | 129 | ||
112 | if (ret) | 130 | err_put_of_nodes: |
113 | dev_err(&pdev->dev, "snd_soc_register_card() failed:%d\n", ret); | 131 | arndale_put_of_nodes(card); |
114 | |||
115 | return ret; | 132 | return ret; |
116 | } | 133 | } |
117 | 134 | ||
135 | static int arndale_audio_remove(struct platform_device *pdev) | ||
136 | { | ||
137 | struct snd_soc_card *card = platform_get_drvdata(pdev); | ||
138 | |||
139 | arndale_put_of_nodes(card); | ||
140 | return 0; | ||
141 | } | ||
142 | |||
118 | static const struct of_device_id samsung_arndale_rt5631_of_match[] __maybe_unused = { | 143 | static const struct of_device_id samsung_arndale_rt5631_of_match[] __maybe_unused = { |
119 | { .compatible = "samsung,arndale-rt5631", }, | 144 | { .compatible = "samsung,arndale-rt5631", }, |
120 | { .compatible = "samsung,arndale-alc5631", }, | 145 | { .compatible = "samsung,arndale-alc5631", }, |
@@ -129,6 +154,7 @@ static struct platform_driver arndale_audio_driver = { | |||
129 | .of_match_table = of_match_ptr(samsung_arndale_rt5631_of_match), | 154 | .of_match_table = of_match_ptr(samsung_arndale_rt5631_of_match), |
130 | }, | 155 | }, |
131 | .probe = arndale_audio_probe, | 156 | .probe = arndale_audio_probe, |
157 | .remove = arndale_audio_remove, | ||
132 | }; | 158 | }; |
133 | 159 | ||
134 | module_platform_driver(arndale_audio_driver); | 160 | module_platform_driver(arndale_audio_driver); |