Message ID | bf5c566bd4c2adf0518a9785627bdc5f12a7187b.1726242605.git.oleksii.kurochko@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | device tree mapping | expand |
On 13.09.2024 17:57, Oleksii Kurochko wrote: > Update the defintion of write_atomic() to support non-scalar types, > aligning it with the behavior of read_atomic(). "Aligning" would imo imply yet more similarity. Types are different, names are different. How about "bringing it closer to"? > --- a/xen/arch/riscv/include/asm/atomic.h > +++ b/xen/arch/riscv/include/asm/atomic.h > @@ -69,10 +69,11 @@ static always_inline void _write_atomic(volatile void *p, > } > } > > -#define write_atomic(p, x) \ > -({ \ > - typeof(*(p)) x_ = (x); \ > - _write_atomic(p, x_, sizeof(*(p))); \ > +#define write_atomic(p, x) \ > +({ \ > + union { typeof(*(p)) v; unsigned long v_ul; } x_ = { .v_ul = 0UL }; \ > + x_.v = (x); \ > + _write_atomic(p, x_.v_ul, sizeof(*(p))); \ v_ul is an odd name for my taste. Why not just ul, which is closer to read_atomic()'s c? Preferably with the adjustments (which I guess could be done while committing, so long as you agree) Acked-by: Jan Beulich <jbeulich@suse.com> Jan
On Mon, 2024-09-16 at 08:25 +0200, Jan Beulich wrote: > On 13.09.2024 17:57, Oleksii Kurochko wrote: > > Update the defintion of write_atomic() to support non-scalar types, > > aligning it with the behavior of read_atomic(). > > "Aligning" would imo imply yet more similarity. Types are different, > names are different. How about "bringing it closer to"? > > > --- a/xen/arch/riscv/include/asm/atomic.h > > +++ b/xen/arch/riscv/include/asm/atomic.h > > @@ -69,10 +69,11 @@ static always_inline void > > _write_atomic(volatile void *p, > > } > > } > > > > -#define write_atomic(p, x) \ > > -({ \ > > - typeof(*(p)) x_ = (x); \ > > - _write_atomic(p, x_, sizeof(*(p))); \ > > +#define write_atomic(p, > > x) \ > > +({ > > \ > > + union { typeof(*(p)) v; unsigned long v_ul; } x_ = { .v_ul = > > 0UL }; \ > > + x_.v = > > (x); \ > > + _write_atomic(p, x_.v_ul, > > sizeof(*(p))); \ > > v_ul is an odd name for my taste. Why not just ul, which is closer to > read_atomic()'s c? Preferably with the adjustments (which I guess > could > be done while committing, so long as you agree) I will be happy with that. > Acked-by: Jan Beulich <jbeulich@suse.com> Thanks. ~ Oleksii
diff --git a/xen/arch/riscv/include/asm/atomic.h b/xen/arch/riscv/include/asm/atomic.h index 95910ebfeb..e2dbb391f0 100644 --- a/xen/arch/riscv/include/asm/atomic.h +++ b/xen/arch/riscv/include/asm/atomic.h @@ -69,10 +69,11 @@ static always_inline void _write_atomic(volatile void *p, } } -#define write_atomic(p, x) \ -({ \ - typeof(*(p)) x_ = (x); \ - _write_atomic(p, x_, sizeof(*(p))); \ +#define write_atomic(p, x) \ +({ \ + union { typeof(*(p)) v; unsigned long v_ul; } x_ = { .v_ul = 0UL }; \ + x_.v = (x); \ + _write_atomic(p, x_.v_ul, sizeof(*(p))); \ }) static always_inline void _add_sized(volatile void *p,
Update the defintion of write_atomic() to support non-scalar types, aligning it with the behavior of read_atomic(). Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com> --- Changes in V7: - use union in definition of write_atomic() to add support of non-scalar types. --- Changes in v6: - new patch. --- xen/arch/riscv/include/asm/atomic.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)