mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 18:51:56 -04:00
asm-generic: uaccess.h cleanup
Like in 3.19, I once more have a multi-stage cleanup for one asm-generic header file, this time the work was done by Michael Tsirkin and cleans up the uaccess.h file in asm-generic, as well as all architectures for which the respective maintainers did not pick up his patches directly. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iQIVAwUAVONFpmCrR//JCVInAQIoYRAA1T3ID1bQLqdi8TU1X+vzutXzGFRhRFii u18GYeN6sGTcfqQD0GsNSaH7G8XehF3cgJ9eo4h9YkRPIG/0T0FO+dqdB0uRh8iy GKcUqVhgvCFpOBDUJC6FgMvgWWyVrgSUBqG6qSXck/PDcMSsUa/m/GcLhR/sHWGn EGEAzYNvJgdOaJ1z0vfPFK6mPwFwmYzIss5XFuoBAKKN856fBlxofkQqdpKjGDFH n0UziaJ5tbCdlZ9M9Y5JN9RU8yBCcOmGHnHUAQHz3BXOt9sD7o5jDuzsUbj+vUGJ gzNc8kee9Pyy8ZA1F959gspaxe5Oumq7NLgs3HDjK6ZDRKpJvZb6iXi56f15chlZ dItTbFSxCHOFs0d8XJKNbmPt44pJ/qKO+03lMIGttMkIm7hXfvyMWSPZV9G0Pu1y zbWEDgW2Mdrdt0saNSD46IEp+c7E5P3D9JSctQRdQjReoCbOHwqrSHi1Zeg97XL4 I1E0KwDqFUw3P1dXr5ahXmR50ZigBGjN5Fz3N7GmJt2x4PRSS2Sw92hyCrL0YM8J 56FdRA7UJ0V/SzmAko3F5wWmhabc6L+qrVA42R6U3SNSjU8hwppOkYKDINNhPZfL SGy1oQS6Jj10WxLOVp66NC7XxXzBybDcQnatz4XtNN8P5sfekUGSGBeMyMsHl7IJ 9MT3xym+DWU= =LROx -----END PGP SIGNATURE----- Merge tag 'asm-generic-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic Pull asm-generic uaccess.h cleanup from Arnd Bergmann: "Like in 3.19, I once more have a multi-stage cleanup for one asm-generic header file, this time the work was done by Michael Tsirkin and cleans up the uaccess.h file in asm-generic, as well as all architectures for which the respective maintainers did not pick up his patches directly" * tag 'asm-generic-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic: (37 commits) sparc32: nocheck uaccess coding style tweaks sparc64: nocheck uaccess coding style tweaks xtensa: macro whitespace fixes sh: macro whitespace fixes parisc: macro whitespace fixes m68k: macro whitespace fixes m32r: macro whitespace fixes frv: macro whitespace fixes cris: macro whitespace fixes avr32: macro whitespace fixes arm64: macro whitespace fixes arm: macro whitespace fixes alpha: macro whitespace fixes blackfin: macro whitespace fixes sparc64: uaccess_64 macro whitespace fixes sparc32: uaccess_32 macro whitespace fixes avr32: whitespace fix sh: fix put_user sparse errors metag: fix put_user sparse errors ia64: fix put_user sparse errors ...
This commit is contained in:
commit
eaa0eda562
19 changed files with 582 additions and 499 deletions
|
|
@ -182,13 +182,13 @@
|
|||
#define get_fs() (current->thread.current_ds)
|
||||
#define set_fs(val) (current->thread.current_ds = (val))
|
||||
|
||||
#define segment_eq(a,b) ((a).seg == (b).seg)
|
||||
#define segment_eq(a, b) ((a).seg == (b).seg)
|
||||
|
||||
#define __kernel_ok (segment_eq(get_fs(), KERNEL_DS))
|
||||
#define __user_ok(addr,size) \
|
||||
#define __user_ok(addr, size) \
|
||||
(((size) <= TASK_SIZE)&&((addr) <= TASK_SIZE-(size)))
|
||||
#define __access_ok(addr,size) (__kernel_ok || __user_ok((addr),(size)))
|
||||
#define access_ok(type,addr,size) __access_ok((unsigned long)(addr),(size))
|
||||
#define __access_ok(addr, size) (__kernel_ok || __user_ok((addr), (size)))
|
||||
#define access_ok(type, addr, size) __access_ok((unsigned long)(addr), (size))
|
||||
|
||||
/*
|
||||
* These are the main single-value transfer routines. They
|
||||
|
|
@ -204,8 +204,8 @@
|
|||
* (a) re-use the arguments for side effects (sizeof is ok)
|
||||
* (b) require any knowledge of processes at this stage
|
||||
*/
|
||||
#define put_user(x,ptr) __put_user_check((x),(ptr),sizeof(*(ptr)))
|
||||
#define get_user(x,ptr) __get_user_check((x),(ptr),sizeof(*(ptr)))
|
||||
#define put_user(x, ptr) __put_user_check((x), (ptr), sizeof(*(ptr)))
|
||||
#define get_user(x, ptr) __get_user_check((x), (ptr), sizeof(*(ptr)))
|
||||
|
||||
/*
|
||||
* The "__xxx" versions of the user access functions are versions that
|
||||
|
|
@ -213,39 +213,39 @@
|
|||
* with a separate "access_ok()" call (this is used when we do multiple
|
||||
* accesses to the same area of user memory).
|
||||
*/
|
||||
#define __put_user(x,ptr) __put_user_nocheck((x),(ptr),sizeof(*(ptr)))
|
||||
#define __get_user(x,ptr) __get_user_nocheck((x),(ptr),sizeof(*(ptr)))
|
||||
#define __put_user(x, ptr) __put_user_nocheck((x), (ptr), sizeof(*(ptr)))
|
||||
#define __get_user(x, ptr) __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
|
||||
|
||||
|
||||
extern long __put_user_bad(void);
|
||||
|
||||
#define __put_user_nocheck(x,ptr,size) \
|
||||
#define __put_user_nocheck(x, ptr, size) \
|
||||
({ \
|
||||
long __pu_err; \
|
||||
__put_user_size((x),(ptr),(size),__pu_err); \
|
||||
__put_user_size((x), (ptr), (size), __pu_err); \
|
||||
__pu_err; \
|
||||
})
|
||||
|
||||
#define __put_user_check(x,ptr,size) \
|
||||
({ \
|
||||
long __pu_err = -EFAULT; \
|
||||
__typeof__(*(ptr)) *__pu_addr = (ptr); \
|
||||
if (access_ok(VERIFY_WRITE,__pu_addr,size)) \
|
||||
__put_user_size((x),__pu_addr,(size),__pu_err); \
|
||||
__pu_err; \
|
||||
#define __put_user_check(x, ptr, size) \
|
||||
({ \
|
||||
long __pu_err = -EFAULT; \
|
||||
__typeof__(*(ptr)) *__pu_addr = (ptr); \
|
||||
if (access_ok(VERIFY_WRITE, __pu_addr, size)) \
|
||||
__put_user_size((x), __pu_addr, (size), __pu_err); \
|
||||
__pu_err; \
|
||||
})
|
||||
|
||||
#define __put_user_size(x,ptr,size,retval) \
|
||||
#define __put_user_size(x, ptr, size, retval) \
|
||||
do { \
|
||||
int __cb; \
|
||||
retval = 0; \
|
||||
switch (size) { \
|
||||
case 1: __put_user_asm(x,ptr,retval,1,"s8i",__cb); break; \
|
||||
case 2: __put_user_asm(x,ptr,retval,2,"s16i",__cb); break; \
|
||||
case 4: __put_user_asm(x,ptr,retval,4,"s32i",__cb); break; \
|
||||
case 1: __put_user_asm(x, ptr, retval, 1, "s8i", __cb); break; \
|
||||
case 2: __put_user_asm(x, ptr, retval, 2, "s16i", __cb); break; \
|
||||
case 4: __put_user_asm(x, ptr, retval, 4, "s32i", __cb); break; \
|
||||
case 8: { \
|
||||
__typeof__(*ptr) __v64 = x; \
|
||||
retval = __copy_to_user(ptr,&__v64,8); \
|
||||
retval = __copy_to_user(ptr, &__v64, 8); \
|
||||
break; \
|
||||
} \
|
||||
default: __put_user_bad(); \
|
||||
|
|
@ -316,35 +316,35 @@ __asm__ __volatile__( \
|
|||
:"=r" (err), "=r" (cb) \
|
||||
:"r" ((int)(x)), "r" (addr), "i" (-EFAULT), "0" (err))
|
||||
|
||||
#define __get_user_nocheck(x,ptr,size) \
|
||||
#define __get_user_nocheck(x, ptr, size) \
|
||||
({ \
|
||||
long __gu_err, __gu_val; \
|
||||
__get_user_size(__gu_val,(ptr),(size),__gu_err); \
|
||||
(x) = (__force __typeof__(*(ptr)))__gu_val; \
|
||||
__get_user_size(__gu_val, (ptr), (size), __gu_err); \
|
||||
(x) = (__force __typeof__(*(ptr)))__gu_val; \
|
||||
__gu_err; \
|
||||
})
|
||||
|
||||
#define __get_user_check(x,ptr,size) \
|
||||
#define __get_user_check(x, ptr, size) \
|
||||
({ \
|
||||
long __gu_err = -EFAULT, __gu_val = 0; \
|
||||
const __typeof__(*(ptr)) *__gu_addr = (ptr); \
|
||||
if (access_ok(VERIFY_READ,__gu_addr,size)) \
|
||||
__get_user_size(__gu_val,__gu_addr,(size),__gu_err); \
|
||||
(x) = (__force __typeof__(*(ptr)))__gu_val; \
|
||||
if (access_ok(VERIFY_READ, __gu_addr, size)) \
|
||||
__get_user_size(__gu_val, __gu_addr, (size), __gu_err); \
|
||||
(x) = (__force __typeof__(*(ptr)))__gu_val; \
|
||||
__gu_err; \
|
||||
})
|
||||
|
||||
extern long __get_user_bad(void);
|
||||
|
||||
#define __get_user_size(x,ptr,size,retval) \
|
||||
#define __get_user_size(x, ptr, size, retval) \
|
||||
do { \
|
||||
int __cb; \
|
||||
retval = 0; \
|
||||
switch (size) { \
|
||||
case 1: __get_user_asm(x,ptr,retval,1,"l8ui",__cb); break; \
|
||||
case 2: __get_user_asm(x,ptr,retval,2,"l16ui",__cb); break; \
|
||||
case 4: __get_user_asm(x,ptr,retval,4,"l32i",__cb); break; \
|
||||
case 8: retval = __copy_from_user(&x,ptr,8); break; \
|
||||
case 1: __get_user_asm(x, ptr, retval, 1, "l8ui", __cb); break;\
|
||||
case 2: __get_user_asm(x, ptr, retval, 2, "l16ui", __cb); break;\
|
||||
case 4: __get_user_asm(x, ptr, retval, 4, "l32i", __cb); break;\
|
||||
case 8: retval = __copy_from_user(&x, ptr, 8); break; \
|
||||
default: (x) = __get_user_bad(); \
|
||||
} \
|
||||
} while (0)
|
||||
|
|
@ -390,19 +390,19 @@ __asm__ __volatile__( \
|
|||
*/
|
||||
|
||||
extern unsigned __xtensa_copy_user(void *to, const void *from, unsigned n);
|
||||
#define __copy_user(to,from,size) __xtensa_copy_user(to,from,size)
|
||||
#define __copy_user(to, from, size) __xtensa_copy_user(to, from, size)
|
||||
|
||||
|
||||
static inline unsigned long
|
||||
__generic_copy_from_user_nocheck(void *to, const void *from, unsigned long n)
|
||||
{
|
||||
return __copy_user(to,from,n);
|
||||
return __copy_user(to, from, n);
|
||||
}
|
||||
|
||||
static inline unsigned long
|
||||
__generic_copy_to_user_nocheck(void *to, const void *from, unsigned long n)
|
||||
{
|
||||
return __copy_user(to,from,n);
|
||||
return __copy_user(to, from, n);
|
||||
}
|
||||
|
||||
static inline unsigned long
|
||||
|
|
@ -410,7 +410,7 @@ __generic_copy_to_user(void *to, const void *from, unsigned long n)
|
|||
{
|
||||
prefetch(from);
|
||||
if (access_ok(VERIFY_WRITE, to, n))
|
||||
return __copy_user(to,from,n);
|
||||
return __copy_user(to, from, n);
|
||||
return n;
|
||||
}
|
||||
|
||||
|
|
@ -419,18 +419,18 @@ __generic_copy_from_user(void *to, const void *from, unsigned long n)
|
|||
{
|
||||
prefetchw(to);
|
||||
if (access_ok(VERIFY_READ, from, n))
|
||||
return __copy_user(to,from,n);
|
||||
return __copy_user(to, from, n);
|
||||
else
|
||||
memset(to, 0, n);
|
||||
return n;
|
||||
}
|
||||
|
||||
#define copy_to_user(to,from,n) __generic_copy_to_user((to),(from),(n))
|
||||
#define copy_from_user(to,from,n) __generic_copy_from_user((to),(from),(n))
|
||||
#define __copy_to_user(to,from,n) \
|
||||
__generic_copy_to_user_nocheck((to),(from),(n))
|
||||
#define __copy_from_user(to,from,n) \
|
||||
__generic_copy_from_user_nocheck((to),(from),(n))
|
||||
#define copy_to_user(to, from, n) __generic_copy_to_user((to), (from), (n))
|
||||
#define copy_from_user(to, from, n) __generic_copy_from_user((to), (from), (n))
|
||||
#define __copy_to_user(to, from, n) \
|
||||
__generic_copy_to_user_nocheck((to), (from), (n))
|
||||
#define __copy_from_user(to, from, n) \
|
||||
__generic_copy_from_user_nocheck((to), (from), (n))
|
||||
#define __copy_to_user_inatomic __copy_to_user
|
||||
#define __copy_from_user_inatomic __copy_from_user
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue