Message ID | 20190918104634.15216-9-s.nawrocki@samsung.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v1,1/9] ASoC: wm8994: Do not register inapplicable controls for WM1811 | expand |
On Wed, Sep 18, 2019 at 12:46:33PM +0200, Sylwester Nawrocki wrote: > Ensure there is no OF node references kept when the driver is removed/unbound. > > Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com> > --- Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com> Thanks, Charles
On Wed, Sep 18, 2019 at 12:46:33PM +0200, Sylwester Nawrocki wrote: > Ensure there is no OF node references kept when the driver is removed/unbound. > > Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com> > --- > sound/soc/samsung/arndale_rt5631.c | 31 ++++++++++++++++++++++++++++-- > 1 file changed, 29 insertions(+), 2 deletions(-) Wasn't this issue introduced in 5/9? It looks weird to fix it here... Best regards, Krzysztof > > diff --git a/sound/soc/samsung/arndale_rt5631.c b/sound/soc/samsung/arndale_rt5631.c > index 3744c47742b8..d8da313e898a 100644 > --- a/sound/soc/samsung/arndale_rt5631.c > +++ b/sound/soc/samsung/arndale_rt5631.c > @@ -132,6 +132,17 @@ static struct snd_soc_card arndale_wm1811 = { > .num_links = ARRAY_SIZE(arndale_wm1811_dai), > }; > > +static void arndale_put_of_nodes(struct snd_soc_card *card) > +{ > + struct snd_soc_dai_link *dai_link; > + int i; > + > + for_each_card_prelinks(card, i, dai_link) { > + of_node_put(dai_link->cpus->of_node); > + of_node_put(dai_link->codecs->of_node); > + } > +} > + > static int arndale_audio_probe(struct platform_device *pdev) > { > struct device_node *np = pdev->dev.of_node; > @@ -156,16 +167,31 @@ static int arndale_audio_probe(struct platform_device *pdev) > if (!dai_link->codecs->of_node) { > dev_err(&pdev->dev, > "Property 'samsung,audio-codec' missing or invalid\n"); > - return -EINVAL; > + ret = -EINVAL; > + goto err_put_of_nodes; > } > > ret = devm_snd_soc_register_card(card->dev, card); > - if (ret) > + if (ret) { > dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", ret); > + goto err_put_of_nodes; > + } > > + return 0; > + > +err_put_of_nodes: > + arndale_put_of_nodes(card); > return ret; > } > > +static int arndale_audio_remove(struct platform_device *pdev) > +{ > + struct snd_soc_card *card = platform_get_drvdata(pdev); > + > + arndale_put_of_nodes(card); > + return 0; > +} > + > static const struct of_device_id arndale_audio_of_match[] __maybe_unused = { > { .compatible = "samsung,arndale-rt5631", .data = &arndale_rt5631 }, > { .compatible = "samsung,arndale-alc5631", .data = &arndale_rt5631 }, > @@ -181,6 +207,7 @@ static struct platform_driver arndale_audio_driver = { > .of_match_table = arndale_audio_of_match, > }, > .probe = arndale_audio_probe, > + .remove = arndale_audio_remove, > }; > > module_platform_driver(arndale_audio_driver); > -- > 2.17.1 >
On 9/19/19 10:22, Krzysztof Kozlowski wrote:
> Wasn't this issue introduced in 5/9? It looks weird to fix it here...
It has not been introduced by 5/9, the issue was there already before
my patch, there was even no remove() callback where OF node references
could be dropped.
On Thu, 19 Sep 2019 at 14:49, Sylwester Nawrocki <s.nawrocki@samsung.com> wrote: > > On 9/19/19 10:22, Krzysztof Kozlowski wrote: > > Wasn't this issue introduced in 5/9? It looks weird to fix it here... > > It has not been introduced by 5/9, the issue was there already before > my patch, there was even no remove() callback where OF node references > could be dropped. I see. Then please put it as first patch. You should not mix bugfixes with features. If mixing, be sure they can be applied before the features. Best regards, Krzysztof
On 9/19/19 14:58, Krzysztof Kozlowski wrote: > On Thu, 19 Sep 2019 at 14:49, Sylwester Nawrocki <s.nawrocki@samsung.com> wrote: >> On 9/19/19 10:22, Krzysztof Kozlowski wrote: >>> Wasn't this issue introduced in 5/9? It looks weird to fix it here... >> It has not been introduced by 5/9, the issue was there already before >> my patch, there was even no remove() callback where OF node references >> could be dropped. > > I see. Then please put it as first patch. You should not mix bugfixes > with features. If mixing, be sure they can be applied before the > features. I will see if it is worth the effort to rebase this patch. I didn't bother with that because this sound card driver is not used in mainline (there is no related dts changes) and the patch is a fix for minor bug which I found just before posting first version of the patch series.
diff --git a/sound/soc/samsung/arndale_rt5631.c b/sound/soc/samsung/arndale_rt5631.c index 3744c47742b8..d8da313e898a 100644 --- a/sound/soc/samsung/arndale_rt5631.c +++ b/sound/soc/samsung/arndale_rt5631.c @@ -132,6 +132,17 @@ static struct snd_soc_card arndale_wm1811 = { .num_links = ARRAY_SIZE(arndale_wm1811_dai), }; +static void arndale_put_of_nodes(struct snd_soc_card *card) +{ + struct snd_soc_dai_link *dai_link; + int i; + + for_each_card_prelinks(card, i, dai_link) { + of_node_put(dai_link->cpus->of_node); + of_node_put(dai_link->codecs->of_node); + } +} + static int arndale_audio_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; @@ -156,16 +167,31 @@ static int arndale_audio_probe(struct platform_device *pdev) if (!dai_link->codecs->of_node) { dev_err(&pdev->dev, "Property 'samsung,audio-codec' missing or invalid\n"); - return -EINVAL; + ret = -EINVAL; + goto err_put_of_nodes; } ret = devm_snd_soc_register_card(card->dev, card); - if (ret) + if (ret) { dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", ret); + goto err_put_of_nodes; + } + return 0; + +err_put_of_nodes: + arndale_put_of_nodes(card); return ret; } +static int arndale_audio_remove(struct platform_device *pdev) +{ + struct snd_soc_card *card = platform_get_drvdata(pdev); + + arndale_put_of_nodes(card); + return 0; +} + static const struct of_device_id arndale_audio_of_match[] __maybe_unused = { { .compatible = "samsung,arndale-rt5631", .data = &arndale_rt5631 }, { .compatible = "samsung,arndale-alc5631", .data = &arndale_rt5631 }, @@ -181,6 +207,7 @@ static struct platform_driver arndale_audio_driver = { .of_match_table = arndale_audio_of_match, }, .probe = arndale_audio_probe, + .remove = arndale_audio_remove, }; module_platform_driver(arndale_audio_driver);
Ensure there is no OF node references kept when the driver is removed/unbound. Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com> --- sound/soc/samsung/arndale_rt5631.c | 31 ++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-)