* [PATCH v4] soc: qcom: Rework BCM_TCS_CMD macro
@ 2024-11-29 14:24 Eugen Hristev
2024-12-17 19:40 ` Stephen Boyd
2024-12-26 18:26 ` Bjorn Andersson
0 siblings, 2 replies; 3+ messages in thread
From: Eugen Hristev @ 2024-11-29 14:24 UTC (permalink / raw)
To: linux-arm-msm, sboyd
Cc: linux-clk, linux-kernel, linux-pm, konradybcio, andersson,
evgreen, Eugen Hristev
Reworked BCM_TCS_CMD macro in order to fix warnings from sparse:
drivers/clk/qcom/clk-rpmh.c:270:28: warning: restricted __le32 degrades to integer
drivers/clk/qcom/clk-rpmh.c:270:28: warning: restricted __le32 degrades to integer
While at it, used u32_encode_bits which made the code easier to
follow and removed unnecessary shift definitions.
The use of cpu_to_le32 was wrong and thus removed.
Signed-off-by: Eugen Hristev <eugen.hristev@linaro.org>
---
Changes in v4:
- as per Stephen Boyd, removed cpu_to_le32 being wrong.
Changes in v3:
- align the macro lines better
Changes in v2:
- use le32_encode_bits instead of u32_encode_bits with a cpu_to_le32 on
the fields; this however ment we need to force cast the le32 to the
u32 container.
include/soc/qcom/tcs.h | 26 ++++++++++++--------------
1 file changed, 12 insertions(+), 14 deletions(-)
diff --git a/include/soc/qcom/tcs.h b/include/soc/qcom/tcs.h
index 3acca067c72b..cff67ce25488 100644
--- a/include/soc/qcom/tcs.h
+++ b/include/soc/qcom/tcs.h
@@ -6,6 +6,9 @@
#ifndef __SOC_QCOM_TCS_H__
#define __SOC_QCOM_TCS_H__
+#include <linux/bitfield.h>
+#include <linux/bits.h>
+
#define MAX_RPMH_PAYLOAD 16
/**
@@ -60,22 +63,17 @@ struct tcs_request {
struct tcs_cmd *cmds;
};
-#define BCM_TCS_CMD_COMMIT_SHFT 30
-#define BCM_TCS_CMD_COMMIT_MASK 0x40000000
-#define BCM_TCS_CMD_VALID_SHFT 29
-#define BCM_TCS_CMD_VALID_MASK 0x20000000
-#define BCM_TCS_CMD_VOTE_X_SHFT 14
-#define BCM_TCS_CMD_VOTE_MASK 0x3fff
-#define BCM_TCS_CMD_VOTE_Y_SHFT 0
-#define BCM_TCS_CMD_VOTE_Y_MASK 0xfffc000
+#define BCM_TCS_CMD_COMMIT_MASK BIT(30)
+#define BCM_TCS_CMD_VALID_MASK BIT(29)
+#define BCM_TCS_CMD_VOTE_MASK GENMASK(13, 0)
+#define BCM_TCS_CMD_VOTE_Y_MASK GENMASK(13, 0)
+#define BCM_TCS_CMD_VOTE_X_MASK GENMASK(27, 14)
/* Construct a Bus Clock Manager (BCM) specific TCS command */
#define BCM_TCS_CMD(commit, valid, vote_x, vote_y) \
- (((commit) << BCM_TCS_CMD_COMMIT_SHFT) | \
- ((valid) << BCM_TCS_CMD_VALID_SHFT) | \
- ((cpu_to_le32(vote_x) & \
- BCM_TCS_CMD_VOTE_MASK) << BCM_TCS_CMD_VOTE_X_SHFT) | \
- ((cpu_to_le32(vote_y) & \
- BCM_TCS_CMD_VOTE_MASK) << BCM_TCS_CMD_VOTE_Y_SHFT))
+ (u32_encode_bits(commit, BCM_TCS_CMD_COMMIT_MASK) | \
+ u32_encode_bits(valid, BCM_TCS_CMD_VALID_MASK) | \
+ u32_encode_bits(vote_x, BCM_TCS_CMD_VOTE_X_MASK) | \
+ u32_encode_bits(vote_y, BCM_TCS_CMD_VOTE_Y_MASK))
#endif /* __SOC_QCOM_TCS_H__ */
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v4] soc: qcom: Rework BCM_TCS_CMD macro
2024-11-29 14:24 [PATCH v4] soc: qcom: Rework BCM_TCS_CMD macro Eugen Hristev
@ 2024-12-17 19:40 ` Stephen Boyd
2024-12-26 18:26 ` Bjorn Andersson
1 sibling, 0 replies; 3+ messages in thread
From: Stephen Boyd @ 2024-12-17 19:40 UTC (permalink / raw)
To: Eugen Hristev, linux-arm-msm
Cc: linux-clk, linux-kernel, linux-pm, konradybcio, andersson,
evgreen, Eugen Hristev
Quoting Eugen Hristev (2024-11-29 06:24:46)
> Reworked BCM_TCS_CMD macro in order to fix warnings from sparse:
>
> drivers/clk/qcom/clk-rpmh.c:270:28: warning: restricted __le32 degrades to integer
> drivers/clk/qcom/clk-rpmh.c:270:28: warning: restricted __le32 degrades to integer
>
> While at it, used u32_encode_bits which made the code easier to
> follow and removed unnecessary shift definitions.
>
> The use of cpu_to_le32 was wrong and thus removed.
>
> Signed-off-by: Eugen Hristev <eugen.hristev@linaro.org>
> ---
Thanks
Reviewed-by: Stephen Boyd <sboyd@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v4] soc: qcom: Rework BCM_TCS_CMD macro
2024-11-29 14:24 [PATCH v4] soc: qcom: Rework BCM_TCS_CMD macro Eugen Hristev
2024-12-17 19:40 ` Stephen Boyd
@ 2024-12-26 18:26 ` Bjorn Andersson
1 sibling, 0 replies; 3+ messages in thread
From: Bjorn Andersson @ 2024-12-26 18:26 UTC (permalink / raw)
To: linux-arm-msm, sboyd, Eugen Hristev
Cc: linux-clk, linux-kernel, linux-pm, konradybcio, evgreen
On Fri, 29 Nov 2024 16:24:46 +0200, Eugen Hristev wrote:
> Reworked BCM_TCS_CMD macro in order to fix warnings from sparse:
>
> drivers/clk/qcom/clk-rpmh.c:270:28: warning: restricted __le32 degrades to integer
> drivers/clk/qcom/clk-rpmh.c:270:28: warning: restricted __le32 degrades to integer
>
> While at it, used u32_encode_bits which made the code easier to
> follow and removed unnecessary shift definitions.
>
> [...]
Applied, thanks!
[1/1] soc: qcom: Rework BCM_TCS_CMD macro
commit: 2705bce5b4c45e2a0a354ec4df937d2803241cd8
Best regards,
--
Bjorn Andersson <andersson@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-12-26 18:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-29 14:24 [PATCH v4] soc: qcom: Rework BCM_TCS_CMD macro Eugen Hristev
2024-12-17 19:40 ` Stephen Boyd
2024-12-26 18:26 ` Bjorn Andersson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox