Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3c3215e3 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "ASoC: wcd9335: Fix race during codec master clock (mclk) enablement"

parents d462437d 128af5cd
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -811,6 +811,9 @@ struct tasha_priv {
	int rx_8_count;
	bool clk_mode;
	bool clk_internal;

	/* Lock to protect mclk enablement */
	struct mutex mclk_lock;
};

static int tasha_codec_vote_max_bw(struct snd_soc_codec *codec,
@@ -951,13 +954,14 @@ static int tasha_cdc_req_mclk_enable(struct tasha_priv *tasha,
{
	int ret = 0;

	mutex_lock(&tasha->mclk_lock);
	if (enable) {
		tasha_cdc_sido_ccl_enable(tasha, true);
		ret = clk_prepare_enable(tasha->wcd_ext_clk);
		if (ret) {
			dev_err(tasha->dev, "%s: ext clk enable failed\n",
				__func__);
			goto err;
			goto unlock_mutex;
		}
		/* get BG */
		wcd_resmgr_enable_master_bias(tasha->resmgr);
@@ -971,7 +975,8 @@ static int tasha_cdc_req_mclk_enable(struct tasha_priv *tasha,
		clk_disable_unprepare(tasha->wcd_ext_clk);
		tasha_cdc_sido_ccl_enable(tasha, false);
	}
err:
unlock_mutex:
	mutex_unlock(&tasha->mclk_lock);
	return ret;
}

@@ -13758,6 +13763,7 @@ static int tasha_probe(struct platform_device *pdev)
	mutex_init(&tasha->swr_read_lock);
	mutex_init(&tasha->swr_write_lock);
	mutex_init(&tasha->swr_clk_lock);
	mutex_init(&tasha->mclk_lock);

	cdc_pwr = devm_kzalloc(&pdev->dev, sizeof(struct wcd9xxx_power_region),
			       GFP_KERNEL);
@@ -13842,6 +13848,7 @@ err_clk:
err_resmgr:
	devm_kfree(&pdev->dev, cdc_pwr);
err_cdc_pwr:
	mutex_destroy(&tasha->mclk_lock);
	devm_kfree(&pdev->dev, tasha);
	return ret;
}
@@ -13855,6 +13862,7 @@ static int tasha_remove(struct platform_device *pdev)
	clk_put(tasha->wcd_ext_clk);
	if (tasha->wcd_native_clk)
		clk_put(tasha->wcd_native_clk);
	mutex_destroy(&tasha->mclk_lock);
	devm_kfree(&pdev->dev, tasha);
	snd_soc_unregister_codec(&pdev->dev);
	return 0;