]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
s390/sysinfo: Cleanup stsi() inline assembly
authorHeiko Carstens <hca@linux.ibm.com>
Fri, 7 Feb 2025 14:49:05 +0000 (15:49 +0100)
committerVasily Gorbik <gor@linux.ibm.com>
Tue, 4 Mar 2025 16:18:07 +0000 (17:18 +0100)
Merge stsi() and __stsi() and cleanup the inline assembly. This involves
making use of the flag output constraint. Semantically the result is
identical to before.

Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
arch/s390/kernel/sysinfo.c

index a592f9509ce874fc909ed556ae3039fb779bfa9c..6c5baff46f91e64b7cba034686b91226fa288ff2 100644 (file)
 #include <asm/cpcmd.h>
 #include <asm/topology.h>
 #include <asm/fpu.h>
+#include <asm/asm.h>
 
 int topology_max_mnest;
 
-static inline int __stsi(void *sysinfo, int fc, int sel1, int sel2, int *lvl)
-{
-       int r0 = (fc << 28) | sel1;
-       int rc = 0;
-
-       asm volatile(
-               "       lr      0,%[r0]\n"
-               "       lr      1,%[r1]\n"
-               "       stsi    0(%[sysinfo])\n"
-               "       jz      0f\n"
-               "       lhi     %[rc],%[retval]\n"
-               "0:     lr      %[r0],0\n"
-               : [r0] "+d" (r0), [rc] "+d" (rc)
-               : [r1] "d" (sel2),
-                 [sysinfo] "a" (sysinfo),
-                 [retval] "K" (-EOPNOTSUPP)
-               : "cc", "0", "1", "memory");
-       *lvl = ((unsigned int) r0) >> 28;
-       return rc;
-}
-
 /*
  * stsi - store system information
  *
@@ -54,12 +34,21 @@ static inline int __stsi(void *sysinfo, int fc, int sel1, int sel2, int *lvl)
  */
 int stsi(void *sysinfo, int fc, int sel1, int sel2)
 {
-       int lvl, rc;
+       int r0 = (fc << 28) | sel1;
+       int cc;
 
-       rc = __stsi(sysinfo, fc, sel1, sel2, &lvl);
-       if (rc)
-               return rc;
-       return fc ? 0 : lvl;
+       asm volatile(
+               "       lr      %%r0,%[r0]\n"
+               "       lr      %%r1,%[r1]\n"
+               "       stsi    %[sysinfo]\n"
+               "       lr      %[r0],%%r0\n"
+               CC_IPM(cc)
+               : CC_OUT(cc, cc), [r0] "+d" (r0), [sysinfo] "=Q" (*(char *)sysinfo)
+               : [r1] "d" (sel2)
+               : CC_CLOBBER_LIST("0", "1", "memory"));
+       if (cc == 3)
+               return -EOPNOTSUPP;
+       return fc ? 0 : (unsigned int)r0 >> 28;
 }
 EXPORT_SYMBOL(stsi);