arm64: sysreg: Generate C compiler warnings on {read,write}_sysreg_s arguments
[platform/kernel/linux-starfive.git] / arch / arm64 / include / asm / sysreg.h
index b481935..16464bf 100644 (file)
 /*
  * For registers without architectural names, or simply unsupported by
  * GAS.
+ *
+ * __check_r forces warnings to be generated by the compiler when
+ * evaluating r which wouldn't normally happen due to being passed to
+ * the assembler via __stringify(r).
  */
 #define read_sysreg_s(r) ({                                            \
        u64 __val;                                                      \
+       u32 __maybe_unused __check_r = (u32)(r);                        \
        asm volatile(__mrs_s("%0", r) : "=r" (__val));                  \
        __val;                                                          \
 })
 
 #define write_sysreg_s(v, r) do {                                      \
        u64 __val = (u64)(v);                                           \
+       u32 __maybe_unused __check_r = (u32)(r);                        \
        asm volatile(__msr_s(r, "%x0") : : "rZ" (__val));               \
 } while (0)