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

Commit 7f6e82d8 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "clk: msm: clock: Refactor the aggr_sibling_rates logic"

parents 218cb38d 025dce34
Loading
Loading
Loading
Loading
+36 −35
Original line number Diff line number Diff line
@@ -647,16 +647,17 @@ static int branch_clk_prepare(struct clk *c)
	unsigned long curr_rate;
	int ret = 0;

	if (!branch->aggr_sibling_rates)
		return ret;

	mutex_lock(&branch_clk_lock);
	branch->is_prepared = false;
	if (branch->aggr_sibling_rates) {
	curr_rate = branch_clk_aggregate_rate(c->parent);
	if (c->rate > curr_rate) {
		ret = clk_set_rate(c->parent, c->rate);
		if (ret)
			goto exit;
	}
	}
	branch->is_prepared = true;
exit:
	mutex_unlock(&branch_clk_lock);
@@ -699,14 +700,15 @@ static void branch_clk_unprepare(struct clk *c)
	struct branch_clk *branch = to_branch_clk(c);
	unsigned long curr_rate, new_rate;

	if (!branch->aggr_sibling_rates)
		return;

	mutex_lock(&branch_clk_lock);
	branch->is_prepared = false;
	if (branch->aggr_sibling_rates) {
	new_rate = branch_clk_aggregate_rate(c->parent);
	curr_rate = max(new_rate, c->rate);
	if (new_rate < curr_rate)
		clk_set_rate(c->parent, new_rate);
	}
	mutex_unlock(&branch_clk_lock);
}

@@ -764,8 +766,10 @@ static int branch_clk_set_rate(struct clk *c, unsigned long rate)
	if (branch->has_sibling)
		return -EPERM;

	if (!branch->aggr_sibling_rates)
		return clk_set_rate(c->parent, rate);

	mutex_lock(&branch_clk_lock);
	if (branch->aggr_sibling_rates) {
	if (!branch->is_prepared) {
		c->rate = rate;
		goto exit;
@@ -786,9 +790,6 @@ static int branch_clk_set_rate(struct clk *c, unsigned long rate)
		if (!ret)
			c->rate = rate;
	}
		goto exit;
	}
	ret = clk_set_rate(c->parent, rate);
exit:
	mutex_unlock(&branch_clk_lock);
	return ret;