diff options
-rw-r--r-- | include/linux/trace_seq.h | 37 | ||||
-rw-r--r-- | kernel/trace/trace_seq.c | 84 |
2 files changed, 38 insertions, 83 deletions
diff --git a/include/linux/trace_seq.h b/include/linux/trace_seq.h index 07eda413dfcf..db8a73224f1a 100644 --- a/include/linux/trace_seq.h +++ b/include/linux/trace_seq.h | |||
@@ -57,40 +57,37 @@ static inline bool trace_seq_has_overflowed(struct trace_seq *s) | |||
57 | */ | 57 | */ |
58 | #ifdef CONFIG_TRACING | 58 | #ifdef CONFIG_TRACING |
59 | extern __printf(2, 3) | 59 | extern __printf(2, 3) |
60 | int trace_seq_printf(struct trace_seq *s, const char *fmt, ...); | 60 | void trace_seq_printf(struct trace_seq *s, const char *fmt, ...); |
61 | extern __printf(2, 0) | 61 | extern __printf(2, 0) |
62 | int trace_seq_vprintf(struct trace_seq *s, const char *fmt, va_list args); | 62 | void trace_seq_vprintf(struct trace_seq *s, const char *fmt, va_list args); |
63 | extern int | 63 | extern void |
64 | trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 *binary); | 64 | trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 *binary); |
65 | extern int trace_print_seq(struct seq_file *m, struct trace_seq *s); | 65 | extern int trace_print_seq(struct seq_file *m, struct trace_seq *s); |
66 | extern int trace_seq_to_user(struct trace_seq *s, char __user *ubuf, | 66 | extern int trace_seq_to_user(struct trace_seq *s, char __user *ubuf, |
67 | int cnt); | 67 | int cnt); |
68 | extern int trace_seq_puts(struct trace_seq *s, const char *str); | 68 | extern void trace_seq_puts(struct trace_seq *s, const char *str); |
69 | extern int trace_seq_putc(struct trace_seq *s, unsigned char c); | 69 | extern void trace_seq_putc(struct trace_seq *s, unsigned char c); |
70 | extern int trace_seq_putmem(struct trace_seq *s, const void *mem, unsigned int len); | 70 | extern void trace_seq_putmem(struct trace_seq *s, const void *mem, unsigned int len); |
71 | extern int trace_seq_putmem_hex(struct trace_seq *s, const void *mem, | 71 | extern void trace_seq_putmem_hex(struct trace_seq *s, const void *mem, |
72 | unsigned int len); | 72 | unsigned int len); |
73 | extern int trace_seq_path(struct trace_seq *s, const struct path *path); | 73 | extern int trace_seq_path(struct trace_seq *s, const struct path *path); |
74 | 74 | ||
75 | extern int trace_seq_bitmask(struct trace_seq *s, const unsigned long *maskp, | 75 | extern void trace_seq_bitmask(struct trace_seq *s, const unsigned long *maskp, |
76 | int nmaskbits); | 76 | int nmaskbits); |
77 | 77 | ||
78 | #else /* CONFIG_TRACING */ | 78 | #else /* CONFIG_TRACING */ |
79 | static inline int trace_seq_printf(struct trace_seq *s, const char *fmt, ...) | 79 | static inline void trace_seq_printf(struct trace_seq *s, const char *fmt, ...) |
80 | { | 80 | { |
81 | return 0; | ||
82 | } | 81 | } |
83 | static inline int | 82 | static inline void |
84 | trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 *binary) | 83 | trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 *binary) |
85 | { | 84 | { |
86 | return 0; | ||
87 | } | 85 | } |
88 | 86 | ||
89 | static inline int | 87 | static inline void |
90 | trace_seq_bitmask(struct trace_seq *s, const unsigned long *maskp, | 88 | trace_seq_bitmask(struct trace_seq *s, const unsigned long *maskp, |
91 | int nmaskbits) | 89 | int nmaskbits) |
92 | { | 90 | { |
93 | return 0; | ||
94 | } | 91 | } |
95 | 92 | ||
96 | static inline int trace_print_seq(struct seq_file *m, struct trace_seq *s) | 93 | static inline int trace_print_seq(struct seq_file *m, struct trace_seq *s) |
@@ -102,23 +99,19 @@ static inline int trace_seq_to_user(struct trace_seq *s, char __user *ubuf, | |||
102 | { | 99 | { |
103 | return 0; | 100 | return 0; |
104 | } | 101 | } |
105 | static inline int trace_seq_puts(struct trace_seq *s, const char *str) | 102 | static inline void trace_seq_puts(struct trace_seq *s, const char *str) |
106 | { | 103 | { |
107 | return 0; | ||
108 | } | 104 | } |
109 | static inline int trace_seq_putc(struct trace_seq *s, unsigned char c) | 105 | static inline void trace_seq_putc(struct trace_seq *s, unsigned char c) |
110 | { | 106 | { |
111 | return 0; | ||
112 | } | 107 | } |
113 | static inline int | 108 | static inline void |
114 | trace_seq_putmem(struct trace_seq *s, const void *mem, unsigned int len) | 109 | trace_seq_putmem(struct trace_seq *s, const void *mem, unsigned int len) |
115 | { | 110 | { |
116 | return 0; | ||
117 | } | 111 | } |
118 | static inline int trace_seq_putmem_hex(struct trace_seq *s, const void *mem, | 112 | static inline void trace_seq_putmem_hex(struct trace_seq *s, const void *mem, |
119 | unsigned int len) | 113 | unsigned int len) |
120 | { | 114 | { |
121 | return 0; | ||
122 | } | 115 | } |
123 | static inline int trace_seq_path(struct trace_seq *s, const struct path *path) | 116 | static inline int trace_seq_path(struct trace_seq *s, const struct path *path) |
124 | { | 117 | { |
diff --git a/kernel/trace/trace_seq.c b/kernel/trace/trace_seq.c index b100994a17fe..fabfa0f190a3 100644 --- a/kernel/trace/trace_seq.c +++ b/kernel/trace/trace_seq.c | |||
@@ -69,20 +69,15 @@ int trace_print_seq(struct seq_file *m, struct trace_seq *s) | |||
69 | * trace_seq_printf() is used to store strings into a special | 69 | * trace_seq_printf() is used to store strings into a special |
70 | * buffer (@s). Then the output may be either used by | 70 | * buffer (@s). Then the output may be either used by |
71 | * the sequencer or pulled into another buffer. | 71 | * the sequencer or pulled into another buffer. |
72 | * | ||
73 | * Returns 1 if we successfully written all the contents to | ||
74 | * the buffer. | ||
75 | * Returns 0 if we the length to write is bigger than the | ||
76 | * reserved buffer space. In this case, nothing gets written. | ||
77 | */ | 72 | */ |
78 | int trace_seq_printf(struct trace_seq *s, const char *fmt, ...) | 73 | void trace_seq_printf(struct trace_seq *s, const char *fmt, ...) |
79 | { | 74 | { |
80 | unsigned int len = TRACE_SEQ_BUF_LEFT(s); | 75 | unsigned int len = TRACE_SEQ_BUF_LEFT(s); |
81 | va_list ap; | 76 | va_list ap; |
82 | int ret; | 77 | int ret; |
83 | 78 | ||
84 | if (s->full || !len) | 79 | if (s->full || !len) |
85 | return 0; | 80 | return; |
86 | 81 | ||
87 | va_start(ap, fmt); | 82 | va_start(ap, fmt); |
88 | ret = vsnprintf(s->buffer + s->len, len, fmt, ap); | 83 | ret = vsnprintf(s->buffer + s->len, len, fmt, ap); |
@@ -91,12 +86,10 @@ int trace_seq_printf(struct trace_seq *s, const char *fmt, ...) | |||
91 | /* If we can't write it all, don't bother writing anything */ | 86 | /* If we can't write it all, don't bother writing anything */ |
92 | if (ret >= len) { | 87 | if (ret >= len) { |
93 | s->full = 1; | 88 | s->full = 1; |
94 | return 0; | 89 | return; |
95 | } | 90 | } |
96 | 91 | ||
97 | s->len += ret; | 92 | s->len += ret; |
98 | |||
99 | return 1; | ||
100 | } | 93 | } |
101 | EXPORT_SYMBOL_GPL(trace_seq_printf); | 94 | EXPORT_SYMBOL_GPL(trace_seq_printf); |
102 | 95 | ||
@@ -107,25 +100,18 @@ EXPORT_SYMBOL_GPL(trace_seq_printf); | |||
107 | * @nmaskbits: The number of bits that are valid in @maskp | 100 | * @nmaskbits: The number of bits that are valid in @maskp |
108 | * | 101 | * |
109 | * Writes a ASCII representation of a bitmask string into @s. | 102 | * Writes a ASCII representation of a bitmask string into @s. |
110 | * | ||
111 | * Returns 1 if we successfully written all the contents to | ||
112 | * the buffer. | ||
113 | * Returns 0 if we the length to write is bigger than the | ||
114 | * reserved buffer space. In this case, nothing gets written. | ||
115 | */ | 103 | */ |
116 | int trace_seq_bitmask(struct trace_seq *s, const unsigned long *maskp, | 104 | void trace_seq_bitmask(struct trace_seq *s, const unsigned long *maskp, |
117 | int nmaskbits) | 105 | int nmaskbits) |
118 | { | 106 | { |
119 | unsigned int len = TRACE_SEQ_BUF_LEFT(s); | 107 | unsigned int len = TRACE_SEQ_BUF_LEFT(s); |
120 | int ret; | 108 | int ret; |
121 | 109 | ||
122 | if (s->full || !len) | 110 | if (s->full || !len) |
123 | return 0; | 111 | return; |
124 | 112 | ||
125 | ret = bitmap_scnprintf(s->buffer + s->len, len, maskp, nmaskbits); | 113 | ret = bitmap_scnprintf(s->buffer + s->len, len, maskp, nmaskbits); |
126 | s->len += ret; | 114 | s->len += ret; |
127 | |||
128 | return 1; | ||
129 | } | 115 | } |
130 | EXPORT_SYMBOL_GPL(trace_seq_bitmask); | 116 | EXPORT_SYMBOL_GPL(trace_seq_bitmask); |
131 | 117 | ||
@@ -139,28 +125,24 @@ EXPORT_SYMBOL_GPL(trace_seq_bitmask); | |||
139 | * trace_seq_printf is used to store strings into a special | 125 | * trace_seq_printf is used to store strings into a special |
140 | * buffer (@s). Then the output may be either used by | 126 | * buffer (@s). Then the output may be either used by |
141 | * the sequencer or pulled into another buffer. | 127 | * the sequencer or pulled into another buffer. |
142 | * | ||
143 | * Returns how much it wrote to the buffer. | ||
144 | */ | 128 | */ |
145 | int trace_seq_vprintf(struct trace_seq *s, const char *fmt, va_list args) | 129 | void trace_seq_vprintf(struct trace_seq *s, const char *fmt, va_list args) |
146 | { | 130 | { |
147 | unsigned int len = TRACE_SEQ_BUF_LEFT(s); | 131 | unsigned int len = TRACE_SEQ_BUF_LEFT(s); |
148 | int ret; | 132 | int ret; |
149 | 133 | ||
150 | if (s->full || !len) | 134 | if (s->full || !len) |
151 | return 0; | 135 | return; |
152 | 136 | ||
153 | ret = vsnprintf(s->buffer + s->len, len, fmt, args); | 137 | ret = vsnprintf(s->buffer + s->len, len, fmt, args); |
154 | 138 | ||
155 | /* If we can't write it all, don't bother writing anything */ | 139 | /* If we can't write it all, don't bother writing anything */ |
156 | if (ret >= len) { | 140 | if (ret >= len) { |
157 | s->full = 1; | 141 | s->full = 1; |
158 | return 0; | 142 | return; |
159 | } | 143 | } |
160 | 144 | ||
161 | s->len += ret; | 145 | s->len += ret; |
162 | |||
163 | return len; | ||
164 | } | 146 | } |
165 | EXPORT_SYMBOL_GPL(trace_seq_vprintf); | 147 | EXPORT_SYMBOL_GPL(trace_seq_vprintf); |
166 | 148 | ||
@@ -178,28 +160,24 @@ EXPORT_SYMBOL_GPL(trace_seq_vprintf); | |||
178 | * | 160 | * |
179 | * This function will take the format and the binary array and finish | 161 | * This function will take the format and the binary array and finish |
180 | * the conversion into the ASCII string within the buffer. | 162 | * the conversion into the ASCII string within the buffer. |
181 | * | ||
182 | * Returns how much it wrote to the buffer. | ||
183 | */ | 163 | */ |
184 | int trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 *binary) | 164 | void trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 *binary) |
185 | { | 165 | { |
186 | unsigned int len = TRACE_SEQ_BUF_LEFT(s); | 166 | unsigned int len = TRACE_SEQ_BUF_LEFT(s); |
187 | int ret; | 167 | int ret; |
188 | 168 | ||
189 | if (s->full || !len) | 169 | if (s->full || !len) |
190 | return 0; | 170 | return; |
191 | 171 | ||
192 | ret = bstr_printf(s->buffer + s->len, len, fmt, binary); | 172 | ret = bstr_printf(s->buffer + s->len, len, fmt, binary); |
193 | 173 | ||
194 | /* If we can't write it all, don't bother writing anything */ | 174 | /* If we can't write it all, don't bother writing anything */ |
195 | if (ret >= len) { | 175 | if (ret >= len) { |
196 | s->full = 1; | 176 | s->full = 1; |
197 | return 0; | 177 | return; |
198 | } | 178 | } |
199 | 179 | ||
200 | s->len += ret; | 180 | s->len += ret; |
201 | |||
202 | return len; | ||
203 | } | 181 | } |
204 | EXPORT_SYMBOL_GPL(trace_seq_bprintf); | 182 | EXPORT_SYMBOL_GPL(trace_seq_bprintf); |
205 | 183 | ||
@@ -212,25 +190,21 @@ EXPORT_SYMBOL_GPL(trace_seq_bprintf); | |||
212 | * copy to user routines. This function records a simple string | 190 | * copy to user routines. This function records a simple string |
213 | * into a special buffer (@s) for later retrieval by a sequencer | 191 | * into a special buffer (@s) for later retrieval by a sequencer |
214 | * or other mechanism. | 192 | * or other mechanism. |
215 | * | ||
216 | * Returns how much it wrote to the buffer. | ||
217 | */ | 193 | */ |
218 | int trace_seq_puts(struct trace_seq *s, const char *str) | 194 | void trace_seq_puts(struct trace_seq *s, const char *str) |
219 | { | 195 | { |
220 | unsigned int len = strlen(str); | 196 | unsigned int len = strlen(str); |
221 | 197 | ||
222 | if (s->full) | 198 | if (s->full) |
223 | return 0; | 199 | return; |
224 | 200 | ||
225 | if (len > TRACE_SEQ_BUF_LEFT(s)) { | 201 | if (len > TRACE_SEQ_BUF_LEFT(s)) { |
226 | s->full = 1; | 202 | s->full = 1; |
227 | return 0; | 203 | return; |
228 | } | 204 | } |
229 | 205 | ||
230 | memcpy(s->buffer + s->len, str, len); | 206 | memcpy(s->buffer + s->len, str, len); |
231 | s->len += len; | 207 | s->len += len; |
232 | |||
233 | return len; | ||
234 | } | 208 | } |
235 | EXPORT_SYMBOL_GPL(trace_seq_puts); | 209 | EXPORT_SYMBOL_GPL(trace_seq_puts); |
236 | 210 | ||
@@ -243,22 +217,18 @@ EXPORT_SYMBOL_GPL(trace_seq_puts); | |||
243 | * copy to user routines. This function records a simple charater | 217 | * copy to user routines. This function records a simple charater |
244 | * into a special buffer (@s) for later retrieval by a sequencer | 218 | * into a special buffer (@s) for later retrieval by a sequencer |
245 | * or other mechanism. | 219 | * or other mechanism. |
246 | * | ||
247 | * Returns how much it wrote to the buffer. | ||
248 | */ | 220 | */ |
249 | int trace_seq_putc(struct trace_seq *s, unsigned char c) | 221 | void trace_seq_putc(struct trace_seq *s, unsigned char c) |
250 | { | 222 | { |
251 | if (s->full) | 223 | if (s->full) |
252 | return 0; | 224 | return; |
253 | 225 | ||
254 | if (TRACE_SEQ_BUF_LEFT(s) < 1) { | 226 | if (TRACE_SEQ_BUF_LEFT(s) < 1) { |
255 | s->full = 1; | 227 | s->full = 1; |
256 | return 0; | 228 | return; |
257 | } | 229 | } |
258 | 230 | ||
259 | s->buffer[s->len++] = c; | 231 | s->buffer[s->len++] = c; |
260 | |||
261 | return 1; | ||
262 | } | 232 | } |
263 | EXPORT_SYMBOL_GPL(trace_seq_putc); | 233 | EXPORT_SYMBOL_GPL(trace_seq_putc); |
264 | 234 | ||
@@ -271,23 +241,19 @@ EXPORT_SYMBOL_GPL(trace_seq_putc); | |||
271 | * There may be cases where raw memory needs to be written into the | 241 | * There may be cases where raw memory needs to be written into the |
272 | * buffer and a strcpy() would not work. Using this function allows | 242 | * buffer and a strcpy() would not work. Using this function allows |
273 | * for such cases. | 243 | * for such cases. |
274 | * | ||
275 | * Returns how much it wrote to the buffer. | ||
276 | */ | 244 | */ |
277 | int trace_seq_putmem(struct trace_seq *s, const void *mem, unsigned int len) | 245 | void trace_seq_putmem(struct trace_seq *s, const void *mem, unsigned int len) |
278 | { | 246 | { |
279 | if (s->full) | 247 | if (s->full) |
280 | return 0; | 248 | return; |
281 | 249 | ||
282 | if (len > TRACE_SEQ_BUF_LEFT(s)) { | 250 | if (len > TRACE_SEQ_BUF_LEFT(s)) { |
283 | s->full = 1; | 251 | s->full = 1; |
284 | return 0; | 252 | return; |
285 | } | 253 | } |
286 | 254 | ||
287 | memcpy(s->buffer + s->len, mem, len); | 255 | memcpy(s->buffer + s->len, mem, len); |
288 | s->len += len; | 256 | s->len += len; |
289 | |||
290 | return len; | ||
291 | } | 257 | } |
292 | EXPORT_SYMBOL_GPL(trace_seq_putmem); | 258 | EXPORT_SYMBOL_GPL(trace_seq_putmem); |
293 | 259 | ||
@@ -303,20 +269,17 @@ EXPORT_SYMBOL_GPL(trace_seq_putmem); | |||
303 | * This is similar to trace_seq_putmem() except instead of just copying the | 269 | * This is similar to trace_seq_putmem() except instead of just copying the |
304 | * raw memory into the buffer it writes its ASCII representation of it | 270 | * raw memory into the buffer it writes its ASCII representation of it |
305 | * in hex characters. | 271 | * in hex characters. |
306 | * | ||
307 | * Returns how much it wrote to the buffer. | ||
308 | */ | 272 | */ |
309 | int trace_seq_putmem_hex(struct trace_seq *s, const void *mem, | 273 | void trace_seq_putmem_hex(struct trace_seq *s, const void *mem, |
310 | unsigned int len) | 274 | unsigned int len) |
311 | { | 275 | { |
312 | unsigned char hex[HEX_CHARS]; | 276 | unsigned char hex[HEX_CHARS]; |
313 | const unsigned char *data = mem; | 277 | const unsigned char *data = mem; |
314 | unsigned int start_len; | 278 | unsigned int start_len; |
315 | int i, j; | 279 | int i, j; |
316 | int cnt = 0; | ||
317 | 280 | ||
318 | if (s->full) | 281 | if (s->full) |
319 | return 0; | 282 | return; |
320 | 283 | ||
321 | while (len) { | 284 | while (len) { |
322 | start_len = min(len, HEX_CHARS - 1); | 285 | start_len = min(len, HEX_CHARS - 1); |
@@ -335,9 +298,8 @@ int trace_seq_putmem_hex(struct trace_seq *s, const void *mem, | |||
335 | len -= j / 2; | 298 | len -= j / 2; |
336 | hex[j++] = ' '; | 299 | hex[j++] = ' '; |
337 | 300 | ||
338 | cnt += trace_seq_putmem(s, hex, j); | 301 | trace_seq_putmem(s, hex, j); |
339 | } | 302 | } |
340 | return cnt; | ||
341 | } | 303 | } |
342 | EXPORT_SYMBOL_GPL(trace_seq_putmem_hex); | 304 | EXPORT_SYMBOL_GPL(trace_seq_putmem_hex); |
343 | 305 | ||