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

Commit 6aa357b3 authored by Laxminath Kasam's avatar Laxminath Kasam
Browse files

ASoC: wsa881x-analog: Fix warning in bandgap and clock control



During temperature read, resource acquire can fail
if mclk is not enabled successfully. In such case,
clock and bandgap control counters are not incremented.
But resource release is still happening resulting
in counters going negative and warn_on messages.
Fix it by handling resource acquire failure case.

CRs-Fixed: 1003365
Change-Id: If2371e06866a615ca7d7dad64a5d7a17f258b3b6
Signed-off-by: default avatarLaxminath Kasam <lkasam@codeaurora.org>
parent edf4d230
Loading
Loading
Loading
Loading
+18 −6
Original line number Diff line number Diff line
@@ -903,7 +903,8 @@ static int wsa881x_startup(struct wsa881x_pdata *pdata)
	if (pdata->enable_mclk) {
		ret = pdata->enable_mclk(card, true);
		if (ret < 0) {
			pr_err("%s: mclk enable failed %d\n",
			dev_err_ratelimited(codec->dev,
				"%s: mclk enable failed %d\n",
				__func__, ret);
			return ret;
		}
@@ -966,7 +967,8 @@ static int32_t wsa881x_resource_acquire(struct snd_soc_codec *codec,
	if (enable) {
		ret = wsa881x_startup(wsa881x);
		if (ret < 0) {
			pr_err("%s: failed to startup\n", __func__);
			dev_err_ratelimited(codec->dev,
				"%s: failed to startup\n", __func__);
			return ret;
		}
	}
@@ -975,7 +977,8 @@ static int32_t wsa881x_resource_acquire(struct snd_soc_codec *codec,
	if (!enable) {
		ret = wsa881x_shutdown(wsa881x);
		if (ret < 0)
			pr_err("%s: failed to shutdown\n", __func__);
			dev_err_ratelimited(codec->dev,
				"%s: failed to shutdown\n", __func__);
	}
	return ret;
}
@@ -984,12 +987,18 @@ static int32_t wsa881x_temp_reg_read(struct snd_soc_codec *codec,
				     struct wsa_temp_register *wsa_temp_reg)
{
	struct wsa881x_pdata *wsa881x = snd_soc_codec_get_drvdata(codec);
	int ret = 0;

	if (!wsa881x) {
		dev_err(codec->dev, "%s: wsa881x is NULL\n", __func__);
		return -EINVAL;
	}
	wsa881x_resource_acquire(codec, true);
	ret = wsa881x_resource_acquire(codec, true);
	if (ret) {
		dev_err_ratelimited(codec->dev,
			"%s: resource acquire fail\n", __func__);
		return ret;
	}

	if (WSA881X_IS_2_0(wsa881x->version)) {
		snd_soc_update_bits(codec, WSA881X_TADC_VALUE_CTL, 0x01, 0x00);
@@ -1007,9 +1016,12 @@ static int32_t wsa881x_temp_reg_read(struct snd_soc_codec *codec,
	wsa_temp_reg->d2_msb = snd_soc_read(codec, WSA881X_OTP_REG_3);
	wsa_temp_reg->d2_lsb = snd_soc_read(codec, WSA881X_OTP_REG_4);

	wsa881x_resource_acquire(codec, false);
	ret = wsa881x_resource_acquire(codec, false);
	if (ret)
		dev_err_ratelimited(codec->dev,
			"%s: resource release fail\n", __func__);

	return 0;
	return ret;
}

static int wsa881x_probe(struct snd_soc_codec *codec)