s390/ctlreg: cleanup inline assemblies
authorHeiko Carstens <hca@linux.ibm.com>
Mon, 11 Sep 2023 19:39:57 +0000 (21:39 +0200)
committerVasily Gorbik <gor@linux.ibm.com>
Tue, 19 Sep 2023 11:26:56 +0000 (13:26 +0200)
Use symbolic names for operands, remove typedefs, and slightly
refactor the code.

Reviewed-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
arch/s390/include/asm/ctlreg.h

index 25b955db899861443db685e0638931f1cba02767..0b55a1bb3113ad25ce3ab7ba6d1086b39f98fbc3 100644 (file)
 #include <linux/bug.h>
 
 #define __ctl_load(array, low, high) do {                              \
-       typedef struct { char _[sizeof(array)]; } addrtype;             \
+       struct addrtype {                                               \
+               char _[sizeof(array)];                                  \
+       };                                                              \
+       int _high = high;                                               \
+       int _low = low;                                                 \
+       int _esize;                                                     \
                                                                        \
-       BUILD_BUG_ON(sizeof(addrtype) != (high - low + 1) * sizeof(long));\
+       _esize = (_high - _low + 1) * sizeof(unsigned long);            \
+       BUILD_BUG_ON(sizeof(struct addrtype) != _esize);                \
        asm volatile(                                                   \
-               "       lctlg   %1,%2,%0\n"                             \
+               "       lctlg   %[_low],%[_high],%[_arr]\n"             \
                :                                                       \
-               : "Q" (*(addrtype *)(&array)), "i" (low), "i" (high)    \
+               : [_arr] "Q" (*(struct addrtype *)(&array)),            \
+                 [_low] "i" (low), [_high] "i" (high)                  \
                : "memory");                                            \
 } while (0)
 
 #define __ctl_store(array, low, high) do {                             \
-       typedef struct { char _[sizeof(array)]; } addrtype;             \
+       struct addrtype {                                               \
+               char _[sizeof(array)];                                  \
+       };                                                              \
+       int _high = high;                                               \
+       int _low = low;                                                 \
+       int _esize;                                                     \
                                                                        \
-       BUILD_BUG_ON(sizeof(addrtype) != (high - low + 1) * sizeof(long));\
+       _esize = (_high - _low + 1) * sizeof(unsigned long);            \
+       BUILD_BUG_ON(sizeof(struct addrtype) != _esize);                \
        asm volatile(                                                   \
-               "       stctg   %1,%2,%0\n"                             \
-               : "=Q" (*(addrtype *)(&array))                          \
-               : "i" (low), "i" (high));                               \
+               "       stctg   %[_low],%[_high],%[_arr]\n"             \
+               : [_arr] "=Q" (*(struct addrtype *)(&array))            \
+               : [_low] "i" (low), [_high] "i" (high));                \
 } while (0)
 
 static __always_inline void __ctl_set_bit(unsigned int cr, unsigned int bit)