Commit f88d3684 authored by Heiko Carstens's avatar Heiko Carstens Committed by Alexander Gordeev

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: default avatarAlexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
Signed-off-by: default avatarAlexander Gordeev <agordeev@linux.ibm.com>
parent 207022d3
...@@ -141,22 +141,26 @@ static __always_inline void local_ctl_store(unsigned int cr, struct ctlreg *reg) ...@@ -141,22 +141,26 @@ static __always_inline void local_ctl_store(unsigned int cr, struct ctlreg *reg)
: [cr] "i" (cr)); : [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); local_ctl_store(cr, &old);
reg.val |= 1UL << bit; new = old;
local_ctl_load(cr, &reg); 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); local_ctl_store(cr, &old);
reg.val &= ~(1UL << bit); new = old;
local_ctl_load(cr, &reg); new.val &= ~(1UL << bit);
local_ctl_load(cr, &new);
return old;
} }
struct lowcore; struct lowcore;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment