Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

soc: qcom: Rework BCM_TCS_CMD macro

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>
Reviewed-by: Stephen Boyd <sboyd@kernel.org>
Link: https://lore.kernel.org/r/20241129142446.407443-1-eugen.hristev@linaro.org
Signed-off-by: Bjorn Andersson <andersson@kernel.org>

authored by

Eugen Hristev and committed by
Bjorn Andersson
2705bce5 9b01fc6b

+12 -14
+12 -14
include/soc/qcom/tcs.h
··· 6 6 #ifndef __SOC_QCOM_TCS_H__ 7 7 #define __SOC_QCOM_TCS_H__ 8 8 9 + #include <linux/bitfield.h> 10 + #include <linux/bits.h> 11 + 9 12 #define MAX_RPMH_PAYLOAD 16 10 13 11 14 /** ··· 63 60 struct tcs_cmd *cmds; 64 61 }; 65 62 66 - #define BCM_TCS_CMD_COMMIT_SHFT 30 67 - #define BCM_TCS_CMD_COMMIT_MASK 0x40000000 68 - #define BCM_TCS_CMD_VALID_SHFT 29 69 - #define BCM_TCS_CMD_VALID_MASK 0x20000000 70 - #define BCM_TCS_CMD_VOTE_X_SHFT 14 71 - #define BCM_TCS_CMD_VOTE_MASK 0x3fff 72 - #define BCM_TCS_CMD_VOTE_Y_SHFT 0 73 - #define BCM_TCS_CMD_VOTE_Y_MASK 0xfffc000 63 + #define BCM_TCS_CMD_COMMIT_MASK BIT(30) 64 + #define BCM_TCS_CMD_VALID_MASK BIT(29) 65 + #define BCM_TCS_CMD_VOTE_MASK GENMASK(13, 0) 66 + #define BCM_TCS_CMD_VOTE_Y_MASK GENMASK(13, 0) 67 + #define BCM_TCS_CMD_VOTE_X_MASK GENMASK(27, 14) 74 68 75 69 /* Construct a Bus Clock Manager (BCM) specific TCS command */ 76 70 #define BCM_TCS_CMD(commit, valid, vote_x, vote_y) \ 77 - (((commit) << BCM_TCS_CMD_COMMIT_SHFT) | \ 78 - ((valid) << BCM_TCS_CMD_VALID_SHFT) | \ 79 - ((cpu_to_le32(vote_x) & \ 80 - BCM_TCS_CMD_VOTE_MASK) << BCM_TCS_CMD_VOTE_X_SHFT) | \ 81 - ((cpu_to_le32(vote_y) & \ 82 - BCM_TCS_CMD_VOTE_MASK) << BCM_TCS_CMD_VOTE_Y_SHFT)) 71 + (u32_encode_bits(commit, BCM_TCS_CMD_COMMIT_MASK) | \ 72 + u32_encode_bits(valid, BCM_TCS_CMD_VALID_MASK) | \ 73 + u32_encode_bits(vote_x, BCM_TCS_CMD_VOTE_X_MASK) | \ 74 + u32_encode_bits(vote_y, BCM_TCS_CMD_VOTE_Y_MASK)) 83 75 84 76 #endif /* __SOC_QCOM_TCS_H__ */