Powerpc arch_cmpxchg() wrapper macros cast arguments to
'unsigned long' before calling the functions implementing the
operation. Some type annotations (e.g. __bitwise) generate
sparse warnings like:

  block/blk-crypto-fallback.c:164:17: warning: cast from restricted blk_status_t
  block/blk-crypto-fallback.c:164:17: warning: cast to restricted blk_status_t

Force casting in the macros to avoid the warnings:

Reported-by: kernel test robot <[email protected]>
Closes: 
https://lore.kernel.org/oe-kbuild-all/[email protected]/
Signed-off-by: Christophe Leroy (CS GROUP) <[email protected]>
---
 arch/powerpc/include/asm/cmpxchg.h | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/arch/powerpc/include/asm/cmpxchg.h 
b/arch/powerpc/include/asm/cmpxchg.h
index dbb50c06f0bf..7264e33ef877 100644
--- a/arch/powerpc/include/asm/cmpxchg.h
+++ b/arch/powerpc/include/asm/cmpxchg.h
@@ -700,8 +700,9 @@ __cmpxchg_acquire(void *ptr, unsigned long old, unsigned 
long new,
   ({                                                                    \
      __typeof__(*(ptr)) _o_ = (o);                                      \
      __typeof__(*(ptr)) _n_ = (n);                                      \
-     (__typeof__(*(ptr))) __cmpxchg((ptr), (unsigned long)_o_,          \
-                                   (unsigned long)_n_, sizeof(*(ptr))); \
+     (__force __typeof__(*(ptr)))                                       \
+       __cmpxchg((ptr), (__force unsigned long)_o_,                     \
+                 (__force unsigned long)_n_, sizeof(*(ptr)));           \
   })
 
 
@@ -709,26 +710,27 @@ __cmpxchg_acquire(void *ptr, unsigned long old, unsigned 
long new,
   ({                                                                    \
      __typeof__(*(ptr)) _o_ = (o);                                      \
      __typeof__(*(ptr)) _n_ = (n);                                      \
-     (__typeof__(*(ptr))) __cmpxchg_local((ptr), (unsigned long)_o_,    \
-                                   (unsigned long)_n_, sizeof(*(ptr))); \
+     (__force __typeof__(*(ptr)))                                       \
+       __cmpxchg_local((ptr), (__force unsigned long)_o_,               \
+                       (__force unsigned long)_n_, sizeof(*(ptr)));     \
   })
 
 #define arch_cmpxchg_relaxed(ptr, o, n)                                        
\
 ({                                                                     \
        __typeof__(*(ptr)) _o_ = (o);                                   \
        __typeof__(*(ptr)) _n_ = (n);                                   \
-       (__typeof__(*(ptr))) __cmpxchg_relaxed((ptr),                   \
-                       (unsigned long)_o_, (unsigned long)_n_,         \
-                       sizeof(*(ptr)));                                \
+       (__force __typeof__(*(ptr)))                                    \
+         __cmpxchg_relaxed((ptr), (__force unsigned long)_o_,          \
+                           (__force unsigned long)_n_, sizeof(*(ptr)));\
 })
 
 #define arch_cmpxchg_acquire(ptr, o, n)                                        
\
 ({                                                                     \
        __typeof__(*(ptr)) _o_ = (o);                                   \
        __typeof__(*(ptr)) _n_ = (n);                                   \
-       (__typeof__(*(ptr))) __cmpxchg_acquire((ptr),                   \
-                       (unsigned long)_o_, (unsigned long)_n_,         \
-                       sizeof(*(ptr)));                                \
+       (__force __typeof__(*(ptr)))                                    \
+         __cmpxchg_acquire((ptr), (__force unsigned long)_o_,          \
+                           (__force unsigned long)_n_, sizeof(*(ptr)));\
 })
 #ifdef CONFIG_PPC64
 #define arch_cmpxchg64(ptr, o, n)                                      \
-- 
2.54.0


Reply via email to