git: 046d8d89ed19 - main - LinuxKPI: fix WRITE_ONCE(), remove ACCESS_ONCE()

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Sun, 21 May 2023 23:14:27 UTC
The branch main has been updated by bz:

URL: https://cgit.FreeBSD.org/src/commit/?id=046d8d89ed1956944b12ec4f0580c30bc202bbfb

commit 046d8d89ed1956944b12ec4f0580c30bc202bbfb
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2023-05-13 15:17:47 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2023-05-21 23:14:05 +0000

    LinuxKPI: fix WRITE_ONCE(), remove ACCESS_ONCE()
    
    Fix a gcc warning: "to be safe all intermediate pointers in cast from
    '...' to '...' must be 'const' qualified [-Wcast-qual]".
    Doing what is essentially a __DECONST() adding the uintptr_t gets
    rid of the massive amount of warnings we get in LinuxKPI and lets
    us see the actual problems a lot better.
    This is a follow-up to 74e908b3c63b28de1d590dc42502fbe959a6da2e which
    fixed READ_ONCE().
    ACCESS_ONCE() seems to be an obsolete KPI these days in Linux and
    FreeBSD does not use it either directly so we can entirely remove
    it now.
    
    Sponsored by:   The FreeBSD Foundation
    Suggested by:   jhb
    Reviewed by:    hselasky
    MFC after:      10 days
    Differential Revision: https://reviews.freebsd.org/D40084
---
 sys/compat/linuxkpi/common/include/linux/compiler.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/sys/compat/linuxkpi/common/include/linux/compiler.h b/sys/compat/linuxkpi/common/include/linux/compiler.h
index b2c835ad808d..323a583860b4 100644
--- a/sys/compat/linuxkpi/common/include/linux/compiler.h
+++ b/sys/compat/linuxkpi/common/include/linux/compiler.h
@@ -88,11 +88,9 @@
 #define	___PASTE(a,b) a##b
 #define	__PASTE(a,b) ___PASTE(a,b)
 
-#define	ACCESS_ONCE(x)			(*(volatile __typeof(x) *)&(x))
-
 #define	WRITE_ONCE(x,v) do {		\
 	barrier();			\
-	ACCESS_ONCE(x) = (v);		\
+	(*(volatile __typeof(x) *)(uintptr_t)&(x)) = (v); \
 	barrier();			\
 } while (0)