diff options
Diffstat (limited to 'net/tipc/log.c')
-rw-r--r-- | net/tipc/log.c | 81 |
1 files changed, 3 insertions, 78 deletions
diff --git a/net/tipc/log.c b/net/tipc/log.c index 9d99f7097d2d..2796044f9941 100644 --- a/net/tipc/log.c +++ b/net/tipc/log.c | |||
@@ -64,9 +64,9 @@ struct print_buf *const TIPC_LOG = &log_buf; | |||
64 | * 'print_string' when writing to a print buffer. This also protects against | 64 | * 'print_string' when writing to a print buffer. This also protects against |
65 | * concurrent writes to the print buffer being written to. | 65 | * concurrent writes to the print buffer being written to. |
66 | * | 66 | * |
67 | * 2) tipc_dump() and tipc_log_XXX() leverage the aforementioned | 67 | * 2) tipc_log_XXX() leverages the aforementioned use of 'print_lock' to |
68 | * use of 'print_lock' to protect against all types of concurrent operations | 68 | * protect against all types of concurrent operations on their associated |
69 | * on their associated print buffer (not just write operations). | 69 | * print buffer (not just write operations). |
70 | * | 70 | * |
71 | * Note: All routines of the form tipc_printbuf_XXX() are lock-free, and rely | 71 | * Note: All routines of the form tipc_printbuf_XXX() are lock-free, and rely |
72 | * on the caller to prevent simultaneous use of the print buffer(s) being | 72 | * on the caller to prevent simultaneous use of the print buffer(s) being |
@@ -268,81 +268,6 @@ void tipc_printf(struct print_buf *pb, const char *fmt, ...) | |||
268 | spin_unlock_bh(&print_lock); | 268 | spin_unlock_bh(&print_lock); |
269 | } | 269 | } |
270 | 270 | ||
271 | #ifdef CONFIG_TIPC_DEBUG | ||
272 | |||
273 | /** | ||
274 | * print_to_console - write string of bytes to console in multiple chunks | ||
275 | */ | ||
276 | |||
277 | static void print_to_console(char *crs, int len) | ||
278 | { | ||
279 | int rest = len; | ||
280 | |||
281 | while (rest > 0) { | ||
282 | int sz = rest < TIPC_PB_MAX_STR ? rest : TIPC_PB_MAX_STR; | ||
283 | char c = crs[sz]; | ||
284 | |||
285 | crs[sz] = 0; | ||
286 | printk((const char *)crs); | ||
287 | crs[sz] = c; | ||
288 | rest -= sz; | ||
289 | crs += sz; | ||
290 | } | ||
291 | } | ||
292 | |||
293 | /** | ||
294 | * printbuf_dump - write print buffer contents to console | ||
295 | */ | ||
296 | |||
297 | static void printbuf_dump(struct print_buf *pb) | ||
298 | { | ||
299 | int len; | ||
300 | |||
301 | if (!pb->buf) { | ||
302 | printk("*** PRINT BUFFER NOT ALLOCATED ***"); | ||
303 | return; | ||
304 | } | ||
305 | |||
306 | /* Dump print buffer from char after cursor to end (if used) */ | ||
307 | |||
308 | len = pb->buf + pb->size - pb->crs - 2; | ||
309 | if ((pb->buf[pb->size - 1] == 0) && (len > 0)) | ||
310 | print_to_console(pb->crs + 1, len); | ||
311 | |||
312 | /* Dump print buffer from start to cursor (always) */ | ||
313 | |||
314 | len = pb->crs - pb->buf; | ||
315 | print_to_console(pb->buf, len); | ||
316 | } | ||
317 | |||
318 | /** | ||
319 | * tipc_dump_dbg - dump (non-console) print buffer to console | ||
320 | * @pb: pointer to print buffer | ||
321 | */ | ||
322 | |||
323 | void tipc_dump_dbg(struct print_buf *pb, const char *fmt, ...) | ||
324 | { | ||
325 | int len; | ||
326 | |||
327 | if (pb == TIPC_CONS) | ||
328 | return; | ||
329 | |||
330 | spin_lock_bh(&print_lock); | ||
331 | |||
332 | FORMAT(print_string, len, fmt); | ||
333 | printk(print_string); | ||
334 | |||
335 | printk("\n---- Start of %s log dump ----\n\n", | ||
336 | (pb == TIPC_LOG) ? "global" : "local"); | ||
337 | printbuf_dump(pb); | ||
338 | tipc_printbuf_reset(pb); | ||
339 | printk("\n---- End of dump ----\n"); | ||
340 | |||
341 | spin_unlock_bh(&print_lock); | ||
342 | } | ||
343 | |||
344 | #endif | ||
345 | |||
346 | /** | 271 | /** |
347 | * tipc_log_resize - change the size of the TIPC log buffer | 272 | * tipc_log_resize - change the size of the TIPC log buffer |
348 | * @log_size: print buffer size to use | 273 | * @log_size: print buffer size to use |