[PATCH 2/2] uaccess: minimize INLINE_COPY_USER-related ifdefery

From: Yury Norov

Date: Wed Mar 25 2026 - 12:43:36 EST


Now that we've got the same knob selecting inline vs outline copy_to_user()
and copy_from_user(), we can simplify the corresponding logic in the
uaccess.h.

Signed-off-by: Yury Norov <ynorov@xxxxxxxxxx>
---
include/linux/uaccess.h | 21 ++++++++-------------
1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
index 0ddd2806d7f5..19079588c78c 100644
--- a/include/linux/uaccess.h
+++ b/include/linux/uaccess.h
@@ -190,10 +190,6 @@ _inline_copy_from_user(void *to, const void __user *from, unsigned long n)
memset(to + (n - res), 0, res);
return res;
}
-#ifndef INLINE_COPY_USER
-extern __must_check unsigned long
-_copy_from_user(void *, const void __user *, unsigned long);
-#endif

static inline __must_check unsigned long
_inline_copy_to_user(void __user *to, const void *from, unsigned long n)
@@ -207,7 +203,13 @@ _inline_copy_to_user(void __user *to, const void *from, unsigned long n)
}
return n;
}
-#ifndef INLINE_COPY_USER
+#ifdef INLINE_COPY_USER
+# define _copy_to_user _inline_copy_to_user
+# define _copy_from_user _inline_copy_from_user
+#else
+extern __must_check unsigned long
+_copy_from_user(void *, const void __user *, unsigned long);
+
extern __must_check unsigned long
_copy_to_user(void __user *, const void *, unsigned long);
#endif
@@ -217,11 +219,8 @@ copy_from_user(void *to, const void __user *from, unsigned long n)
{
if (!check_copy_size(to, n, false))
return n;
-#ifdef INLINE_COPY_USER
- return _inline_copy_from_user(to, from, n);
-#else
+
return _copy_from_user(to, from, n);
-#endif
}

static __always_inline unsigned long __must_check
@@ -230,11 +229,7 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
if (!check_copy_size(from, n, true))
return n;

-#ifdef INLINE_COPY_USER
- return _inline_copy_to_user(to, from, n);
-#else
return _copy_to_user(to, from, n);
-#endif
}

#ifndef copy_mc_to_kernel
--
2.43.0