s390/ctlreg: return old register contents when changing bits
authorHeiko Carstens <hca@linux.ibm.com>
Fri, 1 Dec 2023 13:09:29 +0000 (14:09 +0100)
committerAlexander Gordeev <agordeev@linux.ibm.com>
Mon, 11 Dec 2023 13:33:04 +0000 (14:33 +0100)
Change local_ctl_set_bit() and local_ctl_clear_bit() so they return the
previous value of the to be changed control register. This is useful if a
bit is only changed temporarily and the previous content needs to be
restored.

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

index 6d4b85f2b541c6d9482222abe9d573d08d7d7f8e..72a9556d04f3b04e40ee01be2d77c028f005041d 100644 (file)
@@ -141,22 +141,26 @@ static __always_inline void local_ctl_store(unsigned int cr, struct ctlreg *reg)
                : [cr] "i" (cr));
 }
 
-static __always_inline void local_ctl_set_bit(unsigned int cr, unsigned int bit)
+static __always_inline struct ctlreg local_ctl_set_bit(unsigned int cr, unsigned int bit)
 {
-       struct ctlreg reg;
+       struct ctlreg new, old;
 
-       local_ctl_store(cr, &reg);
-       reg.val |= 1UL << bit;
-       local_ctl_load(cr, &reg);
+       local_ctl_store(cr, &old);
+       new = old;
+       new.val |= 1UL << bit;
+       local_ctl_load(cr, &new);
+       return old;
 }
 
-static __always_inline void local_ctl_clear_bit(unsigned int cr, unsigned int bit)
+static __always_inline struct ctlreg local_ctl_clear_bit(unsigned int cr, unsigned int bit)
 {
-       struct ctlreg reg;
+       struct ctlreg new, old;
 
-       local_ctl_store(cr, &reg);
-       reg.val &= ~(1UL << bit);
-       local_ctl_load(cr, &reg);
+       local_ctl_store(cr, &old);
+       new = old;
+       new.val &= ~(1UL << bit);
+       local_ctl_load(cr, &new);
+       return old;
 }
 
 struct lowcore;