Commit 0c133dd00ed84aefc41af2cc70e6560a61c95c89

Authored by Linus Torvalds

Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/borntraeger/linux

Pull WRITE_ONCE argument order change from Christian Borntraeger:
 "As discussed on LKML[1] it was agreed that WRITE_ONCE(x, val) is
  better than ASSIGN_ONCE(val, x)

  Lets change that for 3.19 as 3.19 has no user yet, but the first users
  will hit linux-next soon"

[1] http://marc.info/?l=linux-kernel&m=142081181707596

* tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/borntraeger/linux:
  kernel: Change ASSIGN_ONCE(val, x) to WRITE_ONCE(x, val)

Showing 1 changed file Side-by-side Diff

include/linux/compiler.h
... ... @@ -215,7 +215,7 @@
215 215 }
216 216 }
217 217  
218   -static __always_inline void __assign_once_size(volatile void *p, void *res, int size)
  218 +static __always_inline void __write_once_size(volatile void *p, void *res, int size)
219 219 {
220 220 switch (size) {
221 221 case 1: *(volatile __u8 *)p = *(__u8 *)res; break;
222 222  
223 223  
... ... @@ -235,15 +235,15 @@
235 235 /*
236 236 * Prevent the compiler from merging or refetching reads or writes. The
237 237 * compiler is also forbidden from reordering successive instances of
238   - * READ_ONCE, ASSIGN_ONCE and ACCESS_ONCE (see below), but only when the
  238 + * READ_ONCE, WRITE_ONCE and ACCESS_ONCE (see below), but only when the
239 239 * compiler is aware of some particular ordering. One way to make the
240 240 * compiler aware of ordering is to put the two invocations of READ_ONCE,
241   - * ASSIGN_ONCE or ACCESS_ONCE() in different C statements.
  241 + * WRITE_ONCE or ACCESS_ONCE() in different C statements.
242 242 *
243 243 * In contrast to ACCESS_ONCE these two macros will also work on aggregate
244 244 * data types like structs or unions. If the size of the accessed data
245 245 * type exceeds the word size of the machine (e.g., 32 bits or 64 bits)
246   - * READ_ONCE() and ASSIGN_ONCE() will fall back to memcpy and print a
  246 + * READ_ONCE() and WRITE_ONCE() will fall back to memcpy and print a
247 247 * compile-time warning.
248 248 *
249 249 * Their two major use cases are: (1) Mediating communication between
... ... @@ -257,8 +257,8 @@
257 257 #define READ_ONCE(x) \
258 258 ({ typeof(x) __val; __read_once_size(&x, &__val, sizeof(__val)); __val; })
259 259  
260   -#define ASSIGN_ONCE(val, x) \
261   - ({ typeof(x) __val; __val = val; __assign_once_size(&x, &__val, sizeof(__val)); __val; })
  260 +#define WRITE_ONCE(x, val) \
  261 + ({ typeof(x) __val; __val = val; __write_once_size(&x, &__val, sizeof(__val)); __val; })
262 262  
263 263 #endif /* __KERNEL__ */
264 264