arm64: sysreg: Generate C compiler warnings on {read,write}_sysreg_s arguments
authorJames Clark <james.clark@arm.com>
Tue, 15 Aug 2023 14:06:39 +0000 (15:06 +0100)
committerWill Deacon <will@kernel.org>
Wed, 16 Aug 2023 13:47:41 +0000 (14:47 +0100)
commit18b8f57a7f51b4c834e5e974ec38133c02e9eb58
treee3363f99ea0134d53d9684204118a8567d3ed7a6
parent5cd474e57368f0957c343bb21e309cf82826b1ef
arm64: sysreg: Generate C compiler warnings on {read,write}_sysreg_s arguments

Evaluate the register before the asm section so that the C compiler
generates warnings when there is an issue with the register argument.

This will prevent possible future issues such as the one seen here [1]
where a missing bracket caused the shift and addition operators to be
evaluated in the wrong order, but no warning was emitted. The GNU
assembler has no warning for when expressions evaluate differently to C
due to different operator precedence, but the C compiler has some
warnings that may suggest something is wrong. For example in this case
the following warning would have been emitted:

  error: operator '>>' has lower precedence than '+'; '+' will be evaluated first [-Werror,-Wshift-op-parentheses]

There are currently no existing warnings that need to be fixed.

[1]: https://lore.kernel.org/linux-perf-users/20230728162011.GA22050@willie-the-truck/

Signed-off-by: James Clark <james.clark@arm.com>
Link: https://lore.kernel.org/r/20230815140639.614769-1-james.clark@arm.com
Signed-off-by: Will Deacon <will@kernel.org>
arch/arm64/include/asm/sysreg.h