[PATCH] arm64: Make smp_load_acquire() work with pointer to const argument.

From: David Daney
Date: Tue Nov 17 2015 - 19:05:13 EST


From: David Daney <david.daney@xxxxxxxxxx>

We are now getting this error when building:

.
.
.
CC init/do_mounts.o
In file included from include/linux/tcp.h:22:0,
from include/linux/ipv6.h:72,
from include/net/ipv6.h:16,
from include/linux/sunrpc/clnt.h:27,
from include/linux/nfs_fs.h:30,
from init/do_mounts.c:32:
include/net/sock.h: In function âsk_state_loadâ:
include/net/sock.h:2238:2: error: read-only variable â___p1â used as âasmâ output
return smp_load_acquire(&sk->sk_state);
^
include/net/sock.h:2238:2: error: read-only variable â___p1â used as âasmâ output
include/net/sock.h:2238:2: error: read-only variable â___p1â used as âasmâ output
include/net/sock.h:2238:2: error: read-only variable â___p1â used as âasmâ output
.
.
.

Fix the smp_load_acquire() implementation to discard the const
qualifier in the type of the temporary variable with some tricky
casting.

Signed-off-by: David Daney <david.daney@xxxxxxxxxx>
---
arch/arm64/include/asm/barrier.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/include/asm/barrier.h b/arch/arm64/include/asm/barrier.h
index 624f967..52eb9b9 100644
--- a/arch/arm64/include/asm/barrier.h
+++ b/arch/arm64/include/asm/barrier.h
@@ -64,7 +64,8 @@ do { \

#define smp_load_acquire(p) \
({ \
- typeof(*p) ___p1; \
+ typeof((typeof(*p))(*p + 0)) ___p1; \
+ compiletime_assert(sizeof(___p1) == sizeof(*p), "remove const"); \
compiletime_assert_atomic_type(*p); \
switch (sizeof(*p)) { \
case 1: \
--
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/