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

Commit 997526f8 authored by Stephen Boyd's avatar Stephen Boyd Committed by Greg Kroah-Hartman
Browse files

clk: qcom: rpmh: Simplify clk_rpmh_bcm_send_cmd()



[ Upstream commit 2cf7a4cbcb4e108aae666dc6a81cedf69e1cba37 ]

This function has some duplication in unlocking a mutex and returns in a
few different places. Let's use some if statements to consolidate code
and make this a bit easier to read.

Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
CC: Taniya Das <tdas@codeaurora.org>
Signed-off-by: default avatarStephen Boyd <sboyd@kernel.org>
Link: https://lkml.kernel.org/r/20200309221232.145630-2-sboyd@kernel.org


Stable-dep-of: a4e5af27e6f6 ("clk: qcom: clk-rpmh: Fix overflow in BCM vote")
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 86c3f613
Loading
Loading
Loading
Loading
+14 −19
Original line number Diff line number Diff line
@@ -259,22 +259,18 @@ static int clk_rpmh_bcm_send_cmd(struct clk_rpmh *c, bool enable)
{
	struct tcs_cmd cmd = { 0 };
	u32 cmd_state;
	int ret;
	int ret = 0;

	mutex_lock(&rpmh_clk_lock);

	cmd_state = 0;
	if (enable) {
		cmd_state = 1;
		if (c->aggr_state)
			cmd_state = c->aggr_state;
	} else {
		cmd_state = 0;
	}

	if (c->last_sent_aggr_state == cmd_state) {
		mutex_unlock(&rpmh_clk_lock);
		return 0;
	}

	if (c->last_sent_aggr_state != cmd_state) {
		cmd.addr = c->res_addr;
		cmd.data = BCM_TCS_CMD(1, enable, 0, cmd_state);

@@ -282,15 +278,14 @@ static int clk_rpmh_bcm_send_cmd(struct clk_rpmh *c, bool enable)
		if (ret) {
			dev_err(c->dev, "set active state of %s failed: (%d)\n",
				c->res_name, ret);
		mutex_unlock(&rpmh_clk_lock);
		return ret;
	}

		} else {
			c->last_sent_aggr_state = cmd_state;
		}
	}

	mutex_unlock(&rpmh_clk_lock);

	return 0;
	return ret;
}

static int clk_rpmh_bcm_prepare(struct clk_hw *hw)