Skip to content

Commit 546e535

Browse files
author
Ingo Molnar
committed
Merge branch 'core/printk' into tracing/ftrace
2 parents af438c0 + fef20d9 commit 546e535

File tree

4 files changed

+806
-227
lines changed

4 files changed

+806
-227
lines changed

include/linux/kernel.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,19 @@ extern struct ratelimit_state printk_ratelimit_state;
242242
extern int printk_ratelimit(void);
243243
extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
244244
unsigned int interval_msec);
245+
246+
/*
247+
* Print a one-time message (analogous to WARN_ONCE() et al):
248+
*/
249+
#define printk_once(x...) ({ \
250+
static int __print_once = 1; \
251+
\
252+
if (__print_once) { \
253+
__print_once = 0; \
254+
printk(x); \
255+
} \
256+
})
257+
245258
#else
246259
static inline int vprintk(const char *s, va_list args)
247260
__attribute__ ((format (printf, 1, 0)));
@@ -253,6 +266,10 @@ static inline int printk_ratelimit(void) { return 0; }
253266
static inline bool printk_timed_ratelimit(unsigned long *caller_jiffies, \
254267
unsigned int interval_msec) \
255268
{ return false; }
269+
270+
/* No effect, but we still get type checking even in the !PRINTK case: */
271+
#define printk_once(x...) printk(x)
272+
256273
#endif
257274

258275
extern int printk_needs_cpu(int cpu);

include/linux/string.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/compiler.h> /* for inline */
1111
#include <linux/types.h> /* for size_t */
1212
#include <linux/stddef.h> /* for NULL */
13+
#include <stdarg.h>
1314

1415
extern char *strndup_user(const char __user *, long);
1516

@@ -111,6 +112,12 @@ extern void argv_free(char **argv);
111112

112113
extern bool sysfs_streq(const char *s1, const char *s2);
113114

115+
#ifdef CONFIG_BINARY_PRINTF
116+
int vbin_printf(u32 *bin_buf, size_t size, const char *fmt, va_list args);
117+
int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf);
118+
int bprintf(u32 *bin_buf, size_t size, const char *fmt, ...) __printf(3, 4);
119+
#endif
120+
114121
extern ssize_t memory_read_from_buffer(void *to, size_t count, loff_t *ppos,
115122
const void *from, size_t available);
116123

lib/Kconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
# Library configuration
33
#
44

5+
config BINARY_PRINTF
6+
def_bool n
7+
58
menu "Library routines"
69

710
config BITREVERSE

0 commit comments

Comments
 (0)