Jason Baron | e9d376f | 2009-02-05 11:51:38 -0500 | [diff] [blame] | 1 | /* |
| 2 | * lib/dynamic_debug.c |
| 3 | * |
| 4 | * make pr_debug()/dev_dbg() calls runtime configurable based upon their |
| 5 | * source module. |
| 6 | * |
| 7 | * Copyright (C) 2008 Jason Baron <jbaron@redhat.com> |
| 8 | * By Greg Banks <gnb@melbourne.sgi.com> |
| 9 | * Copyright (c) 2008 Silicon Graphics Inc. All Rights Reserved. |
Bart Van Assche | 8ba6ebf5 | 2011-01-23 17:17:24 +0100 | [diff] [blame] | 10 | * Copyright (C) 2011 Bart Van Assche. All Rights Reserved. |
Jason Baron | e9d376f | 2009-02-05 11:51:38 -0500 | [diff] [blame] | 11 | */ |
| 12 | |
Joe Perches | 4ad275e | 2011-08-11 14:36:33 -0400 | [diff] [blame] | 13 | #define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__ |
| 14 | |
Jason Baron | e9d376f | 2009-02-05 11:51:38 -0500 | [diff] [blame] | 15 | #include <linux/kernel.h> |
| 16 | #include <linux/module.h> |
| 17 | #include <linux/moduleparam.h> |
| 18 | #include <linux/kallsyms.h> |
| 19 | #include <linux/version.h> |
| 20 | #include <linux/types.h> |
| 21 | #include <linux/mutex.h> |
| 22 | #include <linux/proc_fs.h> |
| 23 | #include <linux/seq_file.h> |
| 24 | #include <linux/list.h> |
| 25 | #include <linux/sysctl.h> |
| 26 | #include <linux/ctype.h> |
André Goddard Rosa | e7d2860 | 2009-12-14 18:01:06 -0800 | [diff] [blame] | 27 | #include <linux/string.h> |
Jason Baron | e9d376f | 2009-02-05 11:51:38 -0500 | [diff] [blame] | 28 | #include <linux/uaccess.h> |
| 29 | #include <linux/dynamic_debug.h> |
| 30 | #include <linux/debugfs.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 31 | #include <linux/slab.h> |
Jason Baron | 52159d9 | 2010-09-17 11:09:17 -0400 | [diff] [blame] | 32 | #include <linux/jump_label.h> |
Bart Van Assche | 8ba6ebf5 | 2011-01-23 17:17:24 +0100 | [diff] [blame] | 33 | #include <linux/hardirq.h> |
Greg Kroah-Hartman | e8d9792 | 2011-02-03 15:59:58 -0800 | [diff] [blame] | 34 | #include <linux/sched.h> |
Joe Perches | cbc4663 | 2011-08-11 14:36:21 -0400 | [diff] [blame] | 35 | #include <linux/device.h> |
Jason Baron | ffa10cb | 2011-08-11 14:36:48 -0400 | [diff] [blame] | 36 | #include <linux/netdevice.h> |
Jason Baron | e9d376f | 2009-02-05 11:51:38 -0500 | [diff] [blame] | 37 | |
| 38 | extern struct _ddebug __start___verbose[]; |
| 39 | extern struct _ddebug __stop___verbose[]; |
| 40 | |
Jason Baron | e9d376f | 2009-02-05 11:51:38 -0500 | [diff] [blame] | 41 | struct ddebug_table { |
| 42 | struct list_head link; |
| 43 | char *mod_name; |
| 44 | unsigned int num_ddebugs; |
Jason Baron | e9d376f | 2009-02-05 11:51:38 -0500 | [diff] [blame] | 45 | struct _ddebug *ddebugs; |
| 46 | }; |
| 47 | |
| 48 | struct ddebug_query { |
| 49 | const char *filename; |
| 50 | const char *module; |
| 51 | const char *function; |
| 52 | const char *format; |
| 53 | unsigned int first_lineno, last_lineno; |
| 54 | }; |
| 55 | |
| 56 | struct ddebug_iter { |
| 57 | struct ddebug_table *table; |
| 58 | unsigned int idx; |
| 59 | }; |
| 60 | |
| 61 | static DEFINE_MUTEX(ddebug_lock); |
| 62 | static LIST_HEAD(ddebug_tables); |
| 63 | static int verbose = 0; |
| 64 | |
| 65 | /* Return the last part of a pathname */ |
| 66 | static inline const char *basename(const char *path) |
| 67 | { |
| 68 | const char *tail = strrchr(path, '/'); |
| 69 | return tail ? tail+1 : path; |
| 70 | } |
| 71 | |
Bart Van Assche | 8ba6ebf5 | 2011-01-23 17:17:24 +0100 | [diff] [blame] | 72 | static struct { unsigned flag:8; char opt_char; } opt_array[] = { |
| 73 | { _DPRINTK_FLAGS_PRINT, 'p' }, |
| 74 | { _DPRINTK_FLAGS_INCL_MODNAME, 'm' }, |
| 75 | { _DPRINTK_FLAGS_INCL_FUNCNAME, 'f' }, |
| 76 | { _DPRINTK_FLAGS_INCL_LINENO, 'l' }, |
| 77 | { _DPRINTK_FLAGS_INCL_TID, 't' }, |
| 78 | }; |
| 79 | |
Jason Baron | e9d376f | 2009-02-05 11:51:38 -0500 | [diff] [blame] | 80 | /* format a string into buf[] which describes the _ddebug's flags */ |
| 81 | static char *ddebug_describe_flags(struct _ddebug *dp, char *buf, |
| 82 | size_t maxlen) |
| 83 | { |
| 84 | char *p = buf; |
Bart Van Assche | 8ba6ebf5 | 2011-01-23 17:17:24 +0100 | [diff] [blame] | 85 | int i; |
Jason Baron | e9d376f | 2009-02-05 11:51:38 -0500 | [diff] [blame] | 86 | |
| 87 | BUG_ON(maxlen < 4); |
Bart Van Assche | 8ba6ebf5 | 2011-01-23 17:17:24 +0100 | [diff] [blame] | 88 | for (i = 0; i < ARRAY_SIZE(opt_array); ++i) |
| 89 | if (dp->flags & opt_array[i].flag) |
| 90 | *p++ = opt_array[i].opt_char; |
Jason Baron | e9d376f | 2009-02-05 11:51:38 -0500 | [diff] [blame] | 91 | if (p == buf) |
| 92 | *p++ = '-'; |
| 93 | *p = '\0'; |
| 94 | |
| 95 | return buf; |
| 96 | } |
| 97 | |
| 98 | /* |
Jason Baron | e9d376f | 2009-02-05 11:51:38 -0500 | [diff] [blame] | 99 | * Search the tables for _ddebug's which match the given |
| 100 | * `query' and apply the `flags' and `mask' to them. Tells |
| 101 | * the user which ddebug's were changed, or whether none |
| 102 | * were matched. |
| 103 | */ |
| 104 | static void ddebug_change(const struct ddebug_query *query, |
| 105 | unsigned int flags, unsigned int mask) |
| 106 | { |
| 107 | int i; |
| 108 | struct ddebug_table *dt; |
| 109 | unsigned int newflags; |
| 110 | unsigned int nfound = 0; |
| 111 | char flagbuf[8]; |
| 112 | |
| 113 | /* search for matching ddebugs */ |
| 114 | mutex_lock(&ddebug_lock); |
| 115 | list_for_each_entry(dt, &ddebug_tables, link) { |
| 116 | |
| 117 | /* match against the module name */ |
| 118 | if (query->module != NULL && |
| 119 | strcmp(query->module, dt->mod_name)) |
| 120 | continue; |
| 121 | |
| 122 | for (i = 0 ; i < dt->num_ddebugs ; i++) { |
| 123 | struct _ddebug *dp = &dt->ddebugs[i]; |
| 124 | |
| 125 | /* match against the source filename */ |
| 126 | if (query->filename != NULL && |
| 127 | strcmp(query->filename, dp->filename) && |
| 128 | strcmp(query->filename, basename(dp->filename))) |
| 129 | continue; |
| 130 | |
| 131 | /* match against the function */ |
| 132 | if (query->function != NULL && |
| 133 | strcmp(query->function, dp->function)) |
| 134 | continue; |
| 135 | |
| 136 | /* match against the format */ |
| 137 | if (query->format != NULL && |
| 138 | strstr(dp->format, query->format) == NULL) |
| 139 | continue; |
| 140 | |
| 141 | /* match against the line number range */ |
| 142 | if (query->first_lineno && |
| 143 | dp->lineno < query->first_lineno) |
| 144 | continue; |
| 145 | if (query->last_lineno && |
| 146 | dp->lineno > query->last_lineno) |
| 147 | continue; |
| 148 | |
| 149 | nfound++; |
| 150 | |
| 151 | newflags = (dp->flags & mask) | flags; |
| 152 | if (newflags == dp->flags) |
| 153 | continue; |
Jason Baron | e9d376f | 2009-02-05 11:51:38 -0500 | [diff] [blame] | 154 | dp->flags = newflags; |
Jason Baron | 2d75af2 | 2011-01-07 13:36:58 -0500 | [diff] [blame] | 155 | if (newflags) |
| 156 | dp->enabled = 1; |
| 157 | else |
| 158 | dp->enabled = 0; |
Jason Baron | e9d376f | 2009-02-05 11:51:38 -0500 | [diff] [blame] | 159 | if (verbose) |
Joe Perches | 4ad275e | 2011-08-11 14:36:33 -0400 | [diff] [blame] | 160 | pr_info("changed %s:%d [%s]%s %s\n", |
Jason Baron | e9d376f | 2009-02-05 11:51:38 -0500 | [diff] [blame] | 161 | dp->filename, dp->lineno, |
| 162 | dt->mod_name, dp->function, |
| 163 | ddebug_describe_flags(dp, flagbuf, |
| 164 | sizeof(flagbuf))); |
| 165 | } |
| 166 | } |
| 167 | mutex_unlock(&ddebug_lock); |
| 168 | |
| 169 | if (!nfound && verbose) |
Joe Perches | 4ad275e | 2011-08-11 14:36:33 -0400 | [diff] [blame] | 170 | pr_info("no matches for query\n"); |
Jason Baron | e9d376f | 2009-02-05 11:51:38 -0500 | [diff] [blame] | 171 | } |
| 172 | |
| 173 | /* |
Jason Baron | e9d376f | 2009-02-05 11:51:38 -0500 | [diff] [blame] | 174 | * Split the buffer `buf' into space-separated words. |
Greg Banks | 9898abb | 2009-02-06 12:54:26 +1100 | [diff] [blame] | 175 | * Handles simple " and ' quoting, i.e. without nested, |
| 176 | * embedded or escaped \". Return the number of words |
| 177 | * or <0 on error. |
Jason Baron | e9d376f | 2009-02-05 11:51:38 -0500 | [diff] [blame] | 178 | */ |
| 179 | static int ddebug_tokenize(char *buf, char *words[], int maxwords) |
| 180 | { |
| 181 | int nwords = 0; |
| 182 | |
Greg Banks | 9898abb | 2009-02-06 12:54:26 +1100 | [diff] [blame] | 183 | while (*buf) { |
| 184 | char *end; |
| 185 | |
| 186 | /* Skip leading whitespace */ |
André Goddard Rosa | e7d2860 | 2009-12-14 18:01:06 -0800 | [diff] [blame] | 187 | buf = skip_spaces(buf); |
Greg Banks | 9898abb | 2009-02-06 12:54:26 +1100 | [diff] [blame] | 188 | if (!*buf) |
| 189 | break; /* oh, it was trailing whitespace */ |
| 190 | |
| 191 | /* Run `end' over a word, either whitespace separated or quoted */ |
| 192 | if (*buf == '"' || *buf == '\'') { |
| 193 | int quote = *buf++; |
| 194 | for (end = buf ; *end && *end != quote ; end++) |
| 195 | ; |
| 196 | if (!*end) |
| 197 | return -EINVAL; /* unclosed quote */ |
| 198 | } else { |
| 199 | for (end = buf ; *end && !isspace(*end) ; end++) |
| 200 | ; |
| 201 | BUG_ON(end == buf); |
| 202 | } |
| 203 | /* Here `buf' is the start of the word, `end' is one past the end */ |
| 204 | |
| 205 | if (nwords == maxwords) |
| 206 | return -EINVAL; /* ran out of words[] before bytes */ |
| 207 | if (*end) |
| 208 | *end++ = '\0'; /* terminate the word */ |
| 209 | words[nwords++] = buf; |
| 210 | buf = end; |
| 211 | } |
Jason Baron | e9d376f | 2009-02-05 11:51:38 -0500 | [diff] [blame] | 212 | |
| 213 | if (verbose) { |
| 214 | int i; |
Joe Perches | 4ad275e | 2011-08-11 14:36:33 -0400 | [diff] [blame] | 215 | pr_info("split into words:"); |
Jason Baron | e9d376f | 2009-02-05 11:51:38 -0500 | [diff] [blame] | 216 | for (i = 0 ; i < nwords ; i++) |
Joe Perches | 4ad275e | 2011-08-11 14:36:33 -0400 | [diff] [blame] | 217 | pr_cont(" \"%s\"", words[i]); |
| 218 | pr_cont("\n"); |
Jason Baron | e9d376f | 2009-02-05 11:51:38 -0500 | [diff] [blame] | 219 | } |
| 220 | |
| 221 | return nwords; |
| 222 | } |
| 223 | |
| 224 | /* |
| 225 | * Parse a single line number. Note that the empty string "" |
| 226 | * is treated as a special case and converted to zero, which |
| 227 | * is later treated as a "don't care" value. |
| 228 | */ |
| 229 | static inline int parse_lineno(const char *str, unsigned int *val) |
| 230 | { |
| 231 | char *end = NULL; |
| 232 | BUG_ON(str == NULL); |
| 233 | if (*str == '\0') { |
| 234 | *val = 0; |
| 235 | return 0; |
| 236 | } |
| 237 | *val = simple_strtoul(str, &end, 10); |
| 238 | return end == NULL || end == str || *end != '\0' ? -EINVAL : 0; |
| 239 | } |
| 240 | |
| 241 | /* |
| 242 | * Undo octal escaping in a string, inplace. This is useful to |
| 243 | * allow the user to express a query which matches a format |
| 244 | * containing embedded spaces. |
| 245 | */ |
| 246 | #define isodigit(c) ((c) >= '0' && (c) <= '7') |
| 247 | static char *unescape(char *str) |
| 248 | { |
| 249 | char *in = str; |
| 250 | char *out = str; |
| 251 | |
| 252 | while (*in) { |
| 253 | if (*in == '\\') { |
| 254 | if (in[1] == '\\') { |
| 255 | *out++ = '\\'; |
| 256 | in += 2; |
| 257 | continue; |
| 258 | } else if (in[1] == 't') { |
| 259 | *out++ = '\t'; |
| 260 | in += 2; |
| 261 | continue; |
| 262 | } else if (in[1] == 'n') { |
| 263 | *out++ = '\n'; |
| 264 | in += 2; |
| 265 | continue; |
| 266 | } else if (isodigit(in[1]) && |
| 267 | isodigit(in[2]) && |
| 268 | isodigit(in[3])) { |
| 269 | *out++ = ((in[1] - '0')<<6) | |
| 270 | ((in[2] - '0')<<3) | |
| 271 | (in[3] - '0'); |
| 272 | in += 4; |
| 273 | continue; |
| 274 | } |
| 275 | } |
| 276 | *out++ = *in++; |
| 277 | } |
| 278 | *out = '\0'; |
| 279 | |
| 280 | return str; |
| 281 | } |
| 282 | |
| 283 | /* |
| 284 | * Parse words[] as a ddebug query specification, which is a series |
| 285 | * of (keyword, value) pairs chosen from these possibilities: |
| 286 | * |
| 287 | * func <function-name> |
| 288 | * file <full-pathname> |
| 289 | * file <base-filename> |
| 290 | * module <module-name> |
| 291 | * format <escaped-string-to-find-in-format> |
| 292 | * line <lineno> |
| 293 | * line <first-lineno>-<last-lineno> // where either may be empty |
| 294 | */ |
| 295 | static int ddebug_parse_query(char *words[], int nwords, |
| 296 | struct ddebug_query *query) |
| 297 | { |
| 298 | unsigned int i; |
| 299 | |
| 300 | /* check we have an even number of words */ |
| 301 | if (nwords % 2 != 0) |
| 302 | return -EINVAL; |
| 303 | memset(query, 0, sizeof(*query)); |
| 304 | |
| 305 | for (i = 0 ; i < nwords ; i += 2) { |
| 306 | if (!strcmp(words[i], "func")) |
| 307 | query->function = words[i+1]; |
| 308 | else if (!strcmp(words[i], "file")) |
| 309 | query->filename = words[i+1]; |
| 310 | else if (!strcmp(words[i], "module")) |
| 311 | query->module = words[i+1]; |
| 312 | else if (!strcmp(words[i], "format")) |
| 313 | query->format = unescape(words[i+1]); |
| 314 | else if (!strcmp(words[i], "line")) { |
| 315 | char *first = words[i+1]; |
| 316 | char *last = strchr(first, '-'); |
| 317 | if (last) |
| 318 | *last++ = '\0'; |
| 319 | if (parse_lineno(first, &query->first_lineno) < 0) |
| 320 | return -EINVAL; |
| 321 | if (last != NULL) { |
| 322 | /* range <first>-<last> */ |
| 323 | if (parse_lineno(last, &query->last_lineno) < 0) |
| 324 | return -EINVAL; |
| 325 | } else { |
| 326 | query->last_lineno = query->first_lineno; |
| 327 | } |
| 328 | } else { |
| 329 | if (verbose) |
Joe Perches | 4ad275e | 2011-08-11 14:36:33 -0400 | [diff] [blame] | 330 | pr_err("unknown keyword \"%s\"\n", words[i]); |
Jason Baron | e9d376f | 2009-02-05 11:51:38 -0500 | [diff] [blame] | 331 | return -EINVAL; |
| 332 | } |
| 333 | } |
| 334 | |
| 335 | if (verbose) |
Joe Perches | 4ad275e | 2011-08-11 14:36:33 -0400 | [diff] [blame] | 336 | pr_info("q->function=\"%s\" q->filename=\"%s\" " |
| 337 | "q->module=\"%s\" q->format=\"%s\" q->lineno=%u-%u\n", |
| 338 | query->function, query->filename, |
Jason Baron | e9d376f | 2009-02-05 11:51:38 -0500 | [diff] [blame] | 339 | query->module, query->format, query->first_lineno, |
| 340 | query->last_lineno); |
| 341 | |
| 342 | return 0; |
| 343 | } |
| 344 | |
| 345 | /* |
| 346 | * Parse `str' as a flags specification, format [-+=][p]+. |
| 347 | * Sets up *maskp and *flagsp to be used when changing the |
| 348 | * flags fields of matched _ddebug's. Returns 0 on success |
| 349 | * or <0 on error. |
| 350 | */ |
| 351 | static int ddebug_parse_flags(const char *str, unsigned int *flagsp, |
| 352 | unsigned int *maskp) |
| 353 | { |
| 354 | unsigned flags = 0; |
Bart Van Assche | 8ba6ebf5 | 2011-01-23 17:17:24 +0100 | [diff] [blame] | 355 | int op = '=', i; |
Jason Baron | e9d376f | 2009-02-05 11:51:38 -0500 | [diff] [blame] | 356 | |
| 357 | switch (*str) { |
| 358 | case '+': |
| 359 | case '-': |
| 360 | case '=': |
| 361 | op = *str++; |
| 362 | break; |
| 363 | default: |
| 364 | return -EINVAL; |
| 365 | } |
| 366 | if (verbose) |
Joe Perches | 4ad275e | 2011-08-11 14:36:33 -0400 | [diff] [blame] | 367 | pr_info("op='%c'\n", op); |
Jason Baron | e9d376f | 2009-02-05 11:51:38 -0500 | [diff] [blame] | 368 | |
| 369 | for ( ; *str ; ++str) { |
Bart Van Assche | 8ba6ebf5 | 2011-01-23 17:17:24 +0100 | [diff] [blame] | 370 | for (i = ARRAY_SIZE(opt_array) - 1; i >= 0; i--) { |
| 371 | if (*str == opt_array[i].opt_char) { |
| 372 | flags |= opt_array[i].flag; |
| 373 | break; |
| 374 | } |
Jason Baron | e9d376f | 2009-02-05 11:51:38 -0500 | [diff] [blame] | 375 | } |
Bart Van Assche | 8ba6ebf5 | 2011-01-23 17:17:24 +0100 | [diff] [blame] | 376 | if (i < 0) |
| 377 | return -EINVAL; |
Jason Baron | e9d376f | 2009-02-05 11:51:38 -0500 | [diff] [blame] | 378 | } |
| 379 | if (flags == 0) |
| 380 | return -EINVAL; |
| 381 | if (verbose) |
Joe Perches | 4ad275e | 2011-08-11 14:36:33 -0400 | [diff] [blame] | 382 | pr_info("flags=0x%x\n", flags); |
Jason Baron | e9d376f | 2009-02-05 11:51:38 -0500 | [diff] [blame] | 383 | |
| 384 | /* calculate final *flagsp, *maskp according to mask and op */ |
| 385 | switch (op) { |
| 386 | case '=': |
| 387 | *maskp = 0; |
| 388 | *flagsp = flags; |
| 389 | break; |
| 390 | case '+': |
| 391 | *maskp = ~0U; |
| 392 | *flagsp = flags; |
| 393 | break; |
| 394 | case '-': |
| 395 | *maskp = ~flags; |
| 396 | *flagsp = 0; |
| 397 | break; |
| 398 | } |
| 399 | if (verbose) |
Joe Perches | 4ad275e | 2011-08-11 14:36:33 -0400 | [diff] [blame] | 400 | pr_info("*flagsp=0x%x *maskp=0x%x\n", *flagsp, *maskp); |
Jason Baron | e9d376f | 2009-02-05 11:51:38 -0500 | [diff] [blame] | 401 | return 0; |
| 402 | } |
| 403 | |
Thomas Renninger | fd89cfb | 2010-08-06 16:11:01 +0200 | [diff] [blame] | 404 | static int ddebug_exec_query(char *query_string) |
| 405 | { |
| 406 | unsigned int flags = 0, mask = 0; |
| 407 | struct ddebug_query query; |
| 408 | #define MAXWORDS 9 |
| 409 | int nwords; |
| 410 | char *words[MAXWORDS]; |
| 411 | |
| 412 | nwords = ddebug_tokenize(query_string, words, MAXWORDS); |
| 413 | if (nwords <= 0) |
| 414 | return -EINVAL; |
| 415 | if (ddebug_parse_query(words, nwords-1, &query)) |
| 416 | return -EINVAL; |
| 417 | if (ddebug_parse_flags(words[nwords-1], &flags, &mask)) |
| 418 | return -EINVAL; |
| 419 | |
| 420 | /* actually go and implement the change */ |
| 421 | ddebug_change(&query, flags, mask); |
| 422 | return 0; |
| 423 | } |
| 424 | |
Jason Baron | 431625d | 2011-10-04 14:13:19 -0700 | [diff] [blame] | 425 | #define PREFIX_SIZE 64 |
| 426 | |
| 427 | static int remaining(int wrote) |
Bart Van Assche | 8ba6ebf5 | 2011-01-23 17:17:24 +0100 | [diff] [blame] | 428 | { |
Jason Baron | 431625d | 2011-10-04 14:13:19 -0700 | [diff] [blame] | 429 | if (PREFIX_SIZE - wrote > 0) |
| 430 | return PREFIX_SIZE - wrote; |
| 431 | return 0; |
| 432 | } |
Bart Van Assche | 8ba6ebf5 | 2011-01-23 17:17:24 +0100 | [diff] [blame] | 433 | |
Jason Baron | 431625d | 2011-10-04 14:13:19 -0700 | [diff] [blame] | 434 | static char *dynamic_emit_prefix(const struct _ddebug *desc, char *buf) |
| 435 | { |
| 436 | int pos_after_tid; |
| 437 | int pos = 0; |
| 438 | |
| 439 | pos += snprintf(buf + pos, remaining(pos), "%s", KERN_DEBUG); |
| 440 | if (desc->flags & _DPRINTK_FLAGS_INCL_TID) { |
Bart Van Assche | 8ba6ebf5 | 2011-01-23 17:17:24 +0100 | [diff] [blame] | 441 | if (in_interrupt()) |
Jason Baron | 431625d | 2011-10-04 14:13:19 -0700 | [diff] [blame] | 442 | pos += snprintf(buf + pos, remaining(pos), "%s ", |
| 443 | "<intr>"); |
Bart Van Assche | 8ba6ebf5 | 2011-01-23 17:17:24 +0100 | [diff] [blame] | 444 | else |
Jason Baron | 431625d | 2011-10-04 14:13:19 -0700 | [diff] [blame] | 445 | pos += snprintf(buf + pos, remaining(pos), "[%d] ", |
| 446 | task_pid_vnr(current)); |
Bart Van Assche | 8ba6ebf5 | 2011-01-23 17:17:24 +0100 | [diff] [blame] | 447 | } |
Jason Baron | 431625d | 2011-10-04 14:13:19 -0700 | [diff] [blame] | 448 | pos_after_tid = pos; |
| 449 | if (desc->flags & _DPRINTK_FLAGS_INCL_MODNAME) |
| 450 | pos += snprintf(buf + pos, remaining(pos), "%s:", |
| 451 | desc->modname); |
| 452 | if (desc->flags & _DPRINTK_FLAGS_INCL_FUNCNAME) |
| 453 | pos += snprintf(buf + pos, remaining(pos), "%s:", |
| 454 | desc->function); |
| 455 | if (desc->flags & _DPRINTK_FLAGS_INCL_LINENO) |
| 456 | pos += snprintf(buf + pos, remaining(pos), "%d:", desc->lineno); |
| 457 | if (pos - pos_after_tid) |
| 458 | pos += snprintf(buf + pos, remaining(pos), " "); |
| 459 | if (pos >= PREFIX_SIZE) |
| 460 | buf[PREFIX_SIZE - 1] = '\0'; |
Joe Perches | 6c2140e | 2011-08-11 14:36:25 -0400 | [diff] [blame] | 461 | |
Jason Baron | 431625d | 2011-10-04 14:13:19 -0700 | [diff] [blame] | 462 | return buf; |
Joe Perches | 6c2140e | 2011-08-11 14:36:25 -0400 | [diff] [blame] | 463 | } |
| 464 | |
| 465 | int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...) |
| 466 | { |
| 467 | va_list args; |
| 468 | int res; |
Jason Baron | 431625d | 2011-10-04 14:13:19 -0700 | [diff] [blame] | 469 | struct va_format vaf; |
| 470 | char buf[PREFIX_SIZE]; |
Joe Perches | 6c2140e | 2011-08-11 14:36:25 -0400 | [diff] [blame] | 471 | |
| 472 | BUG_ON(!descriptor); |
| 473 | BUG_ON(!fmt); |
| 474 | |
| 475 | va_start(args, fmt); |
Jason Baron | 431625d | 2011-10-04 14:13:19 -0700 | [diff] [blame] | 476 | vaf.fmt = fmt; |
| 477 | vaf.va = &args; |
| 478 | res = printk("%s%pV", dynamic_emit_prefix(descriptor, buf), &vaf); |
Bart Van Assche | 8ba6ebf5 | 2011-01-23 17:17:24 +0100 | [diff] [blame] | 479 | va_end(args); |
| 480 | |
| 481 | return res; |
| 482 | } |
| 483 | EXPORT_SYMBOL(__dynamic_pr_debug); |
| 484 | |
Joe Perches | cbc4663 | 2011-08-11 14:36:21 -0400 | [diff] [blame] | 485 | int __dynamic_dev_dbg(struct _ddebug *descriptor, |
| 486 | const struct device *dev, const char *fmt, ...) |
| 487 | { |
| 488 | struct va_format vaf; |
| 489 | va_list args; |
| 490 | int res; |
Jason Baron | 431625d | 2011-10-04 14:13:19 -0700 | [diff] [blame] | 491 | char buf[PREFIX_SIZE]; |
Joe Perches | cbc4663 | 2011-08-11 14:36:21 -0400 | [diff] [blame] | 492 | |
| 493 | BUG_ON(!descriptor); |
| 494 | BUG_ON(!fmt); |
| 495 | |
| 496 | va_start(args, fmt); |
Joe Perches | cbc4663 | 2011-08-11 14:36:21 -0400 | [diff] [blame] | 497 | vaf.fmt = fmt; |
| 498 | vaf.va = &args; |
Jason Baron | 431625d | 2011-10-04 14:13:19 -0700 | [diff] [blame] | 499 | res = __dev_printk(dynamic_emit_prefix(descriptor, buf), dev, &vaf); |
Joe Perches | cbc4663 | 2011-08-11 14:36:21 -0400 | [diff] [blame] | 500 | va_end(args); |
| 501 | |
| 502 | return res; |
| 503 | } |
| 504 | EXPORT_SYMBOL(__dynamic_dev_dbg); |
| 505 | |
Jason Baron | 0feefd9 | 2011-10-04 14:13:22 -0700 | [diff] [blame^] | 506 | #ifdef CONFIG_NET |
| 507 | |
Jason Baron | ffa10cb | 2011-08-11 14:36:48 -0400 | [diff] [blame] | 508 | int __dynamic_netdev_dbg(struct _ddebug *descriptor, |
| 509 | const struct net_device *dev, const char *fmt, ...) |
| 510 | { |
| 511 | struct va_format vaf; |
| 512 | va_list args; |
| 513 | int res; |
Jason Baron | 431625d | 2011-10-04 14:13:19 -0700 | [diff] [blame] | 514 | char buf[PREFIX_SIZE]; |
Jason Baron | ffa10cb | 2011-08-11 14:36:48 -0400 | [diff] [blame] | 515 | |
| 516 | BUG_ON(!descriptor); |
| 517 | BUG_ON(!fmt); |
| 518 | |
| 519 | va_start(args, fmt); |
Jason Baron | ffa10cb | 2011-08-11 14:36:48 -0400 | [diff] [blame] | 520 | vaf.fmt = fmt; |
| 521 | vaf.va = &args; |
Jason Baron | 431625d | 2011-10-04 14:13:19 -0700 | [diff] [blame] | 522 | res = __netdev_printk(dynamic_emit_prefix(descriptor, buf), dev, &vaf); |
Jason Baron | ffa10cb | 2011-08-11 14:36:48 -0400 | [diff] [blame] | 523 | va_end(args); |
| 524 | |
| 525 | return res; |
| 526 | } |
| 527 | EXPORT_SYMBOL(__dynamic_netdev_dbg); |
| 528 | |
Jason Baron | 0feefd9 | 2011-10-04 14:13:22 -0700 | [diff] [blame^] | 529 | #endif |
| 530 | |
Thomas Renninger | a648ec0 | 2010-08-06 16:11:02 +0200 | [diff] [blame] | 531 | static __initdata char ddebug_setup_string[1024]; |
| 532 | static __init int ddebug_setup_query(char *str) |
| 533 | { |
| 534 | if (strlen(str) >= 1024) { |
Joe Perches | 4ad275e | 2011-08-11 14:36:33 -0400 | [diff] [blame] | 535 | pr_warn("ddebug boot param string too large\n"); |
Thomas Renninger | a648ec0 | 2010-08-06 16:11:02 +0200 | [diff] [blame] | 536 | return 0; |
| 537 | } |
| 538 | strcpy(ddebug_setup_string, str); |
| 539 | return 1; |
| 540 | } |
| 541 | |
| 542 | __setup("ddebug_query=", ddebug_setup_query); |
| 543 | |
Jason Baron | e9d376f | 2009-02-05 11:51:38 -0500 | [diff] [blame] | 544 | /* |
| 545 | * File_ops->write method for <debugfs>/dynamic_debug/conrol. Gathers the |
| 546 | * command text from userspace, parses and executes it. |
| 547 | */ |
| 548 | static ssize_t ddebug_proc_write(struct file *file, const char __user *ubuf, |
| 549 | size_t len, loff_t *offp) |
| 550 | { |
Jason Baron | e9d376f | 2009-02-05 11:51:38 -0500 | [diff] [blame] | 551 | char tmpbuf[256]; |
Thomas Renninger | fd89cfb | 2010-08-06 16:11:01 +0200 | [diff] [blame] | 552 | int ret; |
Jason Baron | e9d376f | 2009-02-05 11:51:38 -0500 | [diff] [blame] | 553 | |
| 554 | if (len == 0) |
| 555 | return 0; |
| 556 | /* we don't check *offp -- multiple writes() are allowed */ |
| 557 | if (len > sizeof(tmpbuf)-1) |
| 558 | return -E2BIG; |
| 559 | if (copy_from_user(tmpbuf, ubuf, len)) |
| 560 | return -EFAULT; |
| 561 | tmpbuf[len] = '\0'; |
| 562 | if (verbose) |
Joe Perches | 4ad275e | 2011-08-11 14:36:33 -0400 | [diff] [blame] | 563 | pr_info("read %d bytes from userspace\n", (int)len); |
Jason Baron | e9d376f | 2009-02-05 11:51:38 -0500 | [diff] [blame] | 564 | |
Thomas Renninger | fd89cfb | 2010-08-06 16:11:01 +0200 | [diff] [blame] | 565 | ret = ddebug_exec_query(tmpbuf); |
| 566 | if (ret) |
| 567 | return ret; |
Jason Baron | e9d376f | 2009-02-05 11:51:38 -0500 | [diff] [blame] | 568 | |
| 569 | *offp += len; |
| 570 | return len; |
| 571 | } |
| 572 | |
| 573 | /* |
| 574 | * Set the iterator to point to the first _ddebug object |
| 575 | * and return a pointer to that first object. Returns |
| 576 | * NULL if there are no _ddebugs at all. |
| 577 | */ |
| 578 | static struct _ddebug *ddebug_iter_first(struct ddebug_iter *iter) |
| 579 | { |
| 580 | if (list_empty(&ddebug_tables)) { |
| 581 | iter->table = NULL; |
| 582 | iter->idx = 0; |
| 583 | return NULL; |
| 584 | } |
| 585 | iter->table = list_entry(ddebug_tables.next, |
| 586 | struct ddebug_table, link); |
| 587 | iter->idx = 0; |
| 588 | return &iter->table->ddebugs[iter->idx]; |
| 589 | } |
| 590 | |
| 591 | /* |
| 592 | * Advance the iterator to point to the next _ddebug |
| 593 | * object from the one the iterator currently points at, |
| 594 | * and returns a pointer to the new _ddebug. Returns |
| 595 | * NULL if the iterator has seen all the _ddebugs. |
| 596 | */ |
| 597 | static struct _ddebug *ddebug_iter_next(struct ddebug_iter *iter) |
| 598 | { |
| 599 | if (iter->table == NULL) |
| 600 | return NULL; |
| 601 | if (++iter->idx == iter->table->num_ddebugs) { |
| 602 | /* iterate to next table */ |
| 603 | iter->idx = 0; |
| 604 | if (list_is_last(&iter->table->link, &ddebug_tables)) { |
| 605 | iter->table = NULL; |
| 606 | return NULL; |
| 607 | } |
| 608 | iter->table = list_entry(iter->table->link.next, |
| 609 | struct ddebug_table, link); |
| 610 | } |
| 611 | return &iter->table->ddebugs[iter->idx]; |
| 612 | } |
| 613 | |
| 614 | /* |
| 615 | * Seq_ops start method. Called at the start of every |
| 616 | * read() call from userspace. Takes the ddebug_lock and |
| 617 | * seeks the seq_file's iterator to the given position. |
| 618 | */ |
| 619 | static void *ddebug_proc_start(struct seq_file *m, loff_t *pos) |
| 620 | { |
| 621 | struct ddebug_iter *iter = m->private; |
| 622 | struct _ddebug *dp; |
| 623 | int n = *pos; |
| 624 | |
| 625 | if (verbose) |
Joe Perches | 4ad275e | 2011-08-11 14:36:33 -0400 | [diff] [blame] | 626 | pr_info("called m=%p *pos=%lld\n", m, (unsigned long long)*pos); |
Jason Baron | e9d376f | 2009-02-05 11:51:38 -0500 | [diff] [blame] | 627 | |
| 628 | mutex_lock(&ddebug_lock); |
| 629 | |
| 630 | if (!n) |
| 631 | return SEQ_START_TOKEN; |
| 632 | if (n < 0) |
| 633 | return NULL; |
| 634 | dp = ddebug_iter_first(iter); |
| 635 | while (dp != NULL && --n > 0) |
| 636 | dp = ddebug_iter_next(iter); |
| 637 | return dp; |
| 638 | } |
| 639 | |
| 640 | /* |
| 641 | * Seq_ops next method. Called several times within a read() |
| 642 | * call from userspace, with ddebug_lock held. Walks to the |
| 643 | * next _ddebug object with a special case for the header line. |
| 644 | */ |
| 645 | static void *ddebug_proc_next(struct seq_file *m, void *p, loff_t *pos) |
| 646 | { |
| 647 | struct ddebug_iter *iter = m->private; |
| 648 | struct _ddebug *dp; |
| 649 | |
| 650 | if (verbose) |
Joe Perches | 4ad275e | 2011-08-11 14:36:33 -0400 | [diff] [blame] | 651 | pr_info("called m=%p p=%p *pos=%lld\n", |
| 652 | m, p, (unsigned long long)*pos); |
Jason Baron | e9d376f | 2009-02-05 11:51:38 -0500 | [diff] [blame] | 653 | |
| 654 | if (p == SEQ_START_TOKEN) |
| 655 | dp = ddebug_iter_first(iter); |
| 656 | else |
| 657 | dp = ddebug_iter_next(iter); |
| 658 | ++*pos; |
| 659 | return dp; |
| 660 | } |
| 661 | |
| 662 | /* |
| 663 | * Seq_ops show method. Called several times within a read() |
| 664 | * call from userspace, with ddebug_lock held. Formats the |
| 665 | * current _ddebug as a single human-readable line, with a |
| 666 | * special case for the header line. |
| 667 | */ |
| 668 | static int ddebug_proc_show(struct seq_file *m, void *p) |
| 669 | { |
| 670 | struct ddebug_iter *iter = m->private; |
| 671 | struct _ddebug *dp = p; |
| 672 | char flagsbuf[8]; |
| 673 | |
| 674 | if (verbose) |
Joe Perches | 4ad275e | 2011-08-11 14:36:33 -0400 | [diff] [blame] | 675 | pr_info("called m=%p p=%p\n", m, p); |
Jason Baron | e9d376f | 2009-02-05 11:51:38 -0500 | [diff] [blame] | 676 | |
| 677 | if (p == SEQ_START_TOKEN) { |
| 678 | seq_puts(m, |
| 679 | "# filename:lineno [module]function flags format\n"); |
| 680 | return 0; |
| 681 | } |
| 682 | |
| 683 | seq_printf(m, "%s:%u [%s]%s %s \"", |
| 684 | dp->filename, dp->lineno, |
| 685 | iter->table->mod_name, dp->function, |
| 686 | ddebug_describe_flags(dp, flagsbuf, sizeof(flagsbuf))); |
| 687 | seq_escape(m, dp->format, "\t\r\n\""); |
| 688 | seq_puts(m, "\"\n"); |
| 689 | |
| 690 | return 0; |
| 691 | } |
| 692 | |
| 693 | /* |
| 694 | * Seq_ops stop method. Called at the end of each read() |
| 695 | * call from userspace. Drops ddebug_lock. |
| 696 | */ |
| 697 | static void ddebug_proc_stop(struct seq_file *m, void *p) |
| 698 | { |
| 699 | if (verbose) |
Joe Perches | 4ad275e | 2011-08-11 14:36:33 -0400 | [diff] [blame] | 700 | pr_info("called m=%p p=%p\n", m, p); |
Jason Baron | e9d376f | 2009-02-05 11:51:38 -0500 | [diff] [blame] | 701 | mutex_unlock(&ddebug_lock); |
| 702 | } |
| 703 | |
| 704 | static const struct seq_operations ddebug_proc_seqops = { |
| 705 | .start = ddebug_proc_start, |
| 706 | .next = ddebug_proc_next, |
| 707 | .show = ddebug_proc_show, |
| 708 | .stop = ddebug_proc_stop |
| 709 | }; |
| 710 | |
| 711 | /* |
| 712 | * File_ops->open method for <debugfs>/dynamic_debug/control. Does the seq_file |
| 713 | * setup dance, and also creates an iterator to walk the _ddebugs. |
| 714 | * Note that we create a seq_file always, even for O_WRONLY files |
| 715 | * where it's not needed, as doing so simplifies the ->release method. |
| 716 | */ |
| 717 | static int ddebug_proc_open(struct inode *inode, struct file *file) |
| 718 | { |
| 719 | struct ddebug_iter *iter; |
| 720 | int err; |
| 721 | |
| 722 | if (verbose) |
Joe Perches | 4ad275e | 2011-08-11 14:36:33 -0400 | [diff] [blame] | 723 | pr_info("called\n"); |
Jason Baron | e9d376f | 2009-02-05 11:51:38 -0500 | [diff] [blame] | 724 | |
| 725 | iter = kzalloc(sizeof(*iter), GFP_KERNEL); |
| 726 | if (iter == NULL) |
| 727 | return -ENOMEM; |
| 728 | |
| 729 | err = seq_open(file, &ddebug_proc_seqops); |
| 730 | if (err) { |
| 731 | kfree(iter); |
| 732 | return err; |
| 733 | } |
| 734 | ((struct seq_file *) file->private_data)->private = iter; |
| 735 | return 0; |
| 736 | } |
| 737 | |
| 738 | static const struct file_operations ddebug_proc_fops = { |
| 739 | .owner = THIS_MODULE, |
| 740 | .open = ddebug_proc_open, |
| 741 | .read = seq_read, |
| 742 | .llseek = seq_lseek, |
| 743 | .release = seq_release_private, |
| 744 | .write = ddebug_proc_write |
| 745 | }; |
| 746 | |
| 747 | /* |
| 748 | * Allocate a new ddebug_table for the given module |
| 749 | * and add it to the global list. |
| 750 | */ |
| 751 | int ddebug_add_module(struct _ddebug *tab, unsigned int n, |
| 752 | const char *name) |
| 753 | { |
| 754 | struct ddebug_table *dt; |
| 755 | char *new_name; |
| 756 | |
| 757 | dt = kzalloc(sizeof(*dt), GFP_KERNEL); |
| 758 | if (dt == NULL) |
| 759 | return -ENOMEM; |
| 760 | new_name = kstrdup(name, GFP_KERNEL); |
| 761 | if (new_name == NULL) { |
| 762 | kfree(dt); |
| 763 | return -ENOMEM; |
| 764 | } |
| 765 | dt->mod_name = new_name; |
| 766 | dt->num_ddebugs = n; |
Jason Baron | e9d376f | 2009-02-05 11:51:38 -0500 | [diff] [blame] | 767 | dt->ddebugs = tab; |
| 768 | |
| 769 | mutex_lock(&ddebug_lock); |
| 770 | list_add_tail(&dt->link, &ddebug_tables); |
| 771 | mutex_unlock(&ddebug_lock); |
| 772 | |
| 773 | if (verbose) |
Joe Perches | 4ad275e | 2011-08-11 14:36:33 -0400 | [diff] [blame] | 774 | pr_info("%u debug prints in module %s\n", n, dt->mod_name); |
Jason Baron | e9d376f | 2009-02-05 11:51:38 -0500 | [diff] [blame] | 775 | return 0; |
| 776 | } |
| 777 | EXPORT_SYMBOL_GPL(ddebug_add_module); |
| 778 | |
| 779 | static void ddebug_table_free(struct ddebug_table *dt) |
| 780 | { |
| 781 | list_del_init(&dt->link); |
| 782 | kfree(dt->mod_name); |
| 783 | kfree(dt); |
| 784 | } |
| 785 | |
| 786 | /* |
| 787 | * Called in response to a module being unloaded. Removes |
| 788 | * any ddebug_table's which point at the module. |
| 789 | */ |
Yehuda Sadeh | ff49d74 | 2010-07-03 13:07:35 +1000 | [diff] [blame] | 790 | int ddebug_remove_module(const char *mod_name) |
Jason Baron | e9d376f | 2009-02-05 11:51:38 -0500 | [diff] [blame] | 791 | { |
| 792 | struct ddebug_table *dt, *nextdt; |
| 793 | int ret = -ENOENT; |
| 794 | |
| 795 | if (verbose) |
Joe Perches | 4ad275e | 2011-08-11 14:36:33 -0400 | [diff] [blame] | 796 | pr_info("removing module \"%s\"\n", mod_name); |
Jason Baron | e9d376f | 2009-02-05 11:51:38 -0500 | [diff] [blame] | 797 | |
| 798 | mutex_lock(&ddebug_lock); |
| 799 | list_for_each_entry_safe(dt, nextdt, &ddebug_tables, link) { |
| 800 | if (!strcmp(dt->mod_name, mod_name)) { |
| 801 | ddebug_table_free(dt); |
| 802 | ret = 0; |
| 803 | } |
| 804 | } |
| 805 | mutex_unlock(&ddebug_lock); |
| 806 | return ret; |
| 807 | } |
| 808 | EXPORT_SYMBOL_GPL(ddebug_remove_module); |
| 809 | |
| 810 | static void ddebug_remove_all_tables(void) |
| 811 | { |
| 812 | mutex_lock(&ddebug_lock); |
| 813 | while (!list_empty(&ddebug_tables)) { |
| 814 | struct ddebug_table *dt = list_entry(ddebug_tables.next, |
| 815 | struct ddebug_table, |
| 816 | link); |
| 817 | ddebug_table_free(dt); |
| 818 | } |
| 819 | mutex_unlock(&ddebug_lock); |
| 820 | } |
| 821 | |
Thomas Renninger | 6a5c083 | 2010-08-06 16:11:03 +0200 | [diff] [blame] | 822 | static __initdata int ddebug_init_success; |
| 823 | |
| 824 | static int __init dynamic_debug_init_debugfs(void) |
Jason Baron | e9d376f | 2009-02-05 11:51:38 -0500 | [diff] [blame] | 825 | { |
| 826 | struct dentry *dir, *file; |
Thomas Renninger | 6a5c083 | 2010-08-06 16:11:03 +0200 | [diff] [blame] | 827 | |
| 828 | if (!ddebug_init_success) |
| 829 | return -ENODEV; |
Jason Baron | e9d376f | 2009-02-05 11:51:38 -0500 | [diff] [blame] | 830 | |
| 831 | dir = debugfs_create_dir("dynamic_debug", NULL); |
| 832 | if (!dir) |
| 833 | return -ENOMEM; |
| 834 | file = debugfs_create_file("control", 0644, dir, NULL, |
| 835 | &ddebug_proc_fops); |
| 836 | if (!file) { |
| 837 | debugfs_remove(dir); |
| 838 | return -ENOMEM; |
| 839 | } |
Thomas Renninger | 6a5c083 | 2010-08-06 16:11:03 +0200 | [diff] [blame] | 840 | return 0; |
| 841 | } |
| 842 | |
| 843 | static int __init dynamic_debug_init(void) |
| 844 | { |
| 845 | struct _ddebug *iter, *iter_start; |
| 846 | const char *modname = NULL; |
| 847 | int ret = 0; |
| 848 | int n = 0; |
| 849 | |
Jason Baron | e9d376f | 2009-02-05 11:51:38 -0500 | [diff] [blame] | 850 | if (__start___verbose != __stop___verbose) { |
| 851 | iter = __start___verbose; |
| 852 | modname = iter->modname; |
| 853 | iter_start = iter; |
| 854 | for (; iter < __stop___verbose; iter++) { |
| 855 | if (strcmp(modname, iter->modname)) { |
| 856 | ret = ddebug_add_module(iter_start, n, modname); |
| 857 | if (ret) |
| 858 | goto out_free; |
| 859 | n = 0; |
| 860 | modname = iter->modname; |
| 861 | iter_start = iter; |
| 862 | } |
| 863 | n++; |
| 864 | } |
| 865 | ret = ddebug_add_module(iter_start, n, modname); |
| 866 | } |
Thomas Renninger | a648ec0 | 2010-08-06 16:11:02 +0200 | [diff] [blame] | 867 | |
| 868 | /* ddebug_query boot param got passed -> set it up */ |
| 869 | if (ddebug_setup_string[0] != '\0') { |
| 870 | ret = ddebug_exec_query(ddebug_setup_string); |
| 871 | if (ret) |
Joe Perches | 4ad275e | 2011-08-11 14:36:33 -0400 | [diff] [blame] | 872 | pr_warn("Invalid ddebug boot param %s", |
| 873 | ddebug_setup_string); |
Thomas Renninger | a648ec0 | 2010-08-06 16:11:02 +0200 | [diff] [blame] | 874 | else |
| 875 | pr_info("ddebug initialized with string %s", |
| 876 | ddebug_setup_string); |
Jason Baron | e9d376f | 2009-02-05 11:51:38 -0500 | [diff] [blame] | 877 | } |
Thomas Renninger | a648ec0 | 2010-08-06 16:11:02 +0200 | [diff] [blame] | 878 | |
Jason Baron | e9d376f | 2009-02-05 11:51:38 -0500 | [diff] [blame] | 879 | out_free: |
Thomas Renninger | 6a5c083 | 2010-08-06 16:11:03 +0200 | [diff] [blame] | 880 | if (ret) |
Jason Baron | e9d376f | 2009-02-05 11:51:38 -0500 | [diff] [blame] | 881 | ddebug_remove_all_tables(); |
Thomas Renninger | 6a5c083 | 2010-08-06 16:11:03 +0200 | [diff] [blame] | 882 | else |
| 883 | ddebug_init_success = 1; |
Jason Baron | e9d376f | 2009-02-05 11:51:38 -0500 | [diff] [blame] | 884 | return 0; |
| 885 | } |
Thomas Renninger | 6a5c083 | 2010-08-06 16:11:03 +0200 | [diff] [blame] | 886 | /* Allow early initialization for boot messages via boot param */ |
| 887 | arch_initcall(dynamic_debug_init); |
| 888 | /* Debugfs setup must be done later */ |
| 889 | module_init(dynamic_debug_init_debugfs); |