ASoC: arizona: Correct return value of arizona_is_enabled_fll

arizona_is_enabled_fll currently returns a bool, but can throw an error.
The error will be basically ignored and we will treat the FLL as already
on. This patch changes the return to be an int and adds error code to
propagate the error up to the callback.

Reported-by: Anil Kumar <anil.kumar@wolfsonmicro.com>
Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
This commit is contained in:
Charles Keepax 2014-07-09 17:41:47 +01:00 committed by Mark Brown
parent 613124ce64
commit c393aca94f
1 changed files with 16 additions and 10 deletions

View File

@ -1716,7 +1716,7 @@ static void arizona_apply_fll(struct arizona *arizona, unsigned int base,
ARIZONA_FLL1_CTRL_UPD | cfg->n); ARIZONA_FLL1_CTRL_UPD | cfg->n);
} }
static bool arizona_is_enabled_fll(struct arizona_fll *fll) static int arizona_is_enabled_fll(struct arizona_fll *fll)
{ {
struct arizona *arizona = fll->arizona; struct arizona *arizona = fll->arizona;
unsigned int reg; unsigned int reg;
@ -1732,13 +1732,17 @@ static bool arizona_is_enabled_fll(struct arizona_fll *fll)
return reg & ARIZONA_FLL1_ENA; return reg & ARIZONA_FLL1_ENA;
} }
static void arizona_enable_fll(struct arizona_fll *fll) static int arizona_enable_fll(struct arizona_fll *fll)
{ {
struct arizona *arizona = fll->arizona; struct arizona *arizona = fll->arizona;
int ret; int ret;
bool use_sync = false; bool use_sync = false;
int already_enabled = arizona_is_enabled_fll(fll);
struct arizona_fll_cfg cfg; struct arizona_fll_cfg cfg;
if (already_enabled < 0)
return already_enabled;
/* /*
* If we have both REFCLK and SYNCCLK then enable both, * If we have both REFCLK and SYNCCLK then enable both,
* otherwise apply the SYNCCLK settings to REFCLK. * otherwise apply the SYNCCLK settings to REFCLK.
@ -1766,7 +1770,7 @@ static void arizona_enable_fll(struct arizona_fll *fll)
ARIZONA_FLL1_SYNC_ENA, 0); ARIZONA_FLL1_SYNC_ENA, 0);
} else { } else {
arizona_fll_err(fll, "No clocks provided\n"); arizona_fll_err(fll, "No clocks provided\n");
return; return -EINVAL;
} }
/* /*
@ -1781,7 +1785,7 @@ static void arizona_enable_fll(struct arizona_fll *fll)
ARIZONA_FLL1_SYNC_BW, ARIZONA_FLL1_SYNC_BW,
ARIZONA_FLL1_SYNC_BW); ARIZONA_FLL1_SYNC_BW);
if (!arizona_is_enabled_fll(fll)) if (!already_enabled)
pm_runtime_get(arizona->dev); pm_runtime_get(arizona->dev);
/* Clear any pending completions */ /* Clear any pending completions */
@ -1800,6 +1804,8 @@ static void arizona_enable_fll(struct arizona_fll *fll)
msecs_to_jiffies(250)); msecs_to_jiffies(250));
if (ret == 0) if (ret == 0)
arizona_fll_warn(fll, "Timed out waiting for lock\n"); arizona_fll_warn(fll, "Timed out waiting for lock\n");
return 0;
} }
static void arizona_disable_fll(struct arizona_fll *fll) static void arizona_disable_fll(struct arizona_fll *fll)
@ -1821,7 +1827,7 @@ static void arizona_disable_fll(struct arizona_fll *fll)
int arizona_set_fll_refclk(struct arizona_fll *fll, int source, int arizona_set_fll_refclk(struct arizona_fll *fll, int source,
unsigned int Fref, unsigned int Fout) unsigned int Fref, unsigned int Fout)
{ {
int ret; int ret = 0;
if (fll->ref_src == source && fll->ref_freq == Fref) if (fll->ref_src == source && fll->ref_freq == Fref)
return 0; return 0;
@ -1836,17 +1842,17 @@ int arizona_set_fll_refclk(struct arizona_fll *fll, int source,
fll->ref_freq = Fref; fll->ref_freq = Fref;
if (fll->fout && Fref > 0) { if (fll->fout && Fref > 0) {
arizona_enable_fll(fll); ret = arizona_enable_fll(fll);
} }
return 0; return ret;
} }
EXPORT_SYMBOL_GPL(arizona_set_fll_refclk); EXPORT_SYMBOL_GPL(arizona_set_fll_refclk);
int arizona_set_fll(struct arizona_fll *fll, int source, int arizona_set_fll(struct arizona_fll *fll, int source,
unsigned int Fref, unsigned int Fout) unsigned int Fref, unsigned int Fout)
{ {
int ret; int ret = 0;
if (fll->sync_src == source && if (fll->sync_src == source &&
fll->sync_freq == Fref && fll->fout == Fout) fll->sync_freq == Fref && fll->fout == Fout)
@ -1869,11 +1875,11 @@ int arizona_set_fll(struct arizona_fll *fll, int source,
fll->fout = Fout; fll->fout = Fout;
if (Fout) if (Fout)
arizona_enable_fll(fll); ret = arizona_enable_fll(fll);
else else
arizona_disable_fll(fll); arizona_disable_fll(fll);
return 0; return ret;
} }
EXPORT_SYMBOL_GPL(arizona_set_fll); EXPORT_SYMBOL_GPL(arizona_set_fll);