* [PATCH 00/14] kernel.h cleanups
@ 2009-12-16 8:08 Joe Perches
2009-12-16 8:09 ` [PATCH 01/14] kernel.h: Consolidate console and logging functions and defines Joe Perches
` (14 more replies)
0 siblings, 15 replies; 18+ messages in thread
From: Joe Perches @ 2009-12-16 8:08 UTC (permalink / raw)
To: Linus Torvalds; +Cc: linux-kernel
No one seems to like taking patches for kernel.h
so I'm sending these to Linus and seeing what happens.
kernel.h has become a chaotic jumble collected over time.
Collect the functions and #defines together in logical groups.
Do some checkpatch neatening and make it more style conformant.
Compiled x86 allnoconfig, allyesconfig, defconfig
Joe Perches (14):
kernel.h: Consolidate console and logging functions and defines
kernel.h: Checkpatch cleaning
kernel.h: ARRAY_SIZE neatening
kernel.h: Add argument names to strtoXX, Xscanf prototypes
kernel.h: printk neatening
drivers/firmware/iscsi_ibft.c: Use %pI4 to print netmask
kernel.h: Move NIPQUAD and NIPQUAD_FMT to in.h
kernel.h: Group math and limits functions, indent function args
kernel.h: Don't use NORET_AND just use noreturn, instead
kernel.h: Remove ATTRIB_NORET, use __attribute__((noreturn))
kernel.h: Remove uses of NORET_TYPE
kernel.h: Add pr_<level>_once
kernel.h: Kernel address utility aggregation and other neatening
kernel/exit.c and kernel/panic.c: Remove unused NORET_TYPE
drivers/firmware/iscsi_ibft.c | 8 +-
include/linux/in.h | 11 +
include/linux/kernel.h | 742 +++++++++++++++++++++++------------------
kernel/exit.c | 4 +-
kernel/panic.c | 2 +-
5 files changed, 437 insertions(+), 330 deletions(-)
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 01/14] kernel.h: Consolidate console and logging functions and defines
2009-12-16 8:08 [PATCH 00/14] kernel.h cleanups Joe Perches
@ 2009-12-16 8:09 ` Joe Perches
2009-12-16 8:09 ` [PATCH 02/14] kernel.h: Checkpatch cleaning Joe Perches
` (13 subsequent siblings)
14 siblings, 0 replies; 18+ messages in thread
From: Joe Perches @ 2009-12-16 8:09 UTC (permalink / raw)
To: Linus Torvalds; +Cc: linux-kernel
Console and logging functions were not logically grouped by type.
Move the around a bit for ease of reading.
Signed-off-by: Joe Perches <joe@perches.com>
---
include/linux/kernel.h | 383 ++++++++++++++++++++++++-----------------------
1 files changed, 196 insertions(+), 187 deletions(-)
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 4d9c916..c9cdfca 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -19,9 +19,6 @@
#include <asm/byteorder.h>
#include <asm/bug.h>
-extern const char linux_banner[];
-extern const char linux_proc_banner[];
-
#define USHORT_MAX ((u16)(~0U))
#define SHORT_MAX ((s16)(USHORT_MAX>>1))
#define SHORT_MIN (-SHORT_MAX - 1)
@@ -87,31 +84,6 @@ extern const char linux_proc_banner[];
*/
#define lower_32_bits(n) ((u32)(n))
-#define KERN_EMERG "<0>" /* system is unusable */
-#define KERN_ALERT "<1>" /* action must be taken immediately */
-#define KERN_CRIT "<2>" /* critical conditions */
-#define KERN_ERR "<3>" /* error conditions */
-#define KERN_WARNING "<4>" /* warning conditions */
-#define KERN_NOTICE "<5>" /* normal but significant condition */
-#define KERN_INFO "<6>" /* informational */
-#define KERN_DEBUG "<7>" /* debug-level messages */
-
-/* Use the default kernel loglevel */
-#define KERN_DEFAULT "<d>"
-/*
- * Annotation for a "continued" line of log printout (only done after a
- * line that had no enclosing \n). Only to be used by core/arch code
- * during early bootup (a continued line is not SMP-safe otherwise).
- */
-#define KERN_CONT "<c>"
-
-extern int console_printk[];
-
-#define console_loglevel (console_printk[0])
-#define default_message_loglevel (console_printk[1])
-#define minimum_console_loglevel (console_printk[2])
-#define default_console_loglevel (console_printk[3])
-
struct completion;
struct pt_regs;
struct user;
@@ -210,6 +182,202 @@ extern int func_ptr_is_kernel_text(void *ptr);
struct pid;
extern struct pid *session_of_pgrp(struct pid *pgrp);
+/* Values used for system_state */
+extern enum system_states {
+ SYSTEM_BOOTING,
+ SYSTEM_RUNNING,
+ SYSTEM_HALT,
+ SYSTEM_POWER_OFF,
+ SYSTEM_RESTART,
+ SYSTEM_SUSPEND_DISK,
+} system_state;
+
+#define TAINT_PROPRIETARY_MODULE 0
+#define TAINT_FORCED_MODULE 1
+#define TAINT_UNSAFE_SMP 2
+#define TAINT_FORCED_RMMOD 3
+#define TAINT_MACHINE_CHECK 4
+#define TAINT_BAD_PAGE 5
+#define TAINT_USER 6
+#define TAINT_DIE 7
+#define TAINT_OVERRIDDEN_ACPI_TABLE 8
+#define TAINT_WARN 9
+#define TAINT_CRAP 10
+
+extern const char *print_tainted(void);
+extern void add_taint(unsigned flag);
+extern int test_taint(unsigned flag);
+extern unsigned long get_taint(void);
+
+extern int panic_timeout;
+extern int panic_on_oops;
+extern int panic_on_unrecovered_nmi;
+extern int panic_on_io_nmi;
+extern int root_mountflags;
+
+
+extern const char hex_asc[];
+#define hex_asc_lo(x) hex_asc[((x) & 0x0f)]
+#define hex_asc_hi(x) hex_asc[((x) & 0xf0) >> 4]
+
+static inline char *pack_hex_byte(char *buf, u8 byte)
+{
+ *buf++ = hex_asc_hi(byte);
+ *buf++ = hex_asc_lo(byte);
+ return buf;
+}
+
+/*
+ * Display an IP address in readable format.
+ */
+
+#define NIPQUAD(addr) \
+ ((unsigned char *)&addr)[0], \
+ ((unsigned char *)&addr)[1], \
+ ((unsigned char *)&addr)[2], \
+ ((unsigned char *)&addr)[3]
+#define NIPQUAD_FMT "%u.%u.%u.%u"
+
+/*
+ * min()/max()/clamp() macros that also do
+ * strict type-checking.. See the
+ * "unnecessary" pointer comparison.
+ */
+#define min(x, y) ({ \
+ typeof(x) _min1 = (x); \
+ typeof(y) _min2 = (y); \
+ (void) (&_min1 == &_min2); \
+ _min1 < _min2 ? _min1 : _min2; })
+
+#define max(x, y) ({ \
+ typeof(x) _max1 = (x); \
+ typeof(y) _max2 = (y); \
+ (void) (&_max1 == &_max2); \
+ _max1 > _max2 ? _max1 : _max2; })
+
+/**
+ * clamp - return a value clamped to a given range with strict typechecking
+ * @val: current value
+ * @min: minimum allowable value
+ * @max: maximum allowable value
+ *
+ * This macro does strict typechecking of min/max to make sure they are of the
+ * same type as val. See the unnecessary pointer comparisons.
+ */
+#define clamp(val, min, max) ({ \
+ typeof(val) __val = (val); \
+ typeof(min) __min = (min); \
+ typeof(max) __max = (max); \
+ (void) (&__val == &__min); \
+ (void) (&__val == &__max); \
+ __val = __val < __min ? __min: __val; \
+ __val > __max ? __max: __val; })
+
+/*
+ * ..and if you can't take the strict
+ * types, you can specify one yourself.
+ *
+ * Or not use min/max/clamp at all, of course.
+ */
+#define min_t(type, x, y) ({ \
+ type __min1 = (x); \
+ type __min2 = (y); \
+ __min1 < __min2 ? __min1: __min2; })
+
+#define max_t(type, x, y) ({ \
+ type __max1 = (x); \
+ type __max2 = (y); \
+ __max1 > __max2 ? __max1: __max2; })
+
+/**
+ * clamp_t - return a value clamped to a given range using a given type
+ * @type: the type of variable to use
+ * @val: current value
+ * @min: minimum allowable value
+ * @max: maximum allowable value
+ *
+ * This macro does no typechecking and uses temporary variables of type
+ * 'type' to make all the comparisons.
+ */
+#define clamp_t(type, val, min, max) ({ \
+ type __val = (val); \
+ type __min = (min); \
+ type __max = (max); \
+ __val = __val < __min ? __min: __val; \
+ __val > __max ? __max: __val; })
+
+/**
+ * clamp_val - return a value clamped to a given range using val's type
+ * @val: current value
+ * @min: minimum allowable value
+ * @max: maximum allowable value
+ *
+ * This macro does no typechecking and uses temporary variables of whatever
+ * type the input argument 'val' is. This is useful when val is an unsigned
+ * type and min and max are literals that will otherwise be assigned a signed
+ * integer type.
+ */
+#define clamp_val(val, min, max) ({ \
+ typeof(val) __val = (val); \
+ typeof(val) __min = (min); \
+ typeof(val) __max = (max); \
+ __val = __val < __min ? __min: __val; \
+ __val > __max ? __max: __val; })
+
+
+/*
+ * swap - swap value of @a and @b
+ */
+#define swap(a, b) \
+ do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0)
+
+/**
+ * container_of - cast a member of a structure out to the containing structure
+ * @ptr: the pointer to the member.
+ * @type: the type of the container struct this is embedded in.
+ * @member: the name of the member within the struct.
+ *
+ */
+#define container_of(ptr, type, member) ({ \
+ const typeof( ((type *)0)->member ) *__mptr = (ptr); \
+ (type *)( (char *)__mptr - offsetof(type,member) ); \
+})
+
+struct sysinfo;
+extern int do_sysinfo(struct sysinfo *info);
+
+/*
+ * Console and logging support
+ */
+
+extern const char linux_banner[];
+extern const char linux_proc_banner[];
+
+#define KERN_EMERG "<0>" /* system is unusable */
+#define KERN_ALERT "<1>" /* action must be taken immediately */
+#define KERN_CRIT "<2>" /* critical conditions */
+#define KERN_ERR "<3>" /* error conditions */
+#define KERN_WARNING "<4>" /* warning conditions */
+#define KERN_NOTICE "<5>" /* normal but significant condition */
+#define KERN_INFO "<6>" /* informational */
+#define KERN_DEBUG "<7>" /* debug-level messages */
+
+/* Use the default kernel loglevel */
+#define KERN_DEFAULT "<d>"
+/*
+ * Annotation for a "continued" line of log printout (only done after a
+ * line that had no enclosing \n). Only to be used by core/arch code
+ * during early bootup (a continued line is not SMP-safe otherwise).
+ */
+#define KERN_CONT "<c>"
+
+extern int console_printk[];
+
+#define console_loglevel (console_printk[0])
+#define default_message_loglevel (console_printk[1])
+#define minimum_console_loglevel (console_printk[2])
+#define default_console_loglevel (console_printk[3])
+
/*
* FW_BUG
* Add this to a message where you are sure the firmware is buggy or behaves
@@ -302,37 +470,6 @@ static inline void console_verbose(void)
extern void bust_spinlocks(int yes);
extern void wake_up_klogd(void);
extern int oops_in_progress; /* If set, an oops, panic(), BUG() or die() is in progress */
-extern int panic_timeout;
-extern int panic_on_oops;
-extern int panic_on_unrecovered_nmi;
-extern int panic_on_io_nmi;
-extern const char *print_tainted(void);
-extern void add_taint(unsigned flag);
-extern int test_taint(unsigned flag);
-extern unsigned long get_taint(void);
-extern int root_mountflags;
-
-/* Values used for system_state */
-extern enum system_states {
- SYSTEM_BOOTING,
- SYSTEM_RUNNING,
- SYSTEM_HALT,
- SYSTEM_POWER_OFF,
- SYSTEM_RESTART,
- SYSTEM_SUSPEND_DISK,
-} system_state;
-
-#define TAINT_PROPRIETARY_MODULE 0
-#define TAINT_FORCED_MODULE 1
-#define TAINT_UNSAFE_SMP 2
-#define TAINT_FORCED_RMMOD 3
-#define TAINT_MACHINE_CHECK 4
-#define TAINT_BAD_PAGE 5
-#define TAINT_USER 6
-#define TAINT_DIE 7
-#define TAINT_OVERRIDDEN_ACPI_TABLE 8
-#define TAINT_WARN 9
-#define TAINT_CRAP 10
extern void dump_stack(void) __cold;
@@ -350,16 +487,6 @@ extern void print_hex_dump(const char *level, const char *prefix_str,
extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
const void *buf, size_t len);
-extern const char hex_asc[];
-#define hex_asc_lo(x) hex_asc[((x) & 0x0f)]
-#define hex_asc_hi(x) hex_asc[((x) & 0xf0) >> 4]
-
-static inline char *pack_hex_byte(char *buf, u8 byte)
-{
- *buf++ = hex_asc_hi(byte);
- *buf++ = hex_asc_lo(byte);
- return buf;
-}
#ifndef pr_fmt
#define pr_fmt(fmt) fmt
@@ -581,124 +708,6 @@ ftrace_vprintk(const char *fmt, va_list ap)
static inline void ftrace_dump(void) { }
#endif /* CONFIG_TRACING */
-/*
- * Display an IP address in readable format.
- */
-
-#define NIPQUAD(addr) \
- ((unsigned char *)&addr)[0], \
- ((unsigned char *)&addr)[1], \
- ((unsigned char *)&addr)[2], \
- ((unsigned char *)&addr)[3]
-#define NIPQUAD_FMT "%u.%u.%u.%u"
-
-/*
- * min()/max()/clamp() macros that also do
- * strict type-checking.. See the
- * "unnecessary" pointer comparison.
- */
-#define min(x, y) ({ \
- typeof(x) _min1 = (x); \
- typeof(y) _min2 = (y); \
- (void) (&_min1 == &_min2); \
- _min1 < _min2 ? _min1 : _min2; })
-
-#define max(x, y) ({ \
- typeof(x) _max1 = (x); \
- typeof(y) _max2 = (y); \
- (void) (&_max1 == &_max2); \
- _max1 > _max2 ? _max1 : _max2; })
-
-/**
- * clamp - return a value clamped to a given range with strict typechecking
- * @val: current value
- * @min: minimum allowable value
- * @max: maximum allowable value
- *
- * This macro does strict typechecking of min/max to make sure they are of the
- * same type as val. See the unnecessary pointer comparisons.
- */
-#define clamp(val, min, max) ({ \
- typeof(val) __val = (val); \
- typeof(min) __min = (min); \
- typeof(max) __max = (max); \
- (void) (&__val == &__min); \
- (void) (&__val == &__max); \
- __val = __val < __min ? __min: __val; \
- __val > __max ? __max: __val; })
-
-/*
- * ..and if you can't take the strict
- * types, you can specify one yourself.
- *
- * Or not use min/max/clamp at all, of course.
- */
-#define min_t(type, x, y) ({ \
- type __min1 = (x); \
- type __min2 = (y); \
- __min1 < __min2 ? __min1: __min2; })
-
-#define max_t(type, x, y) ({ \
- type __max1 = (x); \
- type __max2 = (y); \
- __max1 > __max2 ? __max1: __max2; })
-
-/**
- * clamp_t - return a value clamped to a given range using a given type
- * @type: the type of variable to use
- * @val: current value
- * @min: minimum allowable value
- * @max: maximum allowable value
- *
- * This macro does no typechecking and uses temporary variables of type
- * 'type' to make all the comparisons.
- */
-#define clamp_t(type, val, min, max) ({ \
- type __val = (val); \
- type __min = (min); \
- type __max = (max); \
- __val = __val < __min ? __min: __val; \
- __val > __max ? __max: __val; })
-
-/**
- * clamp_val - return a value clamped to a given range using val's type
- * @val: current value
- * @min: minimum allowable value
- * @max: maximum allowable value
- *
- * This macro does no typechecking and uses temporary variables of whatever
- * type the input argument 'val' is. This is useful when val is an unsigned
- * type and min and max are literals that will otherwise be assigned a signed
- * integer type.
- */
-#define clamp_val(val, min, max) ({ \
- typeof(val) __val = (val); \
- typeof(val) __min = (min); \
- typeof(val) __max = (max); \
- __val = __val < __min ? __min: __val; \
- __val > __max ? __max: __val; })
-
-
-/*
- * swap - swap value of @a and @b
- */
-#define swap(a, b) \
- do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0)
-
-/**
- * container_of - cast a member of a structure out to the containing structure
- * @ptr: the pointer to the member.
- * @type: the type of the container struct this is embedded in.
- * @member: the name of the member within the struct.
- *
- */
-#define container_of(ptr, type, member) ({ \
- const typeof( ((type *)0)->member ) *__mptr = (ptr); \
- (type *)( (char *)__mptr - offsetof(type,member) );})
-
-struct sysinfo;
-extern int do_sysinfo(struct sysinfo *info);
-
#endif /* __KERNEL__ */
#ifndef __EXPORTED_HEADERS__
--
1.6.6.rc0.57.gad7a
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 02/14] kernel.h: Checkpatch cleaning
2009-12-16 8:08 [PATCH 00/14] kernel.h cleanups Joe Perches
2009-12-16 8:09 ` [PATCH 01/14] kernel.h: Consolidate console and logging functions and defines Joe Perches
@ 2009-12-16 8:09 ` Joe Perches
2009-12-16 8:09 ` [PATCH 03/14] kernel.h: ARRAY_SIZE neatening Joe Perches
` (12 subsequent siblings)
14 siblings, 0 replies; 18+ messages in thread
From: Joe Perches @ 2009-12-16 8:09 UTC (permalink / raw)
To: Linus Torvalds; +Cc: linux-kernel
The warnings and errors still generated aren't interesting
was: total: 43 errors, 8 warnings, 756 lines checked
is: total: 3 errors, 7 warnings, 766 lines checked
Signed-off-by: Joe Perches <joe@perches.com>
---
include/linux/kernel.h | 127 ++++++++++++++++++++++++------------------------
1 files changed, 64 insertions(+), 63 deletions(-)
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index c9cdfca..2cc6d70 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -16,56 +16,54 @@
#include <linux/log2.h>
#include <linux/typecheck.h>
#include <linux/dynamic_debug.h>
+#include <linux/bug.h>
#include <asm/byteorder.h>
-#include <asm/bug.h>
#define USHORT_MAX ((u16)(~0U))
-#define SHORT_MAX ((s16)(USHORT_MAX>>1))
+#define SHORT_MAX ((s16)(USHORT_MAX >> 1))
#define SHORT_MIN (-SHORT_MAX - 1)
-#define INT_MAX ((int)(~0U>>1))
+#define INT_MAX ((int)(~0U >> 1))
#define INT_MIN (-INT_MAX - 1)
#define UINT_MAX (~0U)
#define LONG_MAX ((long)(~0UL>>1))
#define LONG_MIN (-LONG_MAX - 1)
#define ULONG_MAX (~0UL)
-#define LLONG_MAX ((long long)(~0ULL>>1))
+#define LLONG_MAX ((long long)(~0ULL >> 1))
#define LLONG_MIN (-LLONG_MAX - 1)
#define ULLONG_MAX (~0ULL)
#define STACK_MAGIC 0xdeadbeef
-#define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1)
-#define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask))
+#define __ALIGN_MASK(x, mask) (((x) + (mask)) & ~(mask))
+#define ALIGN(x, a) __ALIGN_MASK(x, (typeof(x))(a) - 1)
#define PTR_ALIGN(p, a) ((typeof(p))ALIGN((unsigned long)(p), (a)))
-#define IS_ALIGNED(x, a) (((x) & ((typeof(x))(a) - 1)) == 0)
+#define IS_ALIGNED(x, a) (((x) & ((typeof(x))(a) - 1)) == 0)
-#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
+#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
+#define FIELD_SIZEOF(t, f) (sizeof(((t *)0)->f))
-#define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f))
-#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
-#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
-#define DIV_ROUND_CLOSEST(x, divisor)( \
-{ \
+#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
+#define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
+#define DIV_ROUND_CLOSEST(x, divisor) \
+({ \
typeof(divisor) __divisor = divisor; \
(((x) + ((__divisor) / 2)) / (__divisor)); \
-} \
-)
+})
-#define _RET_IP_ (unsigned long)__builtin_return_address(0)
-#define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; })
+#define _RET_IP_ (unsigned long)__builtin_return_address(0)
+#define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; })
#ifdef CONFIG_LBDAF
# include <asm/div64.h>
# define sector_div(a, b) do_div(a, b)
#else
-# define sector_div(n, b)( \
-{ \
- int _res; \
- _res = (n) % (b); \
- (n) /= (b); \
- _res; \
-} \
-)
+# define sector_div(n, b) \
+({ \
+ int _res; \
+ _res = (n) % (b); \
+ (n) /= (b); \
+ _res; \
+})
#endif
/**
@@ -76,13 +74,13 @@
* the "right shift count >= width of type" warning when that quantity is
* 32-bits.
*/
-#define upper_32_bits(n) ((u32)(((n) >> 16) >> 16))
+#define upper_32_bits(n) ((u32)(((n) >> 16) >> 16))
/**
* lower_32_bits - return bits 0-31 of a number
* @n: the number we're accessing
*/
-#define lower_32_bits(n) ((u32)(n))
+#define lower_32_bits(n) ((u32)(n))
struct completion;
struct pt_regs;
@@ -96,7 +94,7 @@ extern int _cond_resched(void);
#endif
#ifdef CONFIG_DEBUG_SPINLOCK_SLEEP
- void __might_sleep(char *file, int line, int preempt_offset);
+void __might_sleep(char *file, int line, int preempt_offset);
/**
* might_sleep - annotation for functions that can sleep
*
@@ -116,10 +114,11 @@ extern int _cond_resched(void);
#define might_sleep_if(cond) do { if (cond) might_sleep(); } while (0)
-#define abs(x) ({ \
- long __x = (x); \
- (__x < 0) ? -__x : __x; \
- })
+#define abs(x) \
+({ \
+ long __x = (x); \
+ (__x < 0) ? -__x : __x; \
+})
#ifdef CONFIG_PROVE_LOCKING
void might_fault(void);
@@ -132,7 +131,7 @@ static inline void might_fault(void)
extern struct atomic_notifier_head panic_notifier_list;
extern long (*panic_blink)(long time);
-NORET_TYPE void panic(const char * fmt, ...)
+NORET_TYPE void panic(const char *fmt, ...)
__attribute__ ((NORET_AND format (printf, 1, 2))) __cold;
extern void oops_enter(void);
extern void oops_exit(void);
@@ -141,23 +140,23 @@ NORET_TYPE void do_exit(long error_code)
ATTRIB_NORET;
NORET_TYPE void complete_and_exit(struct completion *, long)
ATTRIB_NORET;
-extern unsigned long simple_strtoul(const char *,char **,unsigned int);
-extern long simple_strtol(const char *,char **,unsigned int);
-extern unsigned long long simple_strtoull(const char *,char **,unsigned int);
-extern long long simple_strtoll(const char *,char **,unsigned int);
+extern unsigned long simple_strtoul(const char *, char **, unsigned int);
+extern long simple_strtol(const char *, char **, unsigned int);
+extern unsigned long long simple_strtoull(const char *, char **, unsigned int);
+extern long long simple_strtoll(const char *, char **, unsigned int);
extern int strict_strtoul(const char *, unsigned int, unsigned long *);
extern int strict_strtol(const char *, unsigned int, long *);
extern int strict_strtoull(const char *, unsigned int, unsigned long long *);
extern int strict_strtoll(const char *, unsigned int, long long *);
-extern int sprintf(char * buf, const char * fmt, ...)
+extern int sprintf(char *buf, const char *fmt, ...)
__attribute__ ((format (printf, 2, 3)));
extern int vsprintf(char *buf, const char *, va_list)
__attribute__ ((format (printf, 2, 0)));
-extern int snprintf(char * buf, size_t size, const char * fmt, ...)
+extern int snprintf(char *buf, size_t size, const char *fmt, ...)
__attribute__ ((format (printf, 3, 4)));
extern int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
__attribute__ ((format (printf, 3, 0)));
-extern int scnprintf(char * buf, size_t size, const char * fmt, ...)
+extern int scnprintf(char *buf, size_t size, const char *fmt, ...)
__attribute__ ((format (printf, 3, 4)));
extern int vscnprintf(char *buf, size_t size, const char *fmt, va_list args)
__attribute__ ((format (printf, 3, 0)));
@@ -270,8 +269,8 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
typeof(max) __max = (max); \
(void) (&__val == &__min); \
(void) (&__val == &__max); \
- __val = __val < __min ? __min: __val; \
- __val > __max ? __max: __val; })
+ __val = __val < __min ? __min : __val; \
+ __val > __max ? __max : __val; })
/*
* ..and if you can't take the strict
@@ -282,12 +281,12 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
#define min_t(type, x, y) ({ \
type __min1 = (x); \
type __min2 = (y); \
- __min1 < __min2 ? __min1: __min2; })
+ __min1 < __min2 ? __min1 : __min2; })
#define max_t(type, x, y) ({ \
type __max1 = (x); \
type __max2 = (y); \
- __max1 > __max2 ? __max1: __max2; })
+ __max1 > __max2 ? __max1 : __max2; })
/**
* clamp_t - return a value clamped to a given range using a given type
@@ -303,8 +302,8 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
type __val = (val); \
type __min = (min); \
type __max = (max); \
- __val = __val < __min ? __min: __val; \
- __val > __max ? __max: __val; })
+ __val = __val < __min ? __min : __val; \
+ __val > __max ? __max : __val; })
/**
* clamp_val - return a value clamped to a given range using val's type
@@ -321,8 +320,8 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
typeof(val) __val = (val); \
typeof(val) __min = (min); \
typeof(val) __max = (max); \
- __val = __val < __min ? __min: __val; \
- __val > __max ? __max: __val; })
+ __val = __val < __min ? __min : __val; \
+ __val > __max ? __max : __val; })
/*
@@ -339,8 +338,8 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
*
*/
#define container_of(ptr, type, member) ({ \
- const typeof( ((type *)0)->member ) *__mptr = (ptr); \
- (type *)( (char *)__mptr - offsetof(type,member) ); \
+ const typeof(((type *)0)->member) *__mptr = (ptr); \
+ (type *)((char *)__mptr - offsetof(type, member)); \
})
struct sysinfo;
@@ -385,7 +384,7 @@ extern int console_printk[];
* should be able to fix this issue or at least get a concrete idea of the
* problem by reading your message without the need of looking at the kernel
* code.
- *
+ *
* Use it for definite and high priority BIOS bugs.
*
* FW_WARN
@@ -405,7 +404,7 @@ extern int console_printk[];
#ifdef CONFIG_PRINTK
asmlinkage int vprintk(const char *fmt, va_list args)
__attribute__ ((format (printf, 1, 0)));
-asmlinkage int printk(const char * fmt, ...)
+asmlinkage int printk(const char *fmt, ...)
__attribute__ ((format (printf, 1, 2))) __cold;
extern int __printk_ratelimit(const char *func);
@@ -469,7 +468,9 @@ static inline void console_verbose(void)
extern void bust_spinlocks(int yes);
extern void wake_up_klogd(void);
-extern int oops_in_progress; /* If set, an oops, panic(), BUG() or die() is in progress */
+
+/* If set, an oops, panic(), BUG() or die() is in progress */
+extern int oops_in_progress;
extern void dump_stack(void) __cold;
@@ -493,19 +494,19 @@ extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
#endif
#define pr_emerg(fmt, ...) \
- printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
+ printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
#define pr_alert(fmt, ...) \
- printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
+ printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
#define pr_crit(fmt, ...) \
- printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
+ printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
#define pr_err(fmt, ...) \
- printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
+ printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
#define pr_warning(fmt, ...) \
- printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
+ printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
#define pr_notice(fmt, ...) \
- printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
+ printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
#define pr_info(fmt, ...) \
- printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
+ printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
#define pr_cont(fmt, ...) \
printk(KERN_CONT fmt, ##__VA_ARGS__)
@@ -738,14 +739,14 @@ struct sysinfo {
#define BUILD_BUG_ON(condition) ((void)BUILD_BUG_ON_ZERO(condition))
/* Force a compilation error if condition is constant and true */
-#define MAYBE_BUILD_BUG_ON(cond) ((void)sizeof(char[1 - 2 * !!(cond)]))
+#define MAYBE_BUILD_BUG_ON(cond) ((void)sizeof(char[1 - 2 * !!(cond)]))
/* Force a compilation error if condition is true, but also produce a
result (of value 0 and type size_t), so the expression can be used
e.g. in a structure initializer (or where-ever else comma expressions
aren't permitted). */
-#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))
-#define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:-!!(e); }))
+#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))
+#define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:-!!(e); }))
/* Trap pasters of __FUNCTION__ at compile-time */
#define __FUNCTION__ (__func__)
--
1.6.6.rc0.57.gad7a
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 03/14] kernel.h: ARRAY_SIZE neatening
2009-12-16 8:08 [PATCH 00/14] kernel.h cleanups Joe Perches
2009-12-16 8:09 ` [PATCH 01/14] kernel.h: Consolidate console and logging functions and defines Joe Perches
2009-12-16 8:09 ` [PATCH 02/14] kernel.h: Checkpatch cleaning Joe Perches
@ 2009-12-16 8:09 ` Joe Perches
2009-12-16 8:09 ` [PATCH 04/14] kernel.h: Add argument names to strtoXX, Xscanf prototypes Joe Perches
` (11 subsequent siblings)
14 siblings, 0 replies; 18+ messages in thread
From: Joe Perches @ 2009-12-16 8:09 UTC (permalink / raw)
To: Linus Torvalds; +Cc: linux-kernel
Make < 80 column, use array as name
Signed-off-by: Joe Perches <joe@perches.com>
---
include/linux/kernel.h | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 2cc6d70..9206268 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -39,7 +39,8 @@
#define PTR_ALIGN(p, a) ((typeof(p))ALIGN((unsigned long)(p), (a)))
#define IS_ALIGNED(x, a) (((x) & ((typeof(x))(a) - 1)) == 0)
-#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
+#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]) + \
+ __must_be_array(array))
#define FIELD_SIZEOF(t, f) (sizeof(((t *)0)->f))
#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
--
1.6.6.rc0.57.gad7a
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 04/14] kernel.h: Add argument names to strtoXX, Xscanf prototypes
2009-12-16 8:08 [PATCH 00/14] kernel.h cleanups Joe Perches
` (2 preceding siblings ...)
2009-12-16 8:09 ` [PATCH 03/14] kernel.h: ARRAY_SIZE neatening Joe Perches
@ 2009-12-16 8:09 ` Joe Perches
2009-12-16 8:09 ` [PATCH 05/14] kernel.h: printk neatening Joe Perches
` (10 subsequent siblings)
14 siblings, 0 replies; 18+ messages in thread
From: Joe Perches @ 2009-12-16 8:09 UTC (permalink / raw)
To: Linus Torvalds; +Cc: linux-kernel
It's easier to parse prototypes with argument names.
Signed-off-by: Joe Perches <joe@perches.com>
---
include/linux/kernel.h | 36 ++++++++++++++++++++++++------------
1 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 9206268..75e7439 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -137,18 +137,30 @@ NORET_TYPE void panic(const char *fmt, ...)
extern void oops_enter(void);
extern void oops_exit(void);
extern int oops_may_print(void);
-NORET_TYPE void do_exit(long error_code)
+NORET_TYPE void do_exit(long code)
ATTRIB_NORET;
-NORET_TYPE void complete_and_exit(struct completion *, long)
+NORET_TYPE void complete_and_exit(struct completion *comp, long code)
ATTRIB_NORET;
-extern unsigned long simple_strtoul(const char *, char **, unsigned int);
-extern long simple_strtol(const char *, char **, unsigned int);
-extern unsigned long long simple_strtoull(const char *, char **, unsigned int);
-extern long long simple_strtoll(const char *, char **, unsigned int);
-extern int strict_strtoul(const char *, unsigned int, unsigned long *);
-extern int strict_strtol(const char *, unsigned int, long *);
-extern int strict_strtoull(const char *, unsigned int, unsigned long long *);
-extern int strict_strtoll(const char *, unsigned int, long long *);
+
+/*
+ * stdlib - String to type conversions
+ */
+extern unsigned long simple_strtoul(const char *cp, char **endp,
+ unsigned int base);
+extern long simple_strtol(const char *cp, char **endp, unsigned int base);
+extern unsigned long long simple_strtoull(const char *cp, char **endp,
+ unsigned int base);
+extern long long simple_strtoll(const char *cp, char **endp, unsigned int base);
+extern int strict_strtoul(const char *cp, unsigned int base,
+ unsigned long *res);
+extern int strict_strtol(const char *cp, unsigned int base, long *res);
+extern int strict_strtoull(const char *cp, unsigned int base,
+ unsigned long long *res);
+extern int strict_strtoll(const char *cp, unsigned int base, long long *res);
+
+/*
+ * string - String handling
+ */
extern int sprintf(char *buf, const char *fmt, ...)
__attribute__ ((format (printf, 2, 3)));
extern int vsprintf(char *buf, const char *, va_list)
@@ -165,9 +177,9 @@ extern char *kasprintf(gfp_t gfp, const char *fmt, ...)
__attribute__ ((format (printf, 2, 3)));
extern char *kvasprintf(gfp_t gfp, const char *fmt, va_list args);
-extern int sscanf(const char *, const char *, ...)
+extern int sscanf(const char *buf, const char *fmt, ...)
__attribute__ ((format (scanf, 2, 3)));
-extern int vsscanf(const char *, const char *, va_list)
+extern int vsscanf(const char *buf, const char *fmt, va_list)
__attribute__ ((format (scanf, 2, 0)));
extern int get_option(char **str, int *pint);
--
1.6.6.rc0.57.gad7a
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 05/14] kernel.h: printk neatening
2009-12-16 8:08 [PATCH 00/14] kernel.h cleanups Joe Perches
` (3 preceding siblings ...)
2009-12-16 8:09 ` [PATCH 04/14] kernel.h: Add argument names to strtoXX, Xscanf prototypes Joe Perches
@ 2009-12-16 8:09 ` Joe Perches
2009-12-16 8:09 ` [PATCH 06/14] drivers/firmware/iscsi_ibft.c: Use %pI4 to print netmask Joe Perches
` (9 subsequent siblings)
14 siblings, 0 replies; 18+ messages in thread
From: Joe Perches @ 2009-12-16 8:09 UTC (permalink / raw)
To: Linus Torvalds; +Cc: linux-kernel
Make a few printk elements a bit more consistent
Remove trailing backslashes from static inline prototype
Use fmt and ##__VA_ARGS__ in printk_once
Make statement expressions multiline
Use tabs for #define foo bar
Signed-off-by: Joe Perches <joe@perches.com>
---
include/linux/kernel.h | 90 ++++++++++++++++++++++++++++--------------------
1 files changed, 53 insertions(+), 37 deletions(-)
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 75e7439..f7144b1 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -385,10 +385,10 @@ extern const char linux_proc_banner[];
extern int console_printk[];
-#define console_loglevel (console_printk[0])
-#define default_message_loglevel (console_printk[1])
-#define minimum_console_loglevel (console_printk[2])
-#define default_console_loglevel (console_printk[3])
+#define console_loglevel (console_printk[0])
+#define default_message_loglevel (console_printk[1])
+#define minimum_console_loglevel (console_printk[2])
+#define default_console_loglevel (console_printk[3])
/*
* FW_BUG
@@ -430,12 +430,13 @@ extern int printk_delay_msec;
/*
* Print a one-time message (analogous to WARN_ONCE() et al):
*/
-#define printk_once(x...) ({ \
+#define printk_once(fmt, ...) \
+({ \
static bool __print_once; \
\
if (!__print_once) { \
__print_once = true; \
- printk(x); \
+ printk(fmt, ##__VA_ARGS__); \
} \
})
@@ -448,12 +449,14 @@ static inline int printk(const char *s, ...)
__attribute__ ((format (printf, 1, 2)));
static inline int __cold printk(const char *s, ...) { return 0; }
static inline int printk_ratelimit(void) { return 0; }
-static inline bool printk_timed_ratelimit(unsigned long *caller_jiffies, \
- unsigned int interval_msec) \
- { return false; }
+static inline bool printk_timed_ratelimit(unsigned long *caller_jiffies,
+ unsigned int interval_msec)
+{
+ return false;
+}
/* No effect, but we still get type checking even in the !PRINTK case: */
-#define printk_once(x...) printk(x)
+#define printk_once(fmt, ...) printk(fmt, ##__VA_ARGS__)
static inline void log_buf_kexec_setup(void)
{
@@ -506,43 +509,51 @@ extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
#define pr_fmt(fmt) fmt
#endif
-#define pr_emerg(fmt, ...) \
+#define pr_emerg(fmt, ...) \
printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_alert(fmt, ...) \
+#define pr_alert(fmt, ...) \
printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_crit(fmt, ...) \
+#define pr_crit(fmt, ...) \
printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_err(fmt, ...) \
+#define pr_err(fmt, ...) \
printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_warning(fmt, ...) \
+#define pr_warning(fmt, ...) \
printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_notice(fmt, ...) \
+#define pr_notice(fmt, ...) \
printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_info(fmt, ...) \
+#define pr_info(fmt, ...) \
printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_cont(fmt, ...) \
+#define pr_cont(fmt, ...) \
printk(KERN_CONT fmt, ##__VA_ARGS__)
/* pr_devel() should produce zero code unless DEBUG is defined */
#ifdef DEBUG
-#define pr_devel(fmt, ...) \
+#define pr_devel(fmt, ...) \
printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
#else
-#define pr_devel(fmt, ...) \
- ({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; })
+#define pr_devel(fmt, ...) \
+({ \
+ if (0) \
+ printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); \
+ 0; \
+})
#endif
/* If you are writing a driver, please use dev_dbg instead */
#if defined(DEBUG)
-#define pr_debug(fmt, ...) \
+#define pr_debug(fmt, ...) \
printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
#elif defined(CONFIG_DYNAMIC_DEBUG)
/* dynamic_pr_debug() uses pr_fmt() internally so we don't need it here */
-#define pr_debug(fmt, ...) \
+#define pr_debug(fmt, ...) \
dynamic_pr_debug(fmt, ##__VA_ARGS__)
#else
-#define pr_debug(fmt, ...) \
- ({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; })
+#define pr_debug(fmt, ...) \
+({ \
+ if (0) \
+ printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); \
+ 0; \
+})
#endif
/*
@@ -550,7 +561,8 @@ extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
* no local ratelimit_state used in the !PRINTK case
*/
#ifdef CONFIG_PRINTK
-#define printk_ratelimited(fmt, ...) ({ \
+#define printk_ratelimited(fmt, ...) \
+({ \
static struct ratelimit_state _rs = { \
.interval = DEFAULT_RATELIMIT_INTERVAL, \
.burst = DEFAULT_RATELIMIT_BURST, \
@@ -564,29 +576,33 @@ extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
#define printk_ratelimited printk
#endif
-#define pr_emerg_ratelimited(fmt, ...) \
+#define pr_emerg_ratelimited(fmt, ...) \
printk_ratelimited(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_alert_ratelimited(fmt, ...) \
+#define pr_alert_ratelimited(fmt, ...) \
printk_ratelimited(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_crit_ratelimited(fmt, ...) \
+#define pr_crit_ratelimited(fmt, ...) \
printk_ratelimited(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_err_ratelimited(fmt, ...) \
+#define pr_err_ratelimited(fmt, ...) \
printk_ratelimited(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_warning_ratelimited(fmt, ...) \
+#define pr_warning_ratelimited(fmt, ...) \
printk_ratelimited(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_notice_ratelimited(fmt, ...) \
+#define pr_notice_ratelimited(fmt, ...) \
printk_ratelimited(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_info_ratelimited(fmt, ...) \
+#define pr_info_ratelimited(fmt, ...) \
printk_ratelimited(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
/* no pr_cont_ratelimited, don't do that... */
/* If you are writing a driver, please use dev_dbg instead */
#if defined(DEBUG)
-#define pr_debug_ratelimited(fmt, ...) \
+#define pr_debug_ratelimited(fmt, ...) \
printk_ratelimited(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
#else
-#define pr_debug_ratelimited(fmt, ...) \
- ({ if (0) printk_ratelimited(KERN_DEBUG pr_fmt(fmt), \
- ##__VA_ARGS__); 0; })
+#define pr_debug_ratelimited(fmt, ...) \
+({ \
+ if (0) \
+ printk_ratelimited(KERN_DEBUG pr_fmt(fmt), \
+ ##__VA_ARGS__); \
+ 0; \
+})
#endif
/*
--
1.6.6.rc0.57.gad7a
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 06/14] drivers/firmware/iscsi_ibft.c: Use %pI4 to print netmask
2009-12-16 8:08 [PATCH 00/14] kernel.h cleanups Joe Perches
` (4 preceding siblings ...)
2009-12-16 8:09 ` [PATCH 05/14] kernel.h: printk neatening Joe Perches
@ 2009-12-16 8:09 ` Joe Perches
2009-12-16 8:09 ` [PATCH 07/14] kernel.h: Move NIPQUAD and NIPQUAD_FMT to in.h Joe Perches
` (8 subsequent siblings)
14 siblings, 0 replies; 18+ messages in thread
From: Joe Perches @ 2009-12-16 8:09 UTC (permalink / raw)
To: Linus Torvalds; +Cc: linux-kernel
Signed-off-by: Joe Perches <joe@perches.com>
---
drivers/firmware/iscsi_ibft.c | 8 +++-----
1 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/firmware/iscsi_ibft.c b/drivers/firmware/iscsi_ibft.c
index 051d1eb..f82bcda 100644
--- a/drivers/firmware/iscsi_ibft.c
+++ b/drivers/firmware/iscsi_ibft.c
@@ -381,7 +381,7 @@ static ssize_t ibft_attr_show_nic(struct ibft_kobject *entry,
void *ibft_loc = entry->header;
char *str = buf;
char *mac;
- int val;
+ __be32 val;
if (!nic)
return 0;
@@ -397,10 +397,8 @@ static ssize_t ibft_attr_show_nic(struct ibft_kobject *entry,
str += sprintf_ipaddr(str, nic->ip_addr);
break;
case ibft_eth_subnet_mask:
- val = ~((1 << (32-nic->subnet_mask_prefix))-1);
- str += sprintf(str, NIPQUAD_FMT,
- (u8)(val >> 24), (u8)(val >> 16),
- (u8)(val >> 8), (u8)(val));
+ val = cpu_to_be32(~((1 << (32-nic->subnet_mask_prefix))-1));
+ str += sprintf(str, "%pI4", &val);
break;
case ibft_eth_origin:
str += sprintf(str, "%d\n", nic->origin);
--
1.6.6.rc0.57.gad7a
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 07/14] kernel.h: Move NIPQUAD and NIPQUAD_FMT to in.h
2009-12-16 8:08 [PATCH 00/14] kernel.h cleanups Joe Perches
` (5 preceding siblings ...)
2009-12-16 8:09 ` [PATCH 06/14] drivers/firmware/iscsi_ibft.c: Use %pI4 to print netmask Joe Perches
@ 2009-12-16 8:09 ` Joe Perches
2009-12-16 8:09 ` [PATCH 08/14] kernel.h: Group math and limits functions, indent function args Joe Perches
` (7 subsequent siblings)
14 siblings, 0 replies; 18+ messages in thread
From: Joe Perches @ 2009-12-16 8:09 UTC (permalink / raw)
To: Linus Torvalds; +Cc: linux-kernel
Move the #defines to where they're actually useful.
All the current uses of NIPQUAD still compile successfully.
Signed-off-by: Joe Perches <joe@perches.com>
---
include/linux/in.h | 11 +++++++++++
include/linux/kernel.h | 11 -----------
2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/include/linux/in.h b/include/linux/in.h
index b615649..4e0f177 100644
--- a/include/linux/in.h
+++ b/include/linux/in.h
@@ -247,6 +247,17 @@ struct sockaddr_in {
#ifdef __KERNEL__
+/*
+ * Display an IP address in readable format.
+ */
+
+#define NIPQUAD(addr) \
+ ((unsigned char *)&addr)[0], \
+ ((unsigned char *)&addr)[1], \
+ ((unsigned char *)&addr)[2], \
+ ((unsigned char *)&addr)[3]
+#define NIPQUAD_FMT "%u.%u.%u.%u"
+
static inline bool ipv4_is_loopback(__be32 addr)
{
return (addr & htonl(0xff000000)) == htonl(0x7f000000);
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index f7144b1..1764d2d 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -240,17 +240,6 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
}
/*
- * Display an IP address in readable format.
- */
-
-#define NIPQUAD(addr) \
- ((unsigned char *)&addr)[0], \
- ((unsigned char *)&addr)[1], \
- ((unsigned char *)&addr)[2], \
- ((unsigned char *)&addr)[3]
-#define NIPQUAD_FMT "%u.%u.%u.%u"
-
-/*
* min()/max()/clamp() macros that also do
* strict type-checking.. See the
* "unnecessary" pointer comparison.
--
1.6.6.rc0.57.gad7a
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 08/14] kernel.h: Group math and limits functions, indent function args
2009-12-16 8:08 [PATCH 00/14] kernel.h cleanups Joe Perches
` (6 preceding siblings ...)
2009-12-16 8:09 ` [PATCH 07/14] kernel.h: Move NIPQUAD and NIPQUAD_FMT to in.h Joe Perches
@ 2009-12-16 8:09 ` Joe Perches
2009-12-16 8:09 ` [PATCH 09/14] kernel.h: Don't use NORET_AND just use noreturn, instead Joe Perches
` (6 subsequent siblings)
14 siblings, 0 replies; 18+ messages in thread
From: Joe Perches @ 2009-12-16 8:09 UTC (permalink / raw)
To: Linus Torvalds; +Cc: linux-kernel
Use a bit more standardized statement expression format
Signed-off-by:; Joe Perches <joe@perches.com>
---
include/linux/kernel.h | 72 +++++++++++++++++++++++++++++------------------
1 files changed, 44 insertions(+), 28 deletions(-)
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 1764d2d..97c80c7 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -115,12 +115,6 @@ void __might_sleep(char *file, int line, int preempt_offset);
#define might_sleep_if(cond) do { if (cond) might_sleep(); } while (0)
-#define abs(x) \
-({ \
- long __x = (x); \
- (__x < 0) ? -__x : __x; \
-})
-
#ifdef CONFIG_PROVE_LOCKING
void might_fault(void);
#else
@@ -240,21 +234,36 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
}
/*
+ * stdlib - limits and maths
+ */
+#define abs(x) \
+({ \
+ long __x = (x); \
+ (__x < 0) ? -__x : __x; \
+})
+
+unsigned long int_sqrt(unsigned long);
+
+/*
* min()/max()/clamp() macros that also do
* strict type-checking.. See the
* "unnecessary" pointer comparison.
*/
-#define min(x, y) ({ \
+#define min(x, y) \
+({ \
typeof(x) _min1 = (x); \
typeof(y) _min2 = (y); \
(void) (&_min1 == &_min2); \
- _min1 < _min2 ? _min1 : _min2; })
+ _min1 < _min2 ? _min1 : _min2; \
+})
-#define max(x, y) ({ \
+#define max(x, y) \
+({ \
typeof(x) _max1 = (x); \
typeof(y) _max2 = (y); \
(void) (&_max1 == &_max2); \
- _max1 > _max2 ? _max1 : _max2; })
+ _max1 > _max2 ? _max1 : _max2; \
+})
/**
* clamp - return a value clamped to a given range with strict typechecking
@@ -265,14 +274,16 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
* This macro does strict typechecking of min/max to make sure they are of the
* same type as val. See the unnecessary pointer comparisons.
*/
-#define clamp(val, min, max) ({ \
+#define clamp(val, min, max) \
+({ \
typeof(val) __val = (val); \
typeof(min) __min = (min); \
typeof(max) __max = (max); \
(void) (&__val == &__min); \
(void) (&__val == &__max); \
__val = __val < __min ? __min : __val; \
- __val > __max ? __max : __val; })
+ __val > __max ? __max : __val; \
+})
/*
* ..and if you can't take the strict
@@ -280,15 +291,19 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
*
* Or not use min/max/clamp at all, of course.
*/
-#define min_t(type, x, y) ({ \
+#define min_t(type, x, y) \
+({ \
type __min1 = (x); \
type __min2 = (y); \
- __min1 < __min2 ? __min1 : __min2; })
+ __min1 < __min2 ? __min1 : __min2; \
+})
-#define max_t(type, x, y) ({ \
+#define max_t(type, x, y) \
+({ \
type __max1 = (x); \
type __max2 = (y); \
- __max1 > __max2 ? __max1 : __max2; })
+ __max1 > __max2 ? __max1 : __max2; \
+})
/**
* clamp_t - return a value clamped to a given range using a given type
@@ -300,12 +315,14 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
* This macro does no typechecking and uses temporary variables of type
* 'type' to make all the comparisons.
*/
-#define clamp_t(type, val, min, max) ({ \
+#define clamp_t(type, val, min, max) \
+({ \
type __val = (val); \
type __min = (min); \
type __max = (max); \
__val = __val < __min ? __min : __val; \
- __val > __max ? __max : __val; })
+ __val > __max ? __max : __val; \
+})
/**
* clamp_val - return a value clamped to a given range using val's type
@@ -318,13 +335,14 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
* type and min and max are literals that will otherwise be assigned a signed
* integer type.
*/
-#define clamp_val(val, min, max) ({ \
+#define clamp_val(val, min, max) \
+({ \
typeof(val) __val = (val); \
typeof(val) __min = (min); \
typeof(val) __max = (max); \
__val = __val < __min ? __min : __val; \
- __val > __max ? __max : __val; })
-
+ __val > __max ? __max : __val; \
+})
/*
* swap - swap value of @a and @b
@@ -458,8 +476,6 @@ extern void printk_tick(void);
extern void asmlinkage __attribute__((format(printf, 1, 2)))
early_printk(const char *fmt, ...);
-unsigned long int_sqrt(unsigned long);
-
static inline void console_silent(void)
{
console_loglevel = 0;
@@ -485,13 +501,13 @@ enum {
DUMP_PREFIX_OFFSET
};
extern void hex_dump_to_buffer(const void *buf, size_t len,
- int rowsize, int groupsize,
- char *linebuf, size_t linebuflen, bool ascii);
+ int rowsize, int groupsize,
+ char *linebuf, size_t linebuflen, bool ascii);
extern void print_hex_dump(const char *level, const char *prefix_str,
- int prefix_type, int rowsize, int groupsize,
- const void *buf, size_t len, bool ascii);
+ int prefix_type, int rowsize, int groupsize,
+ const void *buf, size_t len, bool ascii);
extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
- const void *buf, size_t len);
+ const void *buf, size_t len);
#ifndef pr_fmt
--
1.6.6.rc0.57.gad7a
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 09/14] kernel.h: Don't use NORET_AND just use noreturn, instead
2009-12-16 8:08 [PATCH 00/14] kernel.h cleanups Joe Perches
` (7 preceding siblings ...)
2009-12-16 8:09 ` [PATCH 08/14] kernel.h: Group math and limits functions, indent function args Joe Perches
@ 2009-12-16 8:09 ` Joe Perches
2009-12-16 8:09 ` [PATCH 10/14] kernel.h: Remove ATTRIB_NORET, use __attribute__((noreturn)) Joe Perches
` (5 subsequent siblings)
14 siblings, 0 replies; 18+ messages in thread
From: Joe Perches @ 2009-12-16 8:09 UTC (permalink / raw)
To: Linus Torvalds; +Cc: linux-kernel
Signed-off-by: Joe Perches <joe@perches.com>
---
include/linux/kernel.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 97c80c7..3b796b9 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -127,7 +127,7 @@ static inline void might_fault(void)
extern struct atomic_notifier_head panic_notifier_list;
extern long (*panic_blink)(long time);
NORET_TYPE void panic(const char *fmt, ...)
- __attribute__ ((NORET_AND format (printf, 1, 2))) __cold;
+ __attribute__ ((noreturn, format (printf, 1, 2))) __cold;
extern void oops_enter(void);
extern void oops_exit(void);
extern int oops_may_print(void);
--
1.6.6.rc0.57.gad7a
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 10/14] kernel.h: Remove ATTRIB_NORET, use __attribute__((noreturn))
2009-12-16 8:08 [PATCH 00/14] kernel.h cleanups Joe Perches
` (8 preceding siblings ...)
2009-12-16 8:09 ` [PATCH 09/14] kernel.h: Don't use NORET_AND just use noreturn, instead Joe Perches
@ 2009-12-16 8:09 ` Joe Perches
2009-12-16 8:09 ` [PATCH 11/14] kernel.h: Remove uses of NORET_TYPE Joe Perches
` (4 subsequent siblings)
14 siblings, 0 replies; 18+ messages in thread
From: Joe Perches @ 2009-12-16 8:09 UTC (permalink / raw)
To: Linus Torvalds; +Cc: linux-kernel
No real need to indirect this
Signed-off-by: Joe Perches <joe@perches.com>
---
include/linux/kernel.h | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 3b796b9..5c97b73 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -132,9 +132,9 @@ extern void oops_enter(void);
extern void oops_exit(void);
extern int oops_may_print(void);
NORET_TYPE void do_exit(long code)
- ATTRIB_NORET;
+ __attribute__ ((noreturn));
NORET_TYPE void complete_and_exit(struct completion *comp, long code)
- ATTRIB_NORET;
+ __attribute__ ((noreturn));
/*
* stdlib - String to type conversions
--
1.6.6.rc0.57.gad7a
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 11/14] kernel.h: Remove uses of NORET_TYPE
2009-12-16 8:08 [PATCH 00/14] kernel.h cleanups Joe Perches
` (9 preceding siblings ...)
2009-12-16 8:09 ` [PATCH 10/14] kernel.h: Remove ATTRIB_NORET, use __attribute__((noreturn)) Joe Perches
@ 2009-12-16 8:09 ` Joe Perches
2009-12-16 8:09 ` [PATCH 12/14] kernel.h: Add pr_<level>_once Joe Perches
` (3 subsequent siblings)
14 siblings, 0 replies; 18+ messages in thread
From: Joe Perches @ 2009-12-16 8:09 UTC (permalink / raw)
To: Linus Torvalds; +Cc: linux-kernel
It's useless
Replaced with extern just for consistency
Signed-off-by: Joe Perches <joe@perches.com>
---
include/linux/kernel.h | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 5c97b73..e079744 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -126,14 +126,14 @@ static inline void might_fault(void)
extern struct atomic_notifier_head panic_notifier_list;
extern long (*panic_blink)(long time);
-NORET_TYPE void panic(const char *fmt, ...)
+extern void panic(const char *fmt, ...)
__attribute__ ((noreturn, format (printf, 1, 2))) __cold;
extern void oops_enter(void);
extern void oops_exit(void);
extern int oops_may_print(void);
-NORET_TYPE void do_exit(long code)
+extern void do_exit(long code)
__attribute__ ((noreturn));
-NORET_TYPE void complete_and_exit(struct completion *comp, long code)
+extern void complete_and_exit(struct completion *comp, long code)
__attribute__ ((noreturn));
/*
--
1.6.6.rc0.57.gad7a
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 12/14] kernel.h: Add pr_<level>_once
2009-12-16 8:08 [PATCH 00/14] kernel.h cleanups Joe Perches
` (10 preceding siblings ...)
2009-12-16 8:09 ` [PATCH 11/14] kernel.h: Remove uses of NORET_TYPE Joe Perches
@ 2009-12-16 8:09 ` Joe Perches
2009-12-16 8:09 ` [PATCH 13/14] kernel.h: Kernel address utility aggregation and other neatening Joe Perches
` (2 subsequent siblings)
14 siblings, 0 replies; 18+ messages in thread
From: Joe Perches @ 2009-12-16 8:09 UTC (permalink / raw)
To: Linus Torvalds; +Cc: linux-kernel
Consolidate the define and use of printk_once near printk_ratelimited
Add pr_<level>_once macros that use pr_fmt(fmt)
A little alignment neatening
Signed-off-by: Joe Perches <joe@perches.com>
---
include/linux/kernel.h | 105 +++++++++++++++++++++++++++++++----------------
1 files changed, 69 insertions(+), 36 deletions(-)
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index e079744..7d7f7e2 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -434,19 +434,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
extern int printk_delay_msec;
-/*
- * Print a one-time message (analogous to WARN_ONCE() et al):
- */
-#define printk_once(fmt, ...) \
-({ \
- static bool __print_once; \
- \
- if (!__print_once) { \
- __print_once = true; \
- printk(fmt, ##__VA_ARGS__); \
- } \
-})
-
void log_buf_kexec_setup(void);
#else
static inline int vprintk(const char *s, va_list args)
@@ -462,9 +449,6 @@ static inline bool printk_timed_ratelimit(unsigned long *caller_jiffies,
return false;
}
-/* No effect, but we still get type checking even in the !PRINTK case: */
-#define printk_once(fmt, ...) printk(fmt, ##__VA_ARGS__)
-
static inline void log_buf_kexec_setup(void)
{
}
@@ -514,26 +498,26 @@ extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
#define pr_fmt(fmt) fmt
#endif
-#define pr_emerg(fmt, ...) \
+#define pr_emerg(fmt, ...) \
printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_alert(fmt, ...) \
+#define pr_alert(fmt, ...) \
printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_crit(fmt, ...) \
+#define pr_crit(fmt, ...) \
printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_err(fmt, ...) \
+#define pr_err(fmt, ...) \
printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_warning(fmt, ...) \
+#define pr_warning(fmt, ...) \
printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_notice(fmt, ...) \
+#define pr_notice(fmt, ...) \
printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_info(fmt, ...) \
+#define pr_info(fmt, ...) \
printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_cont(fmt, ...) \
+#define pr_cont(fmt, ...) \
printk(KERN_CONT fmt, ##__VA_ARGS__)
/* pr_devel() should produce zero code unless DEBUG is defined */
#ifdef DEBUG
-#define pr_devel(fmt, ...) \
+#define pr_devel(fmt, ...) \
printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
#else
#define pr_devel(fmt, ...) \
@@ -546,11 +530,11 @@ extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
/* If you are writing a driver, please use dev_dbg instead */
#if defined(DEBUG)
-#define pr_debug(fmt, ...) \
+#define pr_debug(fmt, ...) \
printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
#elif defined(CONFIG_DYNAMIC_DEBUG)
/* dynamic_pr_debug() uses pr_fmt() internally so we don't need it here */
-#define pr_debug(fmt, ...) \
+#define pr_debug(fmt, ...) \
dynamic_pr_debug(fmt, ##__VA_ARGS__)
#else
#define pr_debug(fmt, ...) \
@@ -562,19 +546,68 @@ extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
#endif
/*
+ * Print a one-time message (analogous to WARN_ONCE() et al):
+ * no local state used in the !PRINTK case
+ */
+#ifdef CONFIG_PRINTK
+#define printk_once(fmt, ...) \
+({ \
+ static bool __print_once; \
+ \
+ if (!__print_once) { \
+ __print_once = true; \
+ printk(fmt, ##__VA_ARGS__); \
+ } \
+})
+
+#else
+/* No effect, but we still get type checking even in the !PRINTK case: */
+#define printk_once(fmt, ...) printk(fmt, ##__VA_ARGS__)
+#endif
+
+#define pr_emerg_once(fmt, ...) \
+ printk_once(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_alert_once(fmt, ...) \
+ printk_once(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_crit_once(fmt, ...) \
+ printk_once(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_err_once(fmt, ...) \
+ printk_once(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_warning_once(fmt, ...) \
+ printk_once(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_notice_once(fmt, ...) \
+ printk_once(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_info_once(fmt, ...) \
+ printk_once(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
+/* no pr_cont_once, don't do that... */
+/* If you are writing a driver, please use dev_dbg instead */
+#if defined(DEBUG)
+#define pr_debug_once(fmt, ...) \
+ printk_once(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
+#else
+#define pr_debug_once(fmt, ...) \
+({ \
+ if (0) \
+ printk_once(KERN_DEBUG pr_fmt(fmt), \
+ ##__VA_ARGS__); \
+ 0; \
+})
+#endif
+
+/*
* ratelimited messages with local ratelimit_state,
* no local ratelimit_state used in the !PRINTK case
*/
#ifdef CONFIG_PRINTK
-#define printk_ratelimited(fmt, ...) \
-({ \
- static struct ratelimit_state _rs = { \
- .interval = DEFAULT_RATELIMIT_INTERVAL, \
- .burst = DEFAULT_RATELIMIT_BURST, \
- }; \
- \
- if (!__ratelimit(&_rs)) \
- printk(fmt, ##__VA_ARGS__); \
+#define printk_ratelimited(fmt, ...) \
+({ \
+ static struct ratelimit_state _rs = { \
+ .interval = DEFAULT_RATELIMIT_INTERVAL, \
+ .burst = DEFAULT_RATELIMIT_BURST, \
+ }; \
+ \
+ if (!__ratelimit(&_rs)) \
+ printk(fmt, ##__VA_ARGS__); \
})
#else
/* No effect, but we still get type checking even in the !PRINTK case: */
--
1.6.6.rc0.57.gad7a
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 13/14] kernel.h: Kernel address utility aggregation and other neatening
2009-12-16 8:08 [PATCH 00/14] kernel.h cleanups Joe Perches
` (11 preceding siblings ...)
2009-12-16 8:09 ` [PATCH 12/14] kernel.h: Add pr_<level>_once Joe Perches
@ 2009-12-16 8:09 ` Joe Perches
2009-12-16 8:09 ` [PATCH 14/14] kernel/exit.c and kernel/panic.c: Remove unused NORET_TYPE Joe Perches
2009-12-17 20:52 ` [PATCH 00/14] kernel.h cleanups Joe Perches
14 siblings, 0 replies; 18+ messages in thread
From: Joe Perches @ 2009-12-16 8:09 UTC (permalink / raw)
To: Linus Torvalds; +Cc: linux-kernel
Group the address utilities
Move upper_32_bits and lower_32_bits to math and limits group
Add a few new group headers
panic and oops
shutdown
string parsing
sysinfo
Signed-off-by: Joe Perches <joe@perches.com>
---
include/linux/kernel.h | 69 +++++++++++++++++++++++++++++++----------------
1 files changed, 45 insertions(+), 24 deletions(-)
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 7d7f7e2..0fd5949 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -32,8 +32,6 @@
#define LLONG_MIN (-LLONG_MAX - 1)
#define ULLONG_MAX (~0ULL)
-#define STACK_MAGIC 0xdeadbeef
-
#define __ALIGN_MASK(x, mask) (((x) + (mask)) & ~(mask))
#define ALIGN(x, a) __ALIGN_MASK(x, (typeof(x))(a) - 1)
#define PTR_ALIGN(p, a) ((typeof(p))ALIGN((unsigned long)(p), (a)))
@@ -51,9 +49,6 @@
(((x) + ((__divisor) / 2)) / (__divisor)); \
})
-#define _RET_IP_ (unsigned long)__builtin_return_address(0)
-#define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; })
-
#ifdef CONFIG_LBDAF
# include <asm/div64.h>
# define sector_div(a, b) do_div(a, b)
@@ -67,22 +62,6 @@
})
#endif
-/**
- * upper_32_bits - return bits 32-63 of a number
- * @n: the number we're accessing
- *
- * A basic shift-right of a 64- or 32-bit quantity. Use this to suppress
- * the "right shift count >= width of type" warning when that quantity is
- * 32-bits.
- */
-#define upper_32_bits(n) ((u32)(((n) >> 16) >> 16))
-
-/**
- * lower_32_bits - return bits 0-31 of a number
- * @n: the number we're accessing
- */
-#define lower_32_bits(n) ((u32)(n))
-
struct completion;
struct pt_regs;
struct user;
@@ -124,6 +103,9 @@ static inline void might_fault(void)
}
#endif
+/*
+ * panic and oops support
+ */
extern struct atomic_notifier_head panic_notifier_list;
extern long (*panic_blink)(long time);
extern void panic(const char *fmt, ...)
@@ -131,6 +113,10 @@ extern void panic(const char *fmt, ...)
extern void oops_enter(void);
extern void oops_exit(void);
extern int oops_may_print(void);
+
+/*
+ * shutdown support
+ */
extern void do_exit(long code)
__attribute__ ((noreturn));
extern void complete_and_exit(struct completion *comp, long code)
@@ -176,15 +162,28 @@ extern int sscanf(const char *buf, const char *fmt, ...)
extern int vsscanf(const char *buf, const char *fmt, va_list)
__attribute__ ((format (scanf, 2, 0)));
+/*
+ * String parsing
+ */
extern int get_option(char **str, int *pint);
extern char *get_options(const char *str, int nints, int *ints);
extern unsigned long long memparse(const char *ptr, char **retptr);
+ /*parse a string with mem suffixes into a number */
+/*
+ * Kernel address utils
+ */
extern int core_kernel_text(unsigned long addr);
extern int __kernel_text_address(unsigned long addr);
extern int kernel_text_address(unsigned long addr);
extern int func_ptr_is_kernel_text(void *ptr);
+#define _RET_IP_ (unsigned long)__builtin_return_address(0)
+#define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; })
+#define STACK_MAGIC 0xdeadbeef
+/*
+ * Process ID and process group
+ */
struct pid;
extern struct pid *session_of_pgrp(struct pid *pgrp);
@@ -221,6 +220,9 @@ extern int panic_on_unrecovered_nmi;
extern int panic_on_io_nmi;
extern int root_mountflags;
+/*
+ * Hex to ascii helpers
+ */
extern const char hex_asc[];
#define hex_asc_lo(x) hex_asc[((x) & 0x0f)]
@@ -244,6 +246,22 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
unsigned long int_sqrt(unsigned long);
+/**
+ * upper_32_bits - return bits 32-63 of a number
+ * @n: the number we're accessing
+ *
+ * A basic shift-right of a 64- or 32-bit quantity. Use this to suppress
+ * the "right shift count >= width of type" warning when that quantity is
+ * 32-bits.
+ */
+#define upper_32_bits(n) ((u32)(((n) >> 16) >> 16))
+
+/**
+ * lower_32_bits - return bits 0-31 of a number
+ * @n: the number we're accessing
+ */
+#define lower_32_bits(n) ((u32)(n))
+
/*
* min()/max()/clamp() macros that also do
* strict type-checking.. See the
@@ -362,9 +380,6 @@ unsigned long int_sqrt(unsigned long);
(type *)((char *)__mptr - offsetof(type, member)); \
})
-struct sysinfo;
-extern int do_sysinfo(struct sysinfo *info);
-
/*
* Console and logging support
*/
@@ -776,6 +791,12 @@ ftrace_vprintk(const char *fmt, va_list ap)
static inline void ftrace_dump(void) { }
#endif /* CONFIG_TRACING */
+/*
+ * sysinfo support
+ */
+struct sysinfo;
+extern int do_sysinfo(struct sysinfo *info);
+
#endif /* __KERNEL__ */
#ifndef __EXPORTED_HEADERS__
--
1.6.6.rc0.57.gad7a
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 14/14] kernel/exit.c and kernel/panic.c: Remove unused NORET_TYPE
2009-12-16 8:08 [PATCH 00/14] kernel.h cleanups Joe Perches
` (12 preceding siblings ...)
2009-12-16 8:09 ` [PATCH 13/14] kernel.h: Kernel address utility aggregation and other neatening Joe Perches
@ 2009-12-16 8:09 ` Joe Perches
2009-12-16 18:51 ` Peter Zijlstra
2009-12-17 20:52 ` [PATCH 00/14] kernel.h cleanups Joe Perches
14 siblings, 1 reply; 18+ messages in thread
From: Joe Perches @ 2009-12-16 8:09 UTC (permalink / raw)
To: Linus Torvalds; +Cc: linux-kernel
Make the functions match the prototypes in <linux/kernel.h>
It's defined to nothing and useless
Signed-off-by: Joe Perches <joe@perches.com>
---
kernel/exit.c | 4 ++--
kernel/panic.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/kernel/exit.c b/kernel/exit.c
index 5962d7c..ebb485c 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -886,7 +886,7 @@ static void check_stack_usage(void)
static inline void check_stack_usage(void) {}
#endif
-NORET_TYPE void do_exit(long code)
+void do_exit(long code)
{
struct task_struct *tsk = current;
int group_dead;
@@ -1029,7 +1029,7 @@ NORET_TYPE void do_exit(long code)
EXPORT_SYMBOL_GPL(do_exit);
-NORET_TYPE void complete_and_exit(struct completion *comp, long code)
+void complete_and_exit(struct completion *comp, long code)
{
if (comp)
complete(comp);
diff --git a/kernel/panic.c b/kernel/panic.c
index 96b45d0..08d24b2 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -52,7 +52,7 @@ EXPORT_SYMBOL(panic_blink);
*
* This function never returns.
*/
-NORET_TYPE void panic(const char * fmt, ...)
+void panic(const char * fmt, ...)
{
static char buf[1024];
va_list args;
--
1.6.6.rc0.57.gad7a
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH 14/14] kernel/exit.c and kernel/panic.c: Remove unused NORET_TYPE
2009-12-16 8:09 ` [PATCH 14/14] kernel/exit.c and kernel/panic.c: Remove unused NORET_TYPE Joe Perches
@ 2009-12-16 18:51 ` Peter Zijlstra
2009-12-16 18:53 ` Peter Zijlstra
0 siblings, 1 reply; 18+ messages in thread
From: Peter Zijlstra @ 2009-12-16 18:51 UTC (permalink / raw)
To: Joe Perches; +Cc: Linus Torvalds, linux-kernel
On Wed, 2009-12-16 at 00:09 -0800, Joe Perches wrote:
> Make the functions match the prototypes in <linux/kernel.h>
> It's defined to nothing and useless
Uhm, why not make it useful again and define it to something like:
#define NORET_TYPE __attribute__((noreturn))
except I guess that should come after the function name, not before.
Annotations that tell a particular function is not supposed to exit
seems useful to me..
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 14/14] kernel/exit.c and kernel/panic.c: Remove unused NORET_TYPE
2009-12-16 18:51 ` Peter Zijlstra
@ 2009-12-16 18:53 ` Peter Zijlstra
0 siblings, 0 replies; 18+ messages in thread
From: Peter Zijlstra @ 2009-12-16 18:53 UTC (permalink / raw)
To: Joe Perches; +Cc: Linus Torvalds, linux-kernel
On Wed, 2009-12-16 at 19:51 +0100, Peter Zijlstra wrote:
> On Wed, 2009-12-16 at 00:09 -0800, Joe Perches wrote:
> > Make the functions match the prototypes in <linux/kernel.h>
> > It's defined to nothing and useless
>
> Uhm, why not make it useful again and define it to something like:
>
> #define NORET_TYPE __attribute__((noreturn))
>
> except I guess that should come after the function name, not before.
>
> Annotations that tell a particular function is not supposed to exit
> seems useful to me..
Ah, that got hidden in the header and was done in a different patch.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 00/14] kernel.h cleanups
2009-12-16 8:08 [PATCH 00/14] kernel.h cleanups Joe Perches
` (13 preceding siblings ...)
2009-12-16 8:09 ` [PATCH 14/14] kernel/exit.c and kernel/panic.c: Remove unused NORET_TYPE Joe Perches
@ 2009-12-17 20:52 ` Joe Perches
14 siblings, 0 replies; 18+ messages in thread
From: Joe Perches @ 2009-12-17 20:52 UTC (permalink / raw)
To: Linus Torvalds; +Cc: linux-kernel
On Wed, 2009-12-16 at 00:08 -0800, Joe Perches wrote:
> kernel.h has become a chaotic jumble collected over time.
> Collect the functions and #defines together in logical groups.
> Do some checkpatch neatening and make it more style conformant.
Are there negative attributes in this patchset that
prevent it from being applied?
> Joe Perches (14):
> kernel.h: Consolidate console and logging functions and defines
> kernel.h: Checkpatch cleaning
> kernel.h: ARRAY_SIZE neatening
> kernel.h: Add argument names to strtoXX, Xscanf prototypes
> kernel.h: printk neatening
> drivers/firmware/iscsi_ibft.c: Use %pI4 to print netmask
> kernel.h: Move NIPQUAD and NIPQUAD_FMT to in.h
> kernel.h: Group math and limits functions, indent function args
> kernel.h: Don't use NORET_AND just use noreturn, instead
> kernel.h: Remove ATTRIB_NORET, use __attribute__((noreturn))
> kernel.h: Remove uses of NORET_TYPE
> kernel.h: Add pr_<level>_once
> kernel.h: Kernel address utility aggregation and other neatening
> kernel/exit.c and kernel/panic.c: Remove unused NORET_TYPE
>
> drivers/firmware/iscsi_ibft.c | 8 +-
> include/linux/in.h | 11 +
> include/linux/kernel.h | 742 +++++++++++++++++++++++------------------
> kernel/exit.c | 4 +-
> kernel/panic.c | 2 +-
> 5 files changed, 437 insertions(+), 330 deletions(-)
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2009-12-17 20:52 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-16 8:08 [PATCH 00/14] kernel.h cleanups Joe Perches
2009-12-16 8:09 ` [PATCH 01/14] kernel.h: Consolidate console and logging functions and defines Joe Perches
2009-12-16 8:09 ` [PATCH 02/14] kernel.h: Checkpatch cleaning Joe Perches
2009-12-16 8:09 ` [PATCH 03/14] kernel.h: ARRAY_SIZE neatening Joe Perches
2009-12-16 8:09 ` [PATCH 04/14] kernel.h: Add argument names to strtoXX, Xscanf prototypes Joe Perches
2009-12-16 8:09 ` [PATCH 05/14] kernel.h: printk neatening Joe Perches
2009-12-16 8:09 ` [PATCH 06/14] drivers/firmware/iscsi_ibft.c: Use %pI4 to print netmask Joe Perches
2009-12-16 8:09 ` [PATCH 07/14] kernel.h: Move NIPQUAD and NIPQUAD_FMT to in.h Joe Perches
2009-12-16 8:09 ` [PATCH 08/14] kernel.h: Group math and limits functions, indent function args Joe Perches
2009-12-16 8:09 ` [PATCH 09/14] kernel.h: Don't use NORET_AND just use noreturn, instead Joe Perches
2009-12-16 8:09 ` [PATCH 10/14] kernel.h: Remove ATTRIB_NORET, use __attribute__((noreturn)) Joe Perches
2009-12-16 8:09 ` [PATCH 11/14] kernel.h: Remove uses of NORET_TYPE Joe Perches
2009-12-16 8:09 ` [PATCH 12/14] kernel.h: Add pr_<level>_once Joe Perches
2009-12-16 8:09 ` [PATCH 13/14] kernel.h: Kernel address utility aggregation and other neatening Joe Perches
2009-12-16 8:09 ` [PATCH 14/14] kernel/exit.c and kernel/panic.c: Remove unused NORET_TYPE Joe Perches
2009-12-16 18:51 ` Peter Zijlstra
2009-12-16 18:53 ` Peter Zijlstra
2009-12-17 20:52 ` [PATCH 00/14] kernel.h cleanups Joe Perches
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox