ath79: etactica-eg200: fix restore button
[openwrt/openwrt.git] / target / linux / mediatek / patches-4.14 / 0180-ASoC-mediatek-fix-error-handling-in-mt2701_afe_pcm_d.patch
1 From 17508c32dd65649d2617c1c52b32b02bdb54b793 Mon Sep 17 00:00:00 2001
2 From: Ryder Lee <ryder.lee@mediatek.com>
3 Date: Tue, 2 Jan 2018 19:47:18 +0800
4 Subject: [PATCH 180/224] ASoC: mediatek: fix error handling in
5 mt2701_afe_pcm_dev_probe()
6
7 Fix unbalanced error handling path which will get incorrect counts
8 if probe failed. The .remove() should be adjusted accordingly.
9
10 Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
11 Tested-by: Garlic Tseng <garlic.tseng@mediatek.com>
12 Signed-off-by: Mark Brown <broonie@kernel.org>
13 ---
14 sound/soc/mediatek/mt2701/mt2701-afe-pcm.c | 31 ++++++++++++++----------------
15 1 file changed, 14 insertions(+), 17 deletions(-)
16
17 --- a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c
18 +++ b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c
19 @@ -1590,12 +1590,16 @@ static int mt2701_afe_pcm_dev_probe(stru
20 }
21
22 platform_set_drvdata(pdev, afe);
23 - pm_runtime_enable(&pdev->dev);
24 - if (!pm_runtime_enabled(&pdev->dev))
25 - goto err_pm_disable;
26 - pm_runtime_get_sync(&pdev->dev);
27
28 - ret = snd_soc_register_platform(&pdev->dev, &mtk_afe_pcm_platform);
29 + pm_runtime_enable(dev);
30 + if (!pm_runtime_enabled(dev)) {
31 + ret = mt2701_afe_runtime_resume(dev);
32 + if (ret)
33 + goto err_pm_disable;
34 + }
35 + pm_runtime_get_sync(dev);
36 +
37 + ret = snd_soc_register_platform(dev, &mtk_afe_pcm_platform);
38 if (ret) {
39 dev_warn(dev, "err_platform\n");
40 goto err_platform;
41 @@ -1610,35 +1614,28 @@ static int mt2701_afe_pcm_dev_probe(stru
42 goto err_dai_component;
43 }
44
45 - mt2701_afe_runtime_resume(&pdev->dev);
46 -
47 return 0;
48
49 err_dai_component:
50 - snd_soc_unregister_component(&pdev->dev);
51 -
52 + snd_soc_unregister_platform(dev);
53 err_platform:
54 - snd_soc_unregister_platform(&pdev->dev);
55 -
56 + pm_runtime_put_sync(dev);
57 err_pm_disable:
58 - pm_runtime_disable(&pdev->dev);
59 + pm_runtime_disable(dev);
60
61 return ret;
62 }
63
64 static int mt2701_afe_pcm_dev_remove(struct platform_device *pdev)
65 {
66 - struct mtk_base_afe *afe = platform_get_drvdata(pdev);
67 -
68 + pm_runtime_put_sync(&pdev->dev);
69 pm_runtime_disable(&pdev->dev);
70 if (!pm_runtime_status_suspended(&pdev->dev))
71 mt2701_afe_runtime_suspend(&pdev->dev);
72 - pm_runtime_put_sync(&pdev->dev);
73
74 snd_soc_unregister_component(&pdev->dev);
75 snd_soc_unregister_platform(&pdev->dev);
76 - /* disable afe clock */
77 - mt2701_afe_disable_clock(afe);
78 +
79 return 0;
80 }
81