Skip to content

Commit bfe6a26

Browse files
JihedChaibibroonie
authored andcommitted
ASoC: adau1372: Fix clock leak on PLL lock failure
adau1372_enable_pll() was a void function that logged a dev_err() on PLL lock timeout but did not propagate the error. As a result, adau1372_set_power() would continue with adau1372->enabled set to true despite the PLL being unlocked, and the mclk left enabled with no corresponding disable on the error path. Convert adau1372_enable_pll() to return int, using -ETIMEDOUT on lock timeout and propagating regmap errors directly. In adau1372_set_power(), check the return value and unwind in reverse order: restore regcache to cache-only mode, reassert GPIO power-down, and disable the clock before returning the error. Signed-off-by: Jihed Chaibi <jihed.chaibi.dev@gmail.com> Fixes: 6cd4c64 ("ASoC: Add ADAU1372 audio CODEC support") Reviewed-by: Nuno Sá <nuno.sa@analog.com> Link: https://patch.msgid.link/20260325210704.76847-3-jihed.chaibi.dev@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 326fe81 commit bfe6a26

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

sound/soc/codecs/adau1372.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ static int adau1372_startup(struct snd_pcm_substream *substream, struct snd_soc_
762762
return 0;
763763
}
764764

765-
static void adau1372_enable_pll(struct adau1372 *adau1372)
765+
static int adau1372_enable_pll(struct adau1372 *adau1372)
766766
{
767767
unsigned int val, timeout = 0;
768768
int ret;
@@ -778,8 +778,12 @@ static void adau1372_enable_pll(struct adau1372 *adau1372)
778778
timeout++;
779779
} while (!(val & 1) && timeout < 3);
780780

781-
if (ret < 0 || !(val & 1))
781+
if (ret < 0 || !(val & 1)) {
782782
dev_err(adau1372->dev, "Failed to lock PLL\n");
783+
return ret < 0 ? ret : -ETIMEDOUT;
784+
}
785+
786+
return 0;
783787
}
784788

785789
static int adau1372_set_power(struct adau1372 *adau1372, bool enable)
@@ -807,7 +811,14 @@ static int adau1372_set_power(struct adau1372 *adau1372, bool enable)
807811
* accessed.
808812
*/
809813
if (adau1372->use_pll) {
810-
adau1372_enable_pll(adau1372);
814+
ret = adau1372_enable_pll(adau1372);
815+
if (ret) {
816+
regcache_cache_only(adau1372->regmap, true);
817+
if (adau1372->pd_gpio)
818+
gpiod_set_value(adau1372->pd_gpio, 1);
819+
clk_disable_unprepare(adau1372->mclk);
820+
return ret;
821+
}
811822
clk_ctrl |= ADAU1372_CLK_CTRL_CLKSRC;
812823
}
813824

0 commit comments

Comments
 (0)