clk: Document and simplify clk_core_get_rate_nolock()

This function uses a few gotos and doesn't explain why parents and
numbers of parents are being checked before returning different values
for the clk's rate. Document and simplify this function somewhat to make
this better.

Signed-off-by: Stephen Boyd <sboyd@kernel.org>
This commit is contained in:
Stephen Boyd 2019-02-01 15:39:50 -08:00
parent 7374faa92e
commit 73d4f945f6

View file

@ -345,23 +345,18 @@ unsigned int __clk_get_enable_count(struct clk *clk)
static unsigned long clk_core_get_rate_nolock(struct clk_core *core) static unsigned long clk_core_get_rate_nolock(struct clk_core *core)
{ {
unsigned long ret; if (!core)
return 0;
if (!core) { if (!core->num_parents || core->parent)
ret = 0; return core->rate;
goto out;
}
ret = core->rate; /*
* Clk must have a parent because num_parents > 0 but the parent isn't
if (!core->num_parents) * known yet. Best to return 0 as the rate of this clk until we can
goto out; * properly recalc the rate based on the parent's rate.
*/
if (!core->parent) return 0;
ret = 0;
out:
return ret;
} }
unsigned long clk_hw_get_rate(const struct clk_hw *hw) unsigned long clk_hw_get_rate(const struct clk_hw *hw)