0180-ASoC-mediatek-fix-error-handling-in-mt2701_afe_pcm_d.patch 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. From 17508c32dd65649d2617c1c52b32b02bdb54b793 Mon Sep 17 00:00:00 2001
  2. From: Ryder Lee <[email protected]>
  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. Fix unbalanced error handling path which will get incorrect counts
  7. if probe failed. The .remove() should be adjusted accordingly.
  8. Signed-off-by: Ryder Lee <[email protected]>
  9. Tested-by: Garlic Tseng <[email protected]>
  10. Signed-off-by: Mark Brown <[email protected]>
  11. ---
  12. sound/soc/mediatek/mt2701/mt2701-afe-pcm.c | 31 ++++++++++++++----------------
  13. 1 file changed, 14 insertions(+), 17 deletions(-)
  14. --- a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c
  15. +++ b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c
  16. @@ -1590,12 +1590,16 @@ static int mt2701_afe_pcm_dev_probe(stru
  17. }
  18. platform_set_drvdata(pdev, afe);
  19. - pm_runtime_enable(&pdev->dev);
  20. - if (!pm_runtime_enabled(&pdev->dev))
  21. - goto err_pm_disable;
  22. - pm_runtime_get_sync(&pdev->dev);
  23. - ret = snd_soc_register_platform(&pdev->dev, &mtk_afe_pcm_platform);
  24. + pm_runtime_enable(dev);
  25. + if (!pm_runtime_enabled(dev)) {
  26. + ret = mt2701_afe_runtime_resume(dev);
  27. + if (ret)
  28. + goto err_pm_disable;
  29. + }
  30. + pm_runtime_get_sync(dev);
  31. +
  32. + ret = snd_soc_register_platform(dev, &mtk_afe_pcm_platform);
  33. if (ret) {
  34. dev_warn(dev, "err_platform\n");
  35. goto err_platform;
  36. @@ -1610,35 +1614,28 @@ static int mt2701_afe_pcm_dev_probe(stru
  37. goto err_dai_component;
  38. }
  39. - mt2701_afe_runtime_resume(&pdev->dev);
  40. -
  41. return 0;
  42. err_dai_component:
  43. - snd_soc_unregister_component(&pdev->dev);
  44. -
  45. + snd_soc_unregister_platform(dev);
  46. err_platform:
  47. - snd_soc_unregister_platform(&pdev->dev);
  48. -
  49. + pm_runtime_put_sync(dev);
  50. err_pm_disable:
  51. - pm_runtime_disable(&pdev->dev);
  52. + pm_runtime_disable(dev);
  53. return ret;
  54. }
  55. static int mt2701_afe_pcm_dev_remove(struct platform_device *pdev)
  56. {
  57. - struct mtk_base_afe *afe = platform_get_drvdata(pdev);
  58. -
  59. + pm_runtime_put_sync(&pdev->dev);
  60. pm_runtime_disable(&pdev->dev);
  61. if (!pm_runtime_status_suspended(&pdev->dev))
  62. mt2701_afe_runtime_suspend(&pdev->dev);
  63. - pm_runtime_put_sync(&pdev->dev);
  64. snd_soc_unregister_component(&pdev->dev);
  65. snd_soc_unregister_platform(&pdev->dev);
  66. - /* disable afe clock */
  67. - mt2701_afe_disable_clock(afe);
  68. +
  69. return 0;
  70. }