]>
Commit | Line | Data |
---|---|---|
9504504c SR |
1 | #ifndef _LINUX_TRACE_SEQ_H |
2 | #define _LINUX_TRACE_SEQ_H | |
3 | ||
3a161d99 | 4 | #include <linux/seq_buf.h> |
6d723736 | 5 | |
78be6914 WZ |
6 | #include <asm/page.h> |
7 | ||
9504504c SR |
8 | /* |
9 | * Trace sequences are used to allow a function to call several other functions | |
6d3f1e12 | 10 | * to create a string of data to use (up to a max of PAGE_SIZE). |
9504504c SR |
11 | */ |
12 | ||
13 | struct trace_seq { | |
14 | unsigned char buffer[PAGE_SIZE]; | |
3a161d99 | 15 | struct seq_buf seq; |
d184b31c | 16 | int full; |
9504504c SR |
17 | }; |
18 | ||
19 | static inline void | |
20 | trace_seq_init(struct trace_seq *s) | |
21 | { | |
3a161d99 | 22 | seq_buf_init(&s->seq, s->buffer, PAGE_SIZE); |
d184b31c | 23 | s->full = 0; |
9504504c SR |
24 | } |
25 | ||
7b039cb4 SRRH |
26 | /** |
27 | * trace_seq_buffer_ptr - return pointer to next location in buffer | |
28 | * @s: trace sequence descriptor | |
29 | * | |
30 | * Returns the pointer to the buffer where the next write to | |
31 | * the buffer will happen. This is useful to save the location | |
32 | * that is about to be written to and then return the result | |
33 | * of that write. | |
34 | */ | |
35 | static inline unsigned char * | |
36 | trace_seq_buffer_ptr(struct trace_seq *s) | |
37 | { | |
3a161d99 | 38 | return s->buffer + s->seq.len; |
7b039cb4 SRRH |
39 | } |
40 | ||
19a7fe20 SRRH |
41 | /** |
42 | * trace_seq_has_overflowed - return true if the trace_seq took too much | |
43 | * @s: trace sequence descriptor | |
44 | * | |
45 | * Returns true if too much data was added to the trace_seq and it is | |
46 | * now full and will not take anymore. | |
47 | */ | |
48 | static inline bool trace_seq_has_overflowed(struct trace_seq *s) | |
49 | { | |
3a161d99 | 50 | return s->full || seq_buf_has_overflowed(&s->seq); |
19a7fe20 SRRH |
51 | } |
52 | ||
9504504c SR |
53 | /* |
54 | * Currently only defined when tracing is enabled. | |
55 | */ | |
56 | #ifdef CONFIG_TRACING | |
b9075fa9 | 57 | extern __printf(2, 3) |
dba39448 | 58 | void trace_seq_printf(struct trace_seq *s, const char *fmt, ...); |
b9075fa9 | 59 | extern __printf(2, 0) |
dba39448 SRRH |
60 | void trace_seq_vprintf(struct trace_seq *s, const char *fmt, va_list args); |
61 | extern void | |
9504504c | 62 | trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 *binary); |
a63ce5b3 | 63 | extern int trace_print_seq(struct seq_file *m, struct trace_seq *s); |
36aabfff SRRH |
64 | extern int trace_seq_to_user(struct trace_seq *s, char __user *ubuf, |
65 | int cnt); | |
dba39448 SRRH |
66 | extern void trace_seq_puts(struct trace_seq *s, const char *str); |
67 | extern void trace_seq_putc(struct trace_seq *s, unsigned char c); | |
68 | extern void trace_seq_putmem(struct trace_seq *s, const void *mem, unsigned int len); | |
69 | extern void trace_seq_putmem_hex(struct trace_seq *s, const void *mem, | |
36aabfff | 70 | unsigned int len); |
38eff289 | 71 | extern int trace_seq_path(struct trace_seq *s, const struct path *path); |
9504504c | 72 | |
dba39448 | 73 | extern void trace_seq_bitmask(struct trace_seq *s, const unsigned long *maskp, |
4449bf92 SRRH |
74 | int nmaskbits); |
75 | ||
9504504c | 76 | #else /* CONFIG_TRACING */ |
dba39448 | 77 | static inline void trace_seq_printf(struct trace_seq *s, const char *fmt, ...) |
9504504c | 78 | { |
9504504c | 79 | } |
dba39448 | 80 | static inline void |
9504504c SR |
81 | trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 *binary) |
82 | { | |
9504504c SR |
83 | } |
84 | ||
dba39448 | 85 | static inline void |
4449bf92 SRRH |
86 | trace_seq_bitmask(struct trace_seq *s, const unsigned long *maskp, |
87 | int nmaskbits) | |
88 | { | |
4449bf92 SRRH |
89 | } |
90 | ||
a63ce5b3 | 91 | static inline int trace_print_seq(struct seq_file *m, struct trace_seq *s) |
9504504c | 92 | { |
a63ce5b3 | 93 | return 0; |
9504504c | 94 | } |
36aabfff SRRH |
95 | static inline int trace_seq_to_user(struct trace_seq *s, char __user *ubuf, |
96 | int cnt) | |
9504504c SR |
97 | { |
98 | return 0; | |
99 | } | |
dba39448 | 100 | static inline void trace_seq_puts(struct trace_seq *s, const char *str) |
9504504c | 101 | { |
9504504c | 102 | } |
dba39448 | 103 | static inline void trace_seq_putc(struct trace_seq *s, unsigned char c) |
9504504c | 104 | { |
9504504c | 105 | } |
dba39448 | 106 | static inline void |
36aabfff | 107 | trace_seq_putmem(struct trace_seq *s, const void *mem, unsigned int len) |
9504504c | 108 | { |
9504504c | 109 | } |
dba39448 | 110 | static inline void trace_seq_putmem_hex(struct trace_seq *s, const void *mem, |
36aabfff | 111 | unsigned int len) |
9504504c | 112 | { |
9504504c | 113 | } |
38eff289 | 114 | static inline int trace_seq_path(struct trace_seq *s, const struct path *path) |
9504504c SR |
115 | { |
116 | return 0; | |
117 | } | |
118 | #endif /* CONFIG_TRACING */ | |
119 | ||
120 | #endif /* _LINUX_TRACE_SEQ_H */ |