aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-03-20 14:16:20 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-03-20 14:16:20 -0400
commit4a52246302f01596f0edf7b4a3e6425e23479192 (patch)
treef384d86722d3ccfc875e3e5e8d8726e993a922ee /lib
parent9f9d2760da8c7f94fae119fac3e13d5a1702f8f0 (diff)
parentadc80ae60eae24a43a357bf5b30fb496f34aa605 (diff)
Merge tag 'driver-core-3.3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core
Pull driver core patches for 3.4-rc1 from Greg KH: "Here's the big driver core merge for 3.4-rc1. Lots of various things here, sysfs fixes/tweaks (with the nlink breakage reverted), dynamic debugging updates, w1 drivers, hyperv driver updates, and a variety of other bits and pieces, full information in the shortlog." * tag 'driver-core-3.3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (78 commits) Tools: hv: Support enumeration from all the pools Tools: hv: Fully support the new KVP verbs in the user level daemon Drivers: hv: Support the newly introduced KVP messages in the driver Drivers: hv: Add new message types to enhance KVP regulator: Support driver probe deferral Revert "sysfs: Kill nlink counting." uevent: send events in correct order according to seqnum (v3) driver core: minor comment formatting cleanups driver core: move the deferred probe pointer into the private area drivercore: Add driver probe deferral mechanism DS2781 Maxim Stand-Alone Fuel Gauge battery and w1 slave drivers w1_bq27000: Only one thread can access the bq27000 at a time. w1_bq27000 - remove w1_bq27000_write w1_bq27000: remove unnecessary NULL test. sysfs: Fix memory leak in sysfs_sd_setsecdata(). intel_idle: Revert change of auto_demotion_disable_flags for Nehalem w1: Fix w1_bq27000 driver-core: documentation: fix up Greg's email address powernow-k6: Really enable auto-loading powernow-k7: Fix CPU family number ...
Diffstat (limited to 'lib')
-rw-r--r--lib/dma-debug.c3
-rw-r--r--lib/dynamic_debug.c270
-rw-r--r--lib/kobject_uevent.c19
3 files changed, 197 insertions, 95 deletions
diff --git a/lib/dma-debug.c b/lib/dma-debug.c
index fea790a2b17..13ef2338be4 100644
--- a/lib/dma-debug.c
+++ b/lib/dma-debug.c
@@ -170,7 +170,7 @@ static bool driver_filter(struct device *dev)
170 return false; 170 return false;
171 171
172 /* driver filter on but not yet initialized */ 172 /* driver filter on but not yet initialized */
173 drv = get_driver(dev->driver); 173 drv = dev->driver;
174 if (!drv) 174 if (!drv)
175 return false; 175 return false;
176 176
@@ -185,7 +185,6 @@ static bool driver_filter(struct device *dev)
185 } 185 }
186 186
187 read_unlock_irqrestore(&driver_name_lock, flags); 187 read_unlock_irqrestore(&driver_name_lock, flags);
188 put_driver(drv);
189 188
190 return ret; 189 return ret;
191} 190}
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index dcdade39e47..310c753cf83 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -60,6 +60,7 @@ struct ddebug_iter {
60static DEFINE_MUTEX(ddebug_lock); 60static DEFINE_MUTEX(ddebug_lock);
61static LIST_HEAD(ddebug_tables); 61static LIST_HEAD(ddebug_tables);
62static int verbose = 0; 62static int verbose = 0;
63module_param(verbose, int, 0644);
63 64
64/* Return the last part of a pathname */ 65/* Return the last part of a pathname */
65static inline const char *basename(const char *path) 66static inline const char *basename(const char *path)
@@ -68,12 +69,24 @@ static inline const char *basename(const char *path)
68 return tail ? tail+1 : path; 69 return tail ? tail+1 : path;
69} 70}
70 71
72/* Return the path relative to source root */
73static inline const char *trim_prefix(const char *path)
74{
75 int skip = strlen(__FILE__) - strlen("lib/dynamic_debug.c");
76
77 if (strncmp(path, __FILE__, skip))
78 skip = 0; /* prefix mismatch, don't skip */
79
80 return path + skip;
81}
82
71static struct { unsigned flag:8; char opt_char; } opt_array[] = { 83static struct { unsigned flag:8; char opt_char; } opt_array[] = {
72 { _DPRINTK_FLAGS_PRINT, 'p' }, 84 { _DPRINTK_FLAGS_PRINT, 'p' },
73 { _DPRINTK_FLAGS_INCL_MODNAME, 'm' }, 85 { _DPRINTK_FLAGS_INCL_MODNAME, 'm' },
74 { _DPRINTK_FLAGS_INCL_FUNCNAME, 'f' }, 86 { _DPRINTK_FLAGS_INCL_FUNCNAME, 'f' },
75 { _DPRINTK_FLAGS_INCL_LINENO, 'l' }, 87 { _DPRINTK_FLAGS_INCL_LINENO, 'l' },
76 { _DPRINTK_FLAGS_INCL_TID, 't' }, 88 { _DPRINTK_FLAGS_INCL_TID, 't' },
89 { _DPRINTK_FLAGS_NONE, '_' },
77}; 90};
78 91
79/* format a string into buf[] which describes the _ddebug's flags */ 92/* format a string into buf[] which describes the _ddebug's flags */
@@ -83,58 +96,74 @@ static char *ddebug_describe_flags(struct _ddebug *dp, char *buf,
83 char *p = buf; 96 char *p = buf;
84 int i; 97 int i;
85 98
86 BUG_ON(maxlen < 4); 99 BUG_ON(maxlen < 6);
87 for (i = 0; i < ARRAY_SIZE(opt_array); ++i) 100 for (i = 0; i < ARRAY_SIZE(opt_array); ++i)
88 if (dp->flags & opt_array[i].flag) 101 if (dp->flags & opt_array[i].flag)
89 *p++ = opt_array[i].opt_char; 102 *p++ = opt_array[i].opt_char;
90 if (p == buf) 103 if (p == buf)
91 *p++ = '-'; 104 *p++ = '_';
92 *p = '\0'; 105 *p = '\0';
93 106
94 return buf; 107 return buf;
95} 108}
96 109
110#define vpr_info_dq(q, msg) \
111do { \
112 if (verbose) \
113 /* trim last char off format print */ \
114 pr_info("%s: func=\"%s\" file=\"%s\" " \
115 "module=\"%s\" format=\"%.*s\" " \
116 "lineno=%u-%u", \
117 msg, \
118 q->function ? q->function : "", \
119 q->filename ? q->filename : "", \
120 q->module ? q->module : "", \
121 (int)(q->format ? strlen(q->format) - 1 : 0), \
122 q->format ? q->format : "", \
123 q->first_lineno, q->last_lineno); \
124} while (0)
125
97/* 126/*
98 * Search the tables for _ddebug's which match the given 127 * Search the tables for _ddebug's which match the given `query' and
99 * `query' and apply the `flags' and `mask' to them. Tells 128 * apply the `flags' and `mask' to them. Returns number of matching
100 * the user which ddebug's were changed, or whether none 129 * callsites, normally the same as number of changes. If verbose,
101 * were matched. 130 * logs the changes. Takes ddebug_lock.
102 */ 131 */
103static void ddebug_change(const struct ddebug_query *query, 132static int ddebug_change(const struct ddebug_query *query,
104 unsigned int flags, unsigned int mask) 133 unsigned int flags, unsigned int mask)
105{ 134{
106 int i; 135 int i;
107 struct ddebug_table *dt; 136 struct ddebug_table *dt;
108 unsigned int newflags; 137 unsigned int newflags;
109 unsigned int nfound = 0; 138 unsigned int nfound = 0;
110 char flagbuf[8]; 139 char flagbuf[10];
111 140
112 /* search for matching ddebugs */ 141 /* search for matching ddebugs */
113 mutex_lock(&ddebug_lock); 142 mutex_lock(&ddebug_lock);
114 list_for_each_entry(dt, &ddebug_tables, link) { 143 list_for_each_entry(dt, &ddebug_tables, link) {
115 144
116 /* match against the module name */ 145 /* match against the module name */
117 if (query->module != NULL && 146 if (query->module && strcmp(query->module, dt->mod_name))
118 strcmp(query->module, dt->mod_name))
119 continue; 147 continue;
120 148
121 for (i = 0 ; i < dt->num_ddebugs ; i++) { 149 for (i = 0 ; i < dt->num_ddebugs ; i++) {
122 struct _ddebug *dp = &dt->ddebugs[i]; 150 struct _ddebug *dp = &dt->ddebugs[i];
123 151
124 /* match against the source filename */ 152 /* match against the source filename */
125 if (query->filename != NULL && 153 if (query->filename &&
126 strcmp(query->filename, dp->filename) && 154 strcmp(query->filename, dp->filename) &&
127 strcmp(query->filename, basename(dp->filename))) 155 strcmp(query->filename, basename(dp->filename)) &&
156 strcmp(query->filename, trim_prefix(dp->filename)))
128 continue; 157 continue;
129 158
130 /* match against the function */ 159 /* match against the function */
131 if (query->function != NULL && 160 if (query->function &&
132 strcmp(query->function, dp->function)) 161 strcmp(query->function, dp->function))
133 continue; 162 continue;
134 163
135 /* match against the format */ 164 /* match against the format */
136 if (query->format != NULL && 165 if (query->format &&
137 strstr(dp->format, query->format) == NULL) 166 !strstr(dp->format, query->format))
138 continue; 167 continue;
139 168
140 /* match against the line number range */ 169 /* match against the line number range */
@@ -151,13 +180,9 @@ static void ddebug_change(const struct ddebug_query *query,
151 if (newflags == dp->flags) 180 if (newflags == dp->flags)
152 continue; 181 continue;
153 dp->flags = newflags; 182 dp->flags = newflags;
154 if (newflags)
155 dp->enabled = 1;
156 else
157 dp->enabled = 0;
158 if (verbose) 183 if (verbose)
159 pr_info("changed %s:%d [%s]%s %s\n", 184 pr_info("changed %s:%d [%s]%s =%s\n",
160 dp->filename, dp->lineno, 185 trim_prefix(dp->filename), dp->lineno,
161 dt->mod_name, dp->function, 186 dt->mod_name, dp->function,
162 ddebug_describe_flags(dp, flagbuf, 187 ddebug_describe_flags(dp, flagbuf,
163 sizeof(flagbuf))); 188 sizeof(flagbuf)));
@@ -167,6 +192,8 @@ static void ddebug_change(const struct ddebug_query *query,
167 192
168 if (!nfound && verbose) 193 if (!nfound && verbose)
169 pr_info("no matches for query\n"); 194 pr_info("no matches for query\n");
195
196 return nfound;
170} 197}
171 198
172/* 199/*
@@ -186,8 +213,10 @@ static int ddebug_tokenize(char *buf, char *words[], int maxwords)
186 buf = skip_spaces(buf); 213 buf = skip_spaces(buf);
187 if (!*buf) 214 if (!*buf)
188 break; /* oh, it was trailing whitespace */ 215 break; /* oh, it was trailing whitespace */
216 if (*buf == '#')
217 break; /* token starts comment, skip rest of line */
189 218
190 /* Run `end' over a word, either whitespace separated or quoted */ 219 /* find `end' of word, whitespace separated or quoted */
191 if (*buf == '"' || *buf == '\'') { 220 if (*buf == '"' || *buf == '\'') {
192 int quote = *buf++; 221 int quote = *buf++;
193 for (end = buf ; *end && *end != quote ; end++) 222 for (end = buf ; *end && *end != quote ; end++)
@@ -199,8 +228,8 @@ static int ddebug_tokenize(char *buf, char *words[], int maxwords)
199 ; 228 ;
200 BUG_ON(end == buf); 229 BUG_ON(end == buf);
201 } 230 }
202 /* Here `buf' is the start of the word, `end' is one past the end */
203 231
232 /* `buf' is start of word, `end' is one past its end */
204 if (nwords == maxwords) 233 if (nwords == maxwords)
205 return -EINVAL; /* ran out of words[] before bytes */ 234 return -EINVAL; /* ran out of words[] before bytes */
206 if (*end) 235 if (*end)
@@ -279,6 +308,19 @@ static char *unescape(char *str)
279 return str; 308 return str;
280} 309}
281 310
311static int check_set(const char **dest, char *src, char *name)
312{
313 int rc = 0;
314
315 if (*dest) {
316 rc = -EINVAL;
317 pr_err("match-spec:%s val:%s overridden by %s",
318 name, *dest, src);
319 }
320 *dest = src;
321 return rc;
322}
323
282/* 324/*
283 * Parse words[] as a ddebug query specification, which is a series 325 * Parse words[] as a ddebug query specification, which is a series
284 * of (keyword, value) pairs chosen from these possibilities: 326 * of (keyword, value) pairs chosen from these possibilities:
@@ -290,11 +332,15 @@ static char *unescape(char *str)
290 * format <escaped-string-to-find-in-format> 332 * format <escaped-string-to-find-in-format>
291 * line <lineno> 333 * line <lineno>
292 * line <first-lineno>-<last-lineno> // where either may be empty 334 * line <first-lineno>-<last-lineno> // where either may be empty
335 *
336 * Only 1 of each type is allowed.
337 * Returns 0 on success, <0 on error.
293 */ 338 */
294static int ddebug_parse_query(char *words[], int nwords, 339static int ddebug_parse_query(char *words[], int nwords,
295 struct ddebug_query *query) 340 struct ddebug_query *query)
296{ 341{
297 unsigned int i; 342 unsigned int i;
343 int rc;
298 344
299 /* check we have an even number of words */ 345 /* check we have an even number of words */
300 if (nwords % 2 != 0) 346 if (nwords % 2 != 0)
@@ -303,41 +349,43 @@ static int ddebug_parse_query(char *words[], int nwords,
303 349
304 for (i = 0 ; i < nwords ; i += 2) { 350 for (i = 0 ; i < nwords ; i += 2) {
305 if (!strcmp(words[i], "func")) 351 if (!strcmp(words[i], "func"))
306 query->function = words[i+1]; 352 rc = check_set(&query->function, words[i+1], "func");
307 else if (!strcmp(words[i], "file")) 353 else if (!strcmp(words[i], "file"))
308 query->filename = words[i+1]; 354 rc = check_set(&query->filename, words[i+1], "file");
309 else if (!strcmp(words[i], "module")) 355 else if (!strcmp(words[i], "module"))
310 query->module = words[i+1]; 356 rc = check_set(&query->module, words[i+1], "module");
311 else if (!strcmp(words[i], "format")) 357 else if (!strcmp(words[i], "format"))
312 query->format = unescape(words[i+1]); 358 rc = check_set(&query->format, unescape(words[i+1]),
359 "format");
313 else if (!strcmp(words[i], "line")) { 360 else if (!strcmp(words[i], "line")) {
314 char *first = words[i+1]; 361 char *first = words[i+1];
315 char *last = strchr(first, '-'); 362 char *last = strchr(first, '-');
363 if (query->first_lineno || query->last_lineno) {
364 pr_err("match-spec:line given 2 times\n");
365 return -EINVAL;
366 }
316 if (last) 367 if (last)
317 *last++ = '\0'; 368 *last++ = '\0';
318 if (parse_lineno(first, &query->first_lineno) < 0) 369 if (parse_lineno(first, &query->first_lineno) < 0)
319 return -EINVAL; 370 return -EINVAL;
320 if (last != NULL) { 371 if (last) {
321 /* range <first>-<last> */ 372 /* range <first>-<last> */
322 if (parse_lineno(last, &query->last_lineno) < 0) 373 if (parse_lineno(last, &query->last_lineno)
374 < query->first_lineno) {
375 pr_err("last-line < 1st-line\n");
323 return -EINVAL; 376 return -EINVAL;
377 }
324 } else { 378 } else {
325 query->last_lineno = query->first_lineno; 379 query->last_lineno = query->first_lineno;
326 } 380 }
327 } else { 381 } else {
328 if (verbose) 382 pr_err("unknown keyword \"%s\"\n", words[i]);
329 pr_err("unknown keyword \"%s\"\n", words[i]);
330 return -EINVAL; 383 return -EINVAL;
331 } 384 }
385 if (rc)
386 return rc;
332 } 387 }
333 388 vpr_info_dq(query, "parsed");
334 if (verbose)
335 pr_info("q->function=\"%s\" q->filename=\"%s\" "
336 "q->module=\"%s\" q->format=\"%s\" q->lineno=%u-%u\n",
337 query->function, query->filename,
338 query->module, query->format, query->first_lineno,
339 query->last_lineno);
340
341 return 0; 389 return 0;
342} 390}
343 391
@@ -375,8 +423,6 @@ static int ddebug_parse_flags(const char *str, unsigned int *flagsp,
375 if (i < 0) 423 if (i < 0)
376 return -EINVAL; 424 return -EINVAL;
377 } 425 }
378 if (flags == 0)
379 return -EINVAL;
380 if (verbose) 426 if (verbose)
381 pr_info("flags=0x%x\n", flags); 427 pr_info("flags=0x%x\n", flags);
382 428
@@ -405,7 +451,7 @@ static int ddebug_exec_query(char *query_string)
405 unsigned int flags = 0, mask = 0; 451 unsigned int flags = 0, mask = 0;
406 struct ddebug_query query; 452 struct ddebug_query query;
407#define MAXWORDS 9 453#define MAXWORDS 9
408 int nwords; 454 int nwords, nfound;
409 char *words[MAXWORDS]; 455 char *words[MAXWORDS];
410 456
411 nwords = ddebug_tokenize(query_string, words, MAXWORDS); 457 nwords = ddebug_tokenize(query_string, words, MAXWORDS);
@@ -417,8 +463,47 @@ static int ddebug_exec_query(char *query_string)
417 return -EINVAL; 463 return -EINVAL;
418 464
419 /* actually go and implement the change */ 465 /* actually go and implement the change */
420 ddebug_change(&query, flags, mask); 466 nfound = ddebug_change(&query, flags, mask);
421 return 0; 467 vpr_info_dq((&query), (nfound) ? "applied" : "no-match");
468
469 return nfound;
470}
471
472/* handle multiple queries in query string, continue on error, return
473 last error or number of matching callsites. Module name is either
474 in param (for boot arg) or perhaps in query string.
475*/
476static int ddebug_exec_queries(char *query)
477{
478 char *split;
479 int i, errs = 0, exitcode = 0, rc, nfound = 0;
480
481 for (i = 0; query; query = split) {
482 split = strpbrk(query, ";\n");
483 if (split)
484 *split++ = '\0';
485
486 query = skip_spaces(query);
487 if (!query || !*query || *query == '#')
488 continue;
489
490 if (verbose)
491 pr_info("query %d: \"%s\"\n", i, query);
492
493 rc = ddebug_exec_query(query);
494 if (rc < 0) {
495 errs++;
496 exitcode = rc;
497 } else
498 nfound += rc;
499 i++;
500 }
501 pr_info("processed %d queries, with %d matches, %d errs\n",
502 i, nfound, errs);
503
504 if (exitcode)
505 return exitcode;
506 return nfound;
422} 507}
423 508
424#define PREFIX_SIZE 64 509#define PREFIX_SIZE 64
@@ -452,7 +537,8 @@ static char *dynamic_emit_prefix(const struct _ddebug *desc, char *buf)
452 pos += snprintf(buf + pos, remaining(pos), "%s:", 537 pos += snprintf(buf + pos, remaining(pos), "%s:",
453 desc->function); 538 desc->function);
454 if (desc->flags & _DPRINTK_FLAGS_INCL_LINENO) 539 if (desc->flags & _DPRINTK_FLAGS_INCL_LINENO)
455 pos += snprintf(buf + pos, remaining(pos), "%d:", desc->lineno); 540 pos += snprintf(buf + pos, remaining(pos), "%d:",
541 desc->lineno);
456 if (pos - pos_after_tid) 542 if (pos - pos_after_tid)
457 pos += snprintf(buf + pos, remaining(pos), " "); 543 pos += snprintf(buf + pos, remaining(pos), " ");
458 if (pos >= PREFIX_SIZE) 544 if (pos >= PREFIX_SIZE)
@@ -527,14 +613,16 @@ EXPORT_SYMBOL(__dynamic_netdev_dbg);
527 613
528#endif 614#endif
529 615
530static __initdata char ddebug_setup_string[1024]; 616#define DDEBUG_STRING_SIZE 1024
617static __initdata char ddebug_setup_string[DDEBUG_STRING_SIZE];
618
531static __init int ddebug_setup_query(char *str) 619static __init int ddebug_setup_query(char *str)
532{ 620{
533 if (strlen(str) >= 1024) { 621 if (strlen(str) >= DDEBUG_STRING_SIZE) {
534 pr_warn("ddebug boot param string too large\n"); 622 pr_warn("ddebug boot param string too large\n");
535 return 0; 623 return 0;
536 } 624 }
537 strcpy(ddebug_setup_string, str); 625 strlcpy(ddebug_setup_string, str, DDEBUG_STRING_SIZE);
538 return 1; 626 return 1;
539} 627}
540 628
@@ -544,25 +632,33 @@ __setup("ddebug_query=", ddebug_setup_query);
544 * File_ops->write method for <debugfs>/dynamic_debug/conrol. Gathers the 632 * File_ops->write method for <debugfs>/dynamic_debug/conrol. Gathers the
545 * command text from userspace, parses and executes it. 633 * command text from userspace, parses and executes it.
546 */ 634 */
635#define USER_BUF_PAGE 4096
547static ssize_t ddebug_proc_write(struct file *file, const char __user *ubuf, 636static ssize_t ddebug_proc_write(struct file *file, const char __user *ubuf,
548 size_t len, loff_t *offp) 637 size_t len, loff_t *offp)
549{ 638{
550 char tmpbuf[256]; 639 char *tmpbuf;
551 int ret; 640 int ret;
552 641
553 if (len == 0) 642 if (len == 0)
554 return 0; 643 return 0;
555 /* we don't check *offp -- multiple writes() are allowed */ 644 if (len > USER_BUF_PAGE - 1) {
556 if (len > sizeof(tmpbuf)-1) 645 pr_warn("expected <%d bytes into control\n", USER_BUF_PAGE);
557 return -E2BIG; 646 return -E2BIG;
558 if (copy_from_user(tmpbuf, ubuf, len)) 647 }
648 tmpbuf = kmalloc(len + 1, GFP_KERNEL);
649 if (!tmpbuf)
650 return -ENOMEM;
651 if (copy_from_user(tmpbuf, ubuf, len)) {
652 kfree(tmpbuf);
559 return -EFAULT; 653 return -EFAULT;
654 }
560 tmpbuf[len] = '\0'; 655 tmpbuf[len] = '\0';
561 if (verbose) 656 if (verbose)
562 pr_info("read %d bytes from userspace\n", (int)len); 657 pr_info("read %d bytes from userspace\n", (int)len);
563 658
564 ret = ddebug_exec_query(tmpbuf); 659 ret = ddebug_exec_queries(tmpbuf);
565 if (ret) 660 kfree(tmpbuf);
661 if (ret < 0)
566 return ret; 662 return ret;
567 663
568 *offp += len; 664 *offp += len;
@@ -668,7 +764,7 @@ static int ddebug_proc_show(struct seq_file *m, void *p)
668{ 764{
669 struct ddebug_iter *iter = m->private; 765 struct ddebug_iter *iter = m->private;
670 struct _ddebug *dp = p; 766 struct _ddebug *dp = p;
671 char flagsbuf[8]; 767 char flagsbuf[10];
672 768
673 if (verbose) 769 if (verbose)
674 pr_info("called m=%p p=%p\n", m, p); 770 pr_info("called m=%p p=%p\n", m, p);
@@ -679,10 +775,10 @@ static int ddebug_proc_show(struct seq_file *m, void *p)
679 return 0; 775 return 0;
680 } 776 }
681 777
682 seq_printf(m, "%s:%u [%s]%s %s \"", 778 seq_printf(m, "%s:%u [%s]%s =%s \"",
683 dp->filename, dp->lineno, 779 trim_prefix(dp->filename), dp->lineno,
684 iter->table->mod_name, dp->function, 780 iter->table->mod_name, dp->function,
685 ddebug_describe_flags(dp, flagsbuf, sizeof(flagsbuf))); 781 ddebug_describe_flags(dp, flagsbuf, sizeof(flagsbuf)));
686 seq_escape(m, dp->format, "\t\r\n\""); 782 seq_escape(m, dp->format, "\t\r\n\"");
687 seq_puts(m, "\"\n"); 783 seq_puts(m, "\"\n");
688 784
@@ -708,10 +804,11 @@ static const struct seq_operations ddebug_proc_seqops = {
708}; 804};
709 805
710/* 806/*
711 * File_ops->open method for <debugfs>/dynamic_debug/control. Does the seq_file 807 * File_ops->open method for <debugfs>/dynamic_debug/control. Does
712 * setup dance, and also creates an iterator to walk the _ddebugs. 808 * the seq_file setup dance, and also creates an iterator to walk the
713 * Note that we create a seq_file always, even for O_WRONLY files 809 * _ddebugs. Note that we create a seq_file always, even for O_WRONLY
714 * where it's not needed, as doing so simplifies the ->release method. 810 * files where it's not needed, as doing so simplifies the ->release
811 * method.
715 */ 812 */
716static int ddebug_proc_open(struct inode *inode, struct file *file) 813static int ddebug_proc_open(struct inode *inode, struct file *file)
717{ 814{
@@ -846,33 +943,40 @@ static int __init dynamic_debug_init(void)
846 int ret = 0; 943 int ret = 0;
847 int n = 0; 944 int n = 0;
848 945
849 if (__start___verbose != __stop___verbose) { 946 if (__start___verbose == __stop___verbose) {
850 iter = __start___verbose; 947 pr_warn("_ddebug table is empty in a "
851 modname = iter->modname; 948 "CONFIG_DYNAMIC_DEBUG build");
852 iter_start = iter; 949 return 1;
853 for (; iter < __stop___verbose; iter++) { 950 }
854 if (strcmp(modname, iter->modname)) { 951 iter = __start___verbose;
855 ret = ddebug_add_module(iter_start, n, modname); 952 modname = iter->modname;
856 if (ret) 953 iter_start = iter;
857 goto out_free; 954 for (; iter < __stop___verbose; iter++) {
858 n = 0; 955 if (strcmp(modname, iter->modname)) {
859 modname = iter->modname; 956 ret = ddebug_add_module(iter_start, n, modname);
860 iter_start = iter; 957 if (ret)
861 } 958 goto out_free;
862 n++; 959 n = 0;
960 modname = iter->modname;
961 iter_start = iter;
863 } 962 }
864 ret = ddebug_add_module(iter_start, n, modname); 963 n++;
865 } 964 }
965 ret = ddebug_add_module(iter_start, n, modname);
966 if (ret)
967 goto out_free;
866 968
867 /* ddebug_query boot param got passed -> set it up */ 969 /* ddebug_query boot param got passed -> set it up */
868 if (ddebug_setup_string[0] != '\0') { 970 if (ddebug_setup_string[0] != '\0') {
869 ret = ddebug_exec_query(ddebug_setup_string); 971 ret = ddebug_exec_queries(ddebug_setup_string);
870 if (ret) 972 if (ret < 0)
871 pr_warn("Invalid ddebug boot param %s", 973 pr_warn("Invalid ddebug boot param %s",
872 ddebug_setup_string); 974 ddebug_setup_string);
873 else 975 else
874 pr_info("ddebug initialized with string %s", 976 pr_info("%d changes by ddebug_query\n", ret);
875 ddebug_setup_string); 977
978 /* keep tables even on ddebug_query parse error */
979 ret = 0;
876 } 980 }
877 981
878out_free: 982out_free:
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
index e66e9b63261..75cbdb52bf5 100644
--- a/lib/kobject_uevent.c
+++ b/lib/kobject_uevent.c
@@ -29,16 +29,17 @@
29 29
30u64 uevent_seqnum; 30u64 uevent_seqnum;
31char uevent_helper[UEVENT_HELPER_PATH_LEN] = CONFIG_UEVENT_HELPER_PATH; 31char uevent_helper[UEVENT_HELPER_PATH_LEN] = CONFIG_UEVENT_HELPER_PATH;
32static DEFINE_SPINLOCK(sequence_lock);
33#ifdef CONFIG_NET 32#ifdef CONFIG_NET
34struct uevent_sock { 33struct uevent_sock {
35 struct list_head list; 34 struct list_head list;
36 struct sock *sk; 35 struct sock *sk;
37}; 36};
38static LIST_HEAD(uevent_sock_list); 37static LIST_HEAD(uevent_sock_list);
39static DEFINE_MUTEX(uevent_sock_mutex);
40#endif 38#endif
41 39
40/* This lock protects uevent_seqnum and uevent_sock_list */
41static DEFINE_MUTEX(uevent_sock_mutex);
42
42/* the strings here must match the enum in include/linux/kobject.h */ 43/* the strings here must match the enum in include/linux/kobject.h */
43static const char *kobject_actions[] = { 44static const char *kobject_actions[] = {
44 [KOBJ_ADD] = "add", 45 [KOBJ_ADD] = "add",
@@ -136,7 +137,6 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
136 struct kobject *top_kobj; 137 struct kobject *top_kobj;
137 struct kset *kset; 138 struct kset *kset;
138 const struct kset_uevent_ops *uevent_ops; 139 const struct kset_uevent_ops *uevent_ops;
139 u64 seq;
140 int i = 0; 140 int i = 0;
141 int retval = 0; 141 int retval = 0;
142#ifdef CONFIG_NET 142#ifdef CONFIG_NET
@@ -243,17 +243,16 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
243 else if (action == KOBJ_REMOVE) 243 else if (action == KOBJ_REMOVE)
244 kobj->state_remove_uevent_sent = 1; 244 kobj->state_remove_uevent_sent = 1;
245 245
246 mutex_lock(&uevent_sock_mutex);
246 /* we will send an event, so request a new sequence number */ 247 /* we will send an event, so request a new sequence number */
247 spin_lock(&sequence_lock); 248 retval = add_uevent_var(env, "SEQNUM=%llu", (unsigned long long)++uevent_seqnum);
248 seq = ++uevent_seqnum; 249 if (retval) {
249 spin_unlock(&sequence_lock); 250 mutex_unlock(&uevent_sock_mutex);
250 retval = add_uevent_var(env, "SEQNUM=%llu", (unsigned long long)seq);
251 if (retval)
252 goto exit; 251 goto exit;
252 }
253 253
254#if defined(CONFIG_NET) 254#if defined(CONFIG_NET)
255 /* send netlink message */ 255 /* send netlink message */
256 mutex_lock(&uevent_sock_mutex);
257 list_for_each_entry(ue_sk, &uevent_sock_list, list) { 256 list_for_each_entry(ue_sk, &uevent_sock_list, list) {
258 struct sock *uevent_sock = ue_sk->sk; 257 struct sock *uevent_sock = ue_sk->sk;
259 struct sk_buff *skb; 258 struct sk_buff *skb;
@@ -290,8 +289,8 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
290 } else 289 } else
291 retval = -ENOMEM; 290 retval = -ENOMEM;
292 } 291 }
293 mutex_unlock(&uevent_sock_mutex);
294#endif 292#endif
293 mutex_unlock(&uevent_sock_mutex);
295 294
296 /* call uevent_helper, usually only enabled during early boot */ 295 /* call uevent_helper, usually only enabled during early boot */
297 if (uevent_helper[0] && !kobj_usermode_filter(kobj)) { 296 if (uevent_helper[0] && !kobj_usermode_filter(kobj)) {