aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/kernel.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/kernel.h')
-rw-r--r--include/linux/kernel.h71
1 files changed, 17 insertions, 54 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 4c52907a6d8b..40728cf1c452 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);
376extern long simple_strtol(const char *,char **,unsigned int); 376extern long simple_strtol(const char *,char **,unsigned int);
377extern unsigned long long simple_strtoull(const char *,char **,unsigned int); 377extern unsigned long long simple_strtoull(const char *,char **,unsigned int);
378extern long long simple_strtoll(const char *,char **,unsigned int); 378extern 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
384extern int num_to_str(char *buf, int size, unsigned long long num); 380extern int num_to_str(char *buf, int size, unsigned long long num);
385 381
@@ -470,6 +466,7 @@ extern enum system_states {
470#define TAINT_FIRMWARE_WORKAROUND 11 466#define TAINT_FIRMWARE_WORKAROUND 11
471#define TAINT_OOT_MODULE 12 467#define TAINT_OOT_MODULE 12
472#define TAINT_UNSIGNED_MODULE 13 468#define TAINT_UNSIGNED_MODULE 13
469#define TAINT_SOFTLOCKUP 14
473 470
474extern const char hex_asc[]; 471extern const char hex_asc[];
475#define hex_asc_lo(x) hex_asc[((x) & 0x0f)] 472#define hex_asc_lo(x) hex_asc[((x) & 0x0f)]
@@ -493,15 +490,11 @@ static inline char *hex_byte_pack_upper(char *buf, u8 byte)
493 return buf; 490 return buf;
494} 491}
495 492
496static inline char * __deprecated pack_hex_byte(char *buf, u8 byte)
497{
498 return hex_byte_pack(buf, byte);
499}
500
501extern int hex_to_bin(char ch); 493extern int hex_to_bin(char ch);
502extern int __must_check hex2bin(u8 *dst, const char *src, size_t count); 494extern int __must_check hex2bin(u8 *dst, const char *src, size_t count);
495extern char *bin2hex(char *dst, const void *src, size_t count);
503 496
504int mac_pton(const char *s, u8 *mac); 497bool mac_pton(const char *s, u8 *mac);
505 498
506/* 499/*
507 * General tracing related utility functions - trace_printk(), 500 * General tracing related utility functions - trace_printk(),
@@ -719,23 +712,8 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
719 (void) (&_max1 == &_max2); \ 712 (void) (&_max1 == &_max2); \
720 _max1 > _max2 ? _max1 : _max2; }) 713 _max1 > _max2 ? _max1 : _max2; })
721 714
722#define min3(x, y, z) ({ \ 715#define min3(x, y, z) min((typeof(x))min(x, y), z)
723 typeof(x) _min1 = (x); \ 716#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 717
740/** 718/**
741 * min_not_zero - return the minimum that is _not_ zero, unless both are zero 719 * min_not_zero - return the minimum that is _not_ zero, unless both are zero
@@ -750,20 +728,13 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
750/** 728/**
751 * clamp - return a value clamped to a given range with strict typechecking 729 * clamp - return a value clamped to a given range with strict typechecking
752 * @val: current value 730 * @val: current value
753 * @min: minimum allowable value 731 * @lo: lowest allowable value
754 * @max: maximum allowable value 732 * @hi: highest allowable value
755 * 733 *
756 * This macro does strict typechecking of min/max to make sure they are of the 734 * 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. 735 * same type as val. See the unnecessary pointer comparisons.
758 */ 736 */
759#define clamp(val, min, max) ({ \ 737#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 738
768/* 739/*
769 * ..and if you can't take the strict 740 * ..and if you can't take the strict
@@ -785,36 +756,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 756 * clamp_t - return a value clamped to a given range using a given type
786 * @type: the type of variable to use 757 * @type: the type of variable to use
787 * @val: current value 758 * @val: current value
788 * @min: minimum allowable value 759 * @lo: minimum allowable value
789 * @max: maximum allowable value 760 * @hi: maximum allowable value
790 * 761 *
791 * This macro does no typechecking and uses temporary variables of type 762 * This macro does no typechecking and uses temporary variables of type
792 * 'type' to make all the comparisons. 763 * 'type' to make all the comparisons.
793 */ 764 */
794#define clamp_t(type, val, min, max) ({ \ 765#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 766
801/** 767/**
802 * clamp_val - return a value clamped to a given range using val's type 768 * clamp_val - return a value clamped to a given range using val's type
803 * @val: current value 769 * @val: current value
804 * @min: minimum allowable value 770 * @lo: minimum allowable value
805 * @max: maximum allowable value 771 * @hi: maximum allowable value
806 * 772 *
807 * This macro does no typechecking and uses temporary variables of whatever 773 * 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 774 * 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 775 * type and min and max are literals that will otherwise be assigned a signed
810 * integer type. 776 * integer type.
811 */ 777 */
812#define clamp_val(val, min, max) ({ \ 778#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 779
819 780
820/* 781/*
@@ -849,5 +810,7 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
849 /* User perms >= group perms >= other perms */ \ 810 /* User perms >= group perms >= other perms */ \
850 BUILD_BUG_ON_ZERO(((perms) >> 6) < (((perms) >> 3) & 7)) + \ 811 BUILD_BUG_ON_ZERO(((perms) >> 6) < (((perms) >> 3) & 7)) + \
851 BUILD_BUG_ON_ZERO((((perms) >> 3) & 7) < ((perms) & 7)) + \ 812 BUILD_BUG_ON_ZERO((((perms) >> 3) & 7) < ((perms) & 7)) + \
813 /* Other writable? Generally considered a bad idea. */ \
814 BUILD_BUG_ON_ZERO((perms) & 2) + \
852 (perms)) 815 (perms))
853#endif 816#endif