diff options
Diffstat (limited to 'include/linux/kernel.h')
| -rw-r--r-- | include/linux/kernel.h | 70 |
1 files changed, 17 insertions, 53 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h index a9e2268ecccb..3d770f5564b8 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h | |||
| @@ -376,10 +376,6 @@ extern unsigned long simple_strtoul(const char *,char **,unsigned int); | |||
| 376 | extern long simple_strtol(const char *,char **,unsigned int); | 376 | extern long simple_strtol(const char *,char **,unsigned int); |
| 377 | extern unsigned long long simple_strtoull(const char *,char **,unsigned int); | 377 | extern unsigned long long simple_strtoull(const char *,char **,unsigned int); |
| 378 | extern long long simple_strtoll(const char *,char **,unsigned int); | 378 | extern long long simple_strtoll(const char *,char **,unsigned int); |
| 379 | #define strict_strtoul kstrtoul | ||
| 380 | #define strict_strtol kstrtol | ||
| 381 | #define strict_strtoull kstrtoull | ||
| 382 | #define strict_strtoll kstrtoll | ||
| 383 | 379 | ||
| 384 | extern int num_to_str(char *buf, int size, unsigned long long num); | 380 | extern int num_to_str(char *buf, int size, unsigned long long num); |
| 385 | 381 | ||
| @@ -407,6 +403,7 @@ int vsscanf(const char *, const char *, va_list); | |||
| 407 | extern int get_option(char **str, int *pint); | 403 | extern int get_option(char **str, int *pint); |
| 408 | extern char *get_options(const char *str, int nints, int *ints); | 404 | extern char *get_options(const char *str, int nints, int *ints); |
| 409 | extern unsigned long long memparse(const char *ptr, char **retptr); | 405 | extern unsigned long long memparse(const char *ptr, char **retptr); |
| 406 | extern bool parse_option_str(const char *str, const char *option); | ||
| 410 | 407 | ||
| 411 | extern int core_kernel_text(unsigned long addr); | 408 | extern int core_kernel_text(unsigned long addr); |
| 412 | extern int core_kernel_data(unsigned long addr); | 409 | extern int core_kernel_data(unsigned long addr); |
| @@ -470,6 +467,7 @@ extern enum system_states { | |||
| 470 | #define TAINT_FIRMWARE_WORKAROUND 11 | 467 | #define TAINT_FIRMWARE_WORKAROUND 11 |
| 471 | #define TAINT_OOT_MODULE 12 | 468 | #define TAINT_OOT_MODULE 12 |
| 472 | #define TAINT_UNSIGNED_MODULE 13 | 469 | #define TAINT_UNSIGNED_MODULE 13 |
| 470 | #define TAINT_SOFTLOCKUP 14 | ||
| 473 | 471 | ||
| 474 | extern const char hex_asc[]; | 472 | extern const char hex_asc[]; |
| 475 | #define hex_asc_lo(x) hex_asc[((x) & 0x0f)] | 473 | #define hex_asc_lo(x) hex_asc[((x) & 0x0f)] |
| @@ -493,13 +491,9 @@ static inline char *hex_byte_pack_upper(char *buf, u8 byte) | |||
| 493 | return buf; | 491 | return buf; |
| 494 | } | 492 | } |
| 495 | 493 | ||
| 496 | static inline char * __deprecated pack_hex_byte(char *buf, u8 byte) | ||
| 497 | { | ||
| 498 | return hex_byte_pack(buf, byte); | ||
| 499 | } | ||
| 500 | |||
| 501 | extern int hex_to_bin(char ch); | 494 | extern int hex_to_bin(char ch); |
| 502 | extern int __must_check hex2bin(u8 *dst, const char *src, size_t count); | 495 | extern int __must_check hex2bin(u8 *dst, const char *src, size_t count); |
| 496 | extern char *bin2hex(char *dst, const void *src, size_t count); | ||
| 503 | 497 | ||
| 504 | bool mac_pton(const char *s, u8 *mac); | 498 | bool mac_pton(const char *s, u8 *mac); |
| 505 | 499 | ||
| @@ -719,23 +713,8 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { } | |||
| 719 | (void) (&_max1 == &_max2); \ | 713 | (void) (&_max1 == &_max2); \ |
| 720 | _max1 > _max2 ? _max1 : _max2; }) | 714 | _max1 > _max2 ? _max1 : _max2; }) |
| 721 | 715 | ||
| 722 | #define min3(x, y, z) ({ \ | 716 | #define min3(x, y, z) min((typeof(x))min(x, y), z) |
| 723 | typeof(x) _min1 = (x); \ | 717 | #define max3(x, y, z) max((typeof(x))max(x, y), z) |
| 724 | typeof(y) _min2 = (y); \ | ||
| 725 | typeof(z) _min3 = (z); \ | ||
| 726 | (void) (&_min1 == &_min2); \ | ||
| 727 | (void) (&_min1 == &_min3); \ | ||
| 728 | _min1 < _min2 ? (_min1 < _min3 ? _min1 : _min3) : \ | ||
| 729 | (_min2 < _min3 ? _min2 : _min3); }) | ||
| 730 | |||
| 731 | #define max3(x, y, z) ({ \ | ||
| 732 | typeof(x) _max1 = (x); \ | ||
| 733 | typeof(y) _max2 = (y); \ | ||
| 734 | typeof(z) _max3 = (z); \ | ||
| 735 | (void) (&_max1 == &_max2); \ | ||
| 736 | (void) (&_max1 == &_max3); \ | ||
| 737 | _max1 > _max2 ? (_max1 > _max3 ? _max1 : _max3) : \ | ||
| 738 | (_max2 > _max3 ? _max2 : _max3); }) | ||
| 739 | 718 | ||
| 740 | /** | 719 | /** |
| 741 | * min_not_zero - return the minimum that is _not_ zero, unless both are zero | 720 | * min_not_zero - return the minimum that is _not_ zero, unless both are zero |
| @@ -750,20 +729,13 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { } | |||
| 750 | /** | 729 | /** |
| 751 | * clamp - return a value clamped to a given range with strict typechecking | 730 | * clamp - return a value clamped to a given range with strict typechecking |
| 752 | * @val: current value | 731 | * @val: current value |
| 753 | * @min: minimum allowable value | 732 | * @lo: lowest allowable value |
| 754 | * @max: maximum allowable value | 733 | * @hi: highest allowable value |
| 755 | * | 734 | * |
| 756 | * This macro does strict typechecking of min/max to make sure they are of the | 735 | * This macro does strict typechecking of lo/hi to make sure they are of the |
| 757 | * same type as val. See the unnecessary pointer comparisons. | 736 | * same type as val. See the unnecessary pointer comparisons. |
| 758 | */ | 737 | */ |
| 759 | #define clamp(val, min, max) ({ \ | 738 | #define clamp(val, lo, hi) min((typeof(val))max(val, lo), hi) |
| 760 | typeof(val) __val = (val); \ | ||
| 761 | typeof(min) __min = (min); \ | ||
| 762 | typeof(max) __max = (max); \ | ||
| 763 | (void) (&__val == &__min); \ | ||
| 764 | (void) (&__val == &__max); \ | ||
| 765 | __val = __val < __min ? __min: __val; \ | ||
| 766 | __val > __max ? __max: __val; }) | ||
| 767 | 739 | ||
| 768 | /* | 740 | /* |
| 769 | * ..and if you can't take the strict | 741 | * ..and if you can't take the strict |
| @@ -785,36 +757,26 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { } | |||
| 785 | * clamp_t - return a value clamped to a given range using a given type | 757 | * clamp_t - return a value clamped to a given range using a given type |
| 786 | * @type: the type of variable to use | 758 | * @type: the type of variable to use |
| 787 | * @val: current value | 759 | * @val: current value |
| 788 | * @min: minimum allowable value | 760 | * @lo: minimum allowable value |
| 789 | * @max: maximum allowable value | 761 | * @hi: maximum allowable value |
| 790 | * | 762 | * |
| 791 | * This macro does no typechecking and uses temporary variables of type | 763 | * This macro does no typechecking and uses temporary variables of type |
| 792 | * 'type' to make all the comparisons. | 764 | * 'type' to make all the comparisons. |
| 793 | */ | 765 | */ |
| 794 | #define clamp_t(type, val, min, max) ({ \ | 766 | #define clamp_t(type, val, lo, hi) min_t(type, max_t(type, val, lo), hi) |
| 795 | type __val = (val); \ | ||
| 796 | type __min = (min); \ | ||
| 797 | type __max = (max); \ | ||
| 798 | __val = __val < __min ? __min: __val; \ | ||
| 799 | __val > __max ? __max: __val; }) | ||
| 800 | 767 | ||
| 801 | /** | 768 | /** |
| 802 | * clamp_val - return a value clamped to a given range using val's type | 769 | * clamp_val - return a value clamped to a given range using val's type |
| 803 | * @val: current value | 770 | * @val: current value |
| 804 | * @min: minimum allowable value | 771 | * @lo: minimum allowable value |
| 805 | * @max: maximum allowable value | 772 | * @hi: maximum allowable value |
| 806 | * | 773 | * |
| 807 | * This macro does no typechecking and uses temporary variables of whatever | 774 | * This macro does no typechecking and uses temporary variables of whatever |
| 808 | * type the input argument 'val' is. This is useful when val is an unsigned | 775 | * type the input argument 'val' is. This is useful when val is an unsigned |
| 809 | * type and min and max are literals that will otherwise be assigned a signed | 776 | * type and min and max are literals that will otherwise be assigned a signed |
| 810 | * integer type. | 777 | * integer type. |
| 811 | */ | 778 | */ |
| 812 | #define clamp_val(val, min, max) ({ \ | 779 | #define clamp_val(val, lo, hi) clamp_t(typeof(val), val, lo, hi) |
| 813 | typeof(val) __val = (val); \ | ||
| 814 | typeof(val) __min = (min); \ | ||
| 815 | typeof(val) __max = (max); \ | ||
| 816 | __val = __val < __min ? __min: __val; \ | ||
| 817 | __val > __max ? __max: __val; }) | ||
| 818 | 780 | ||
| 819 | 781 | ||
| 820 | /* | 782 | /* |
| @@ -849,5 +811,7 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { } | |||
| 849 | /* User perms >= group perms >= other perms */ \ | 811 | /* User perms >= group perms >= other perms */ \ |
| 850 | BUILD_BUG_ON_ZERO(((perms) >> 6) < (((perms) >> 3) & 7)) + \ | 812 | BUILD_BUG_ON_ZERO(((perms) >> 6) < (((perms) >> 3) & 7)) + \ |
| 851 | BUILD_BUG_ON_ZERO((((perms) >> 3) & 7) < ((perms) & 7)) + \ | 813 | BUILD_BUG_ON_ZERO((((perms) >> 3) & 7) < ((perms) & 7)) + \ |
| 814 | /* Other writable? Generally considered a bad idea. */ \ | ||
| 815 | BUILD_BUG_ON_ZERO((perms) & 2) + \ | ||
| 852 | (perms)) | 816 | (perms)) |
| 853 | #endif | 817 | #endif |
