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

Commit 0e55037e authored by Santosh Mardi's avatar Santosh Mardi Committed by Aviral Gupta
Browse files

ASoC: msm8x16-wcd: update codec driver to unlock mutex properly



Update codec driver to unlock the mutex before returning during
error case.

Update machine driver not to decrement the mclk reference counter
before disabling the mclk, the reference counter should be
decremented after the mclk disable is completed

CRs-Fixed: 646358
Change-Id: Icf6c3463c7b4e1e45a643c66add3b7685093263c
Signed-off-by: default avatarSantosh Mardi <gsantosh@codeaurora.org>
parent 03fc0168
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -320,7 +320,7 @@ static int __msm8x16_wcd_reg_read(struct snd_soc_codec *codec,
				unsigned short reg)
{
	int ret = -EINVAL;
	u8 temp;
	u8 temp = 0;
	struct msm8x16_wcd *msm8x16_wcd = codec->control_data;
	struct msm8916_asoc_mach_data *pdata = NULL;

@@ -340,13 +340,14 @@ static int __msm8x16_wcd_reg_read(struct snd_soc_codec *codec,
					&pdata->digital_cdc_clk);
			if (ret < 0) {
				pr_err("failed to enable the MCLK\n");
				return 0;
				goto err;
			}
			pr_debug("%s: MCLK not enabled\n", __func__);
			atomic_set(&pdata->dis_work_mclk, true);
			schedule_delayed_work(&pdata->enable_mclk_work, 50);
			ret = msm8x16_wcd_ahb_read_device(
					msm8x16_wcd, reg, 1, &temp);
err:
			mutex_unlock(&pdata->cdc_mclk_mutex);
			mutex_unlock(&msm8x16_wcd->io_lock);
			return temp;
@@ -391,12 +392,14 @@ static int __msm8x16_wcd_reg_write(struct snd_soc_codec *codec,
					&pdata->digital_cdc_clk);
			if (ret < 0) {
				pr_err("failed to enable the MCLK\n");
				return 0;
				ret = 0;
				goto err;
			}
			atomic_set(&pdata->dis_work_mclk, true);
			schedule_delayed_work(&pdata->enable_mclk_work, 50);
			ret = msm8x16_wcd_ahb_write_device(
						msm8x16_wcd, reg, &val, 1);
err:
			mutex_unlock(&pdata->cdc_mclk_mutex);
			mutex_unlock(&msm8x16_wcd->io_lock);
			return ret;
+3 −2
Original line number Diff line number Diff line
@@ -308,7 +308,7 @@ static int msm8x16_enable_codec_ext_clk(struct snd_soc_codec *codec,

	pdata = snd_soc_card_get_drvdata(codec->card);
	mutex_lock(&pdata->cdc_mclk_mutex);
	pr_err("%s: enable = %d  codec name %s enable %d mclk ref counter %d\n",
	pr_debug("%s: enable = %d  codec name %s enable %d mclk ref counter %d\n",
		   __func__, enable, codec->name, enable,
		   atomic_read(&pdata->mclk_rsc_ref));
	if (enable) {
@@ -321,7 +321,7 @@ static int msm8x16_enable_codec_ext_clk(struct snd_soc_codec *codec,
			cancel_delayed_work_sync(&pdata->enable_mclk_work);
		}
	} else {
		if (atomic_dec_return(&pdata->mclk_rsc_ref) == 0) {
		if ((atomic_read(&pdata->mclk_rsc_ref) - 1) == 0) {
			pdata->digital_cdc_clk.clk_val = 0;
			msm8x16_wcd_mclk_enable(codec, 0, dapm);
			afe_set_digital_codec_core_clock(
@@ -334,6 +334,7 @@ static int msm8x16_enable_codec_ext_clk(struct snd_soc_codec *codec,
					&pdata->enable_mclk_work, 10);
			}
		}
		atomic_dec(&pdata->mclk_rsc_ref);
	}
	mutex_unlock(&pdata->cdc_mclk_mutex);
	return ret;