Skip to contentSkip to conversation

soc: qcom: rpmh: Use __fill_rpmh_msg API during rpmh_write()

PATCH RESEND Applied Maulik Shah 3 participants 3 messages Nov 26, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 soc: qcom: rpmh: Use __fill_rpmh_msg API during rpmh_write()

Use __fill_rpmh_msg API during rpmh_write(). This allows to remove duplication of code in error checking, copying commands and setting message state.

---
 drivers/soc/qcom/rpmh.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/soc/qcom/rpmh.c +3 -9
index ad1f062..01765ee 100644
@@ -181,8 +181,6 @@ static int __rpmh_write(const struct device *dev, enum rpmh_state state,
 	struct cache_req *req;
 	int i;
 
-	rpm_msg->msg.state = state;
-
 	/* Cache the request in our store and link the payload */
 	for (i = 0; i < rpm_msg->msg.num_cmds; i++) {
 		req = cache_rpm_request(ctrlr, state, &rpm_msg->msg.cmds[i]);
@@ -190,8 +188,6 @@ static int __rpmh_write(const struct device *dev, enum rpmh_state state,
 			return PTR_ERR(req);
 	}
 
-	rpm_msg->msg.state = state;
-
 	if (state == RPMH_ACTIVE_ONLY_STATE) {
 		WARN_ON(irqs_disabled());
 		ret = rpmh_rsc_send_data(ctrlr_to_drv(ctrlr), &rpm_msg->msg);
@@ -268,11 +264,9 @@ int rpmh_write(const struct device *dev, enum rpmh_state state,
 	DEFINE_RPMH_MSG_ONSTACK(dev, state, &compl, rpm_msg);
 	int ret;
 
-	if (!cmd || !n || n > MAX_RPMH_PAYLOAD)
-		return -EINVAL;
-
-	memcpy(rpm_msg.cmd, cmd, n * sizeof(*cmd));
-	rpm_msg.msg.num_cmds = n;
+	ret = __fill_rpmh_msg(&rpm_msg, state, cmd, n);
+	if (ret)
+		return ret;
 
 	ret = __rpmh_write(dev, state, &rpm_msg);
 	if (ret)
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Maulik Shah

Use __fill_rpmh_msg API during rpmh_write(). This allows to remove duplication of code in error checking, copying commands and setting message state.

Quoted 46 lines
---
 drivers/soc/qcom/rpmh.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/soc/qcom/rpmh.c +3 -9
index ad1f062..01765ee 100644
@@ -181,8 +181,6 @@ static int __rpmh_write(const struct device *dev, enum rpmh_state state,
 	struct cache_req *req;
 	int i;
 
-	rpm_msg->msg.state = state;
-
 	/* Cache the request in our store and link the payload */
 	for (i = 0; i < rpm_msg->msg.num_cmds; i++) {
 		req = cache_rpm_request(ctrlr, state, &rpm_msg->msg.cmds[i]);
@@ -190,8 +188,6 @@ static int __rpmh_write(const struct device *dev, enum rpmh_state state,
 			return PTR_ERR(req);
 	}
 
-	rpm_msg->msg.state = state;
-
 	if (state == RPMH_ACTIVE_ONLY_STATE) {
 		WARN_ON(irqs_disabled());
 		ret = rpmh_rsc_send_data(ctrlr_to_drv(ctrlr), &rpm_msg->msg);
@@ -268,11 +264,9 @@ int rpmh_write(const struct device *dev, enum rpmh_state state,
 	DEFINE_RPMH_MSG_ONSTACK(dev, state, &compl, rpm_msg);
 	int ret;
 
-	if (!cmd || !n || n > MAX_RPMH_PAYLOAD)
-		return -EINVAL;
-
-	memcpy(rpm_msg.cmd, cmd, n * sizeof(*cmd));
-	rpm_msg.msg.num_cmds = n;
+	ret = __fill_rpmh_msg(&rpm_msg, state, cmd, n);
+	if (ret)
+		return ret;
 
 	ret = __rpmh_write(dev, state, &rpm_msg);
 	if (ret)
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#2 lore raw
In reply to Maulik Shah
This patch was applied to qcom/linux.git (refs/heads/for-next):

Hello:

This patch was applied to qcom/linux.git (refs/heads/for-next):

Quoted 8 lines · On Thu, 26 Nov 2020 14:01:30 +0530 you wrote:

Use __fill_rpmh_msg API during rpmh_write(). This allows to remove duplication of code in error checking, copying commands and setting message state.

---
 drivers/soc/qcom/rpmh.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

Here is the summary with links:
- [RESEND] soc: qcom: rpmh: Use __fill_rpmh_msg API during rpmh_write()

    https://git.kernel.org/qcom/c/0924dad5d458

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html