diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-01-13 17:54:12 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-01-13 17:54:12 -0500 |
commit | 0c133dd00ed84aefc41af2cc70e6560a61c95c89 (patch) | |
tree | 542e5cdcc9b2adec9fcf182185e87dc556bfae7d /include | |
parent | e7a823be2adc2c8617bead1376194a399143e4ed (diff) | |
parent | 43239cbe79fc369f5d2160bd7f69e28b5c50a58c (diff) |
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)
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/compiler.h | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/include/linux/compiler.h b/include/linux/compiler.h index a1c81f80978e..33063f872ee3 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h | |||
@@ -215,7 +215,7 @@ static __always_inline void __read_once_size(volatile void *p, void *res, int si | |||
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 | switch (size) { | 220 | switch (size) { |
221 | case 1: *(volatile __u8 *)p = *(__u8 *)res; break; | 221 | case 1: *(volatile __u8 *)p = *(__u8 *)res; break; |
@@ -235,15 +235,15 @@ static __always_inline void __assign_once_size(volatile void *p, void *res, int | |||
235 | /* | 235 | /* |
236 | * Prevent the compiler from merging or refetching reads or writes. The | 236 | * Prevent the compiler from merging or refetching reads or writes. The |
237 | * compiler is also forbidden from reordering successive instances of | 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 | * compiler is aware of some particular ordering. One way to make the | 239 | * compiler is aware of some particular ordering. One way to make the |
240 | * compiler aware of ordering is to put the two invocations of READ_ONCE, | 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 | * In contrast to ACCESS_ONCE these two macros will also work on aggregate | 243 | * In contrast to ACCESS_ONCE these two macros will also work on aggregate |
244 | * data types like structs or unions. If the size of the accessed data | 244 | * data types like structs or unions. If the size of the accessed data |
245 | * type exceeds the word size of the machine (e.g., 32 bits or 64 bits) | 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 | * compile-time warning. | 247 | * compile-time warning. |
248 | * | 248 | * |
249 | * Their two major use cases are: (1) Mediating communication between | 249 | * Their two major use cases are: (1) Mediating communication between |
@@ -257,8 +257,8 @@ static __always_inline void __assign_once_size(volatile void *p, void *res, int | |||
257 | #define READ_ONCE(x) \ | 257 | #define READ_ONCE(x) \ |
258 | ({ typeof(x) __val; __read_once_size(&x, &__val, sizeof(__val)); __val; }) | 258 | ({ typeof(x) __val; __read_once_size(&x, &__val, sizeof(__val)); __val; }) |
259 | 259 | ||
260 | #define ASSIGN_ONCE(val, x) \ | 260 | #define WRITE_ONCE(x, val) \ |
261 | ({ typeof(x) __val; __val = val; __assign_once_size(&x, &__val, sizeof(__val)); __val; }) | 261 | ({ typeof(x) __val; __val = val; __write_once_size(&x, &__val, sizeof(__val)); __val; }) |
262 | 262 | ||
263 | #endif /* __KERNEL__ */ | 263 | #endif /* __KERNEL__ */ |
264 | 264 | ||