mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 20:54:03 +02:00
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: 6cd4c6459e ("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>
This commit is contained in:
parent
326fe8104a
commit
bfe6a264ef
|
|
@ -762,7 +762,7 @@ static int adau1372_startup(struct snd_pcm_substream *substream, struct snd_soc_
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void adau1372_enable_pll(struct adau1372 *adau1372)
|
static int adau1372_enable_pll(struct adau1372 *adau1372)
|
||||||
{
|
{
|
||||||
unsigned int val, timeout = 0;
|
unsigned int val, timeout = 0;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
@ -778,8 +778,12 @@ static void adau1372_enable_pll(struct adau1372 *adau1372)
|
||||||
timeout++;
|
timeout++;
|
||||||
} while (!(val & 1) && timeout < 3);
|
} while (!(val & 1) && timeout < 3);
|
||||||
|
|
||||||
if (ret < 0 || !(val & 1))
|
if (ret < 0 || !(val & 1)) {
|
||||||
dev_err(adau1372->dev, "Failed to lock PLL\n");
|
dev_err(adau1372->dev, "Failed to lock PLL\n");
|
||||||
|
return ret < 0 ? ret : -ETIMEDOUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int adau1372_set_power(struct adau1372 *adau1372, bool enable)
|
static int adau1372_set_power(struct adau1372 *adau1372, bool enable)
|
||||||
|
|
@ -807,7 +811,14 @@ static int adau1372_set_power(struct adau1372 *adau1372, bool enable)
|
||||||
* accessed.
|
* accessed.
|
||||||
*/
|
*/
|
||||||
if (adau1372->use_pll) {
|
if (adau1372->use_pll) {
|
||||||
adau1372_enable_pll(adau1372);
|
ret = adau1372_enable_pll(adau1372);
|
||||||
|
if (ret) {
|
||||||
|
regcache_cache_only(adau1372->regmap, true);
|
||||||
|
if (adau1372->pd_gpio)
|
||||||
|
gpiod_set_value(adau1372->pd_gpio, 1);
|
||||||
|
clk_disable_unprepare(adau1372->mclk);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
clk_ctrl |= ADAU1372_CLK_CTRL_CLKSRC;
|
clk_ctrl |= ADAU1372_CLK_CTRL_CLKSRC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user