ASoC: codecs: wcd938x: fix runtime PM imbalance on remove
authorJohan Hovold <johan+linaro@kernel.org>
Tue, 3 Oct 2023 15:55:56 +0000 (17:55 +0200)
committerMark Brown <broonie@kernel.org>
Mon, 9 Oct 2023 12:03:35 +0000 (13:03 +0100)
Make sure to balance the runtime PM operations, including the disable
count, on driver unbind.

Fixes: 16572522aece ("ASoC: codecs: wcd938x-sdw: add SoundWire driver")
Cc: stable@vger.kernel.org # 5.14
Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
Link: https://lore.kernel.org/r/20231003155558.27079-6-johan+linaro@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/wcd938x.c

index 679c627..d27b919 100644 (file)
@@ -3620,9 +3620,15 @@ err_disable_regulators:
 
 static void wcd938x_remove(struct platform_device *pdev)
 {
-       struct wcd938x_priv *wcd938x = dev_get_drvdata(&pdev->dev);
+       struct device *dev = &pdev->dev;
+       struct wcd938x_priv *wcd938x = dev_get_drvdata(dev);
+
+       component_master_del(dev, &wcd938x_comp_ops);
+
+       pm_runtime_disable(dev);
+       pm_runtime_set_suspended(dev);
+       pm_runtime_dont_use_autosuspend(dev);
 
-       component_master_del(&pdev->dev, &wcd938x_comp_ops);
        regulator_bulk_disable(WCD938X_MAX_SUPPLY, wcd938x->supplies);
        regulator_bulk_free(WCD938X_MAX_SUPPLY, wcd938x->supplies);
 }