diff options
Diffstat (limited to 'net')
-rw-r--r-- | net/tipc/core.h | 8 | ||||
-rw-r--r-- | net/tipc/log.c | 81 |
2 files changed, 3 insertions, 86 deletions
diff --git a/net/tipc/core.h b/net/tipc/core.h index b4e54f8dd43b..3af0b36e3f1a 100644 --- a/net/tipc/core.h +++ b/net/tipc/core.h | |||
@@ -145,23 +145,15 @@ void tipc_printf(struct print_buf *, const char *fmt, ...); | |||
145 | if (DBG_OUTPUT != TIPC_NULL) \ | 145 | if (DBG_OUTPUT != TIPC_NULL) \ |
146 | tipc_msg_dbg(DBG_OUTPUT, msg, txt); \ | 146 | tipc_msg_dbg(DBG_OUTPUT, msg, txt); \ |
147 | } while (0) | 147 | } while (0) |
148 | #define dump(fmt, arg...) \ | ||
149 | do { \ | ||
150 | if (DBG_OUTPUT != TIPC_NULL) \ | ||
151 | tipc_dump_dbg(DBG_OUTPUT, fmt, ##arg); \ | ||
152 | } while (0) | ||
153 | 148 | ||
154 | void tipc_msg_dbg(struct print_buf *, struct tipc_msg *, const char *); | 149 | void tipc_msg_dbg(struct print_buf *, struct tipc_msg *, const char *); |
155 | void tipc_dump_dbg(struct print_buf *, const char *fmt, ...); | ||
156 | 150 | ||
157 | #else | 151 | #else |
158 | 152 | ||
159 | #define dbg(fmt, arg...) do {} while (0) | 153 | #define dbg(fmt, arg...) do {} while (0) |
160 | #define msg_dbg(msg, txt) do {} while (0) | 154 | #define msg_dbg(msg, txt) do {} while (0) |
161 | #define dump(fmt, arg...) do {} while (0) | ||
162 | 155 | ||
163 | #define tipc_msg_dbg(...) do {} while (0) | 156 | #define tipc_msg_dbg(...) do {} while (0) |
164 | #define tipc_dump_dbg(...) do {} while (0) | ||
165 | 157 | ||
166 | #endif | 158 | #endif |
167 | 159 | ||
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 |