diff options
author | Heiko Carstens <hca@linux.ibm.com> | 2023-12-01 16:09:29 +0300 |
---|---|---|
committer | Alexander Gordeev <agordeev@linux.ibm.com> | 2023-12-11 16:33:04 +0300 |
commit | f88d36845391f8df8faa9d28818bfbdd67af0d91 (patch) | |
tree | d0104a336cffb02730484eaa2f61fd71cc5f906d /arch/s390/include/asm/ctlreg.h | |
parent | 207022d39d3b158ca3581e321212f799fa5e7e24 (diff) | |
download | linux-f88d36845391f8df8faa9d28818bfbdd67af0d91.tar.xz |
s390/ctlreg: return old register contents when changing bits
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>
Diffstat (limited to 'arch/s390/include/asm/ctlreg.h')
-rw-r--r-- | arch/s390/include/asm/ctlreg.h | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/arch/s390/include/asm/ctlreg.h b/arch/s390/include/asm/ctlreg.h index 6d4b85f2b541..72a9556d04f3 100644 --- a/arch/s390/include/asm/ctlreg.h +++ b/arch/s390/include/asm/ctlreg.h @@ -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.val |= 1UL << bit; - local_ctl_load(cr, ®); + 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.val &= ~(1UL << bit); - local_ctl_load(cr, ®); + local_ctl_store(cr, &old); + new = old; + new.val &= ~(1UL << bit); + local_ctl_load(cr, &new); + return old; } struct lowcore; |