aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorAlexey Dobriyan <adobriyan@sw.ru>2007-05-08 03:28:41 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-08 14:15:08 -0400
commitffb45122766db220d0bf3d01848d575fbbcb6430 (patch)
treea8fedf0518407ad12578a7c03aa2c3344f11ff3c /kernel
parentea07890a680273b25127129fb555aac0d9324bea (diff)
Simplify kallsyms_lookup()
Several kallsyms_lookup() pass dummy arguments but only need, say, module's name. Make kallsyms_lookup() accept NULLs where possible. Also, makes picture clearer about what interfaces are needed for all symbol resolving business. Signed-off-by: Alexey Dobriyan <adobriyan@sw.ru> Cc: Rusty Russell <rusty@rustcorp.com.au> Acked-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/kallsyms.c6
-rw-r--r--kernel/kprobes.c4
-rw-r--r--kernel/lockdep.c5
-rw-r--r--kernel/module.c6
-rw-r--r--kernel/time/timer_list.c4
-rw-r--r--kernel/time/timer_stats.c4
6 files changed, 13 insertions, 16 deletions
diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
index f1ea6f66ac6c..f66da025cb7f 100644
--- a/kernel/kallsyms.c
+++ b/kernel/kallsyms.c
@@ -214,8 +214,10 @@ static unsigned long get_symbol_pos(unsigned long addr,
214 symbol_end = (unsigned long)_etext; 214 symbol_end = (unsigned long)_etext;
215 } 215 }
216 216
217 *symbolsize = symbol_end - symbol_start; 217 if (symbolsize)
218 *offset = addr - symbol_start; 218 *symbolsize = symbol_end - symbol_start;
219 if (offset)
220 *offset = addr - symbol_start;
219 221
220 return low; 222 return low;
221} 223}
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 0207045b4f6f..bee29bde6adf 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -868,13 +868,13 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
868 struct kprobe *p, *kp; 868 struct kprobe *p, *kp;
869 const char *sym = NULL; 869 const char *sym = NULL;
870 unsigned int i = *(loff_t *) v; 870 unsigned int i = *(loff_t *) v;
871 unsigned long size, offset = 0; 871 unsigned long offset = 0;
872 char *modname, namebuf[128]; 872 char *modname, namebuf[128];
873 873
874 head = &kprobe_table[i]; 874 head = &kprobe_table[i];
875 preempt_disable(); 875 preempt_disable();
876 hlist_for_each_entry_rcu(p, node, head, hlist) { 876 hlist_for_each_entry_rcu(p, node, head, hlist) {
877 sym = kallsyms_lookup((unsigned long)p->addr, &size, 877 sym = kallsyms_lookup((unsigned long)p->addr, NULL,
878 &offset, &modname, namebuf); 878 &offset, &modname, namebuf);
879 if (p->pre_handler == aggr_pre_handler) { 879 if (p->pre_handler == aggr_pre_handler) {
880 list_for_each_entry_rcu(kp, &p->list, list) 880 list_for_each_entry_rcu(kp, &p->list, list)
diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index c1e308a080b8..7f573136a905 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -340,10 +340,7 @@ static const char *usage_str[] =
340 340
341const char * __get_key_name(struct lockdep_subclass_key *key, char *str) 341const char * __get_key_name(struct lockdep_subclass_key *key, char *str)
342{ 342{
343 unsigned long offs, size; 343 return kallsyms_lookup((unsigned long)key, NULL, NULL, NULL, str);
344 char *modname;
345
346 return kallsyms_lookup((unsigned long)key, &size, &offs, &modname, str);
347} 344}
348 345
349void 346void
diff --git a/kernel/module.c b/kernel/module.c
index 5ee65994a3bc..bf4dccadf7b8 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2098,8 +2098,10 @@ static const char *get_ksymbol(struct module *mod,
2098 if (!best) 2098 if (!best)
2099 return NULL; 2099 return NULL;
2100 2100
2101 *size = nextval - mod->symtab[best].st_value; 2101 if (size)
2102 *offset = addr - mod->symtab[best].st_value; 2102 *size = nextval - mod->symtab[best].st_value;
2103 if (offset)
2104 *offset = addr - mod->symtab[best].st_value;
2103 return mod->strtab + mod->symtab[best].st_name; 2105 return mod->strtab + mod->symtab[best].st_name;
2104} 2106}
2105 2107
diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
index 59df5e8555a8..fe9314a89f20 100644
--- a/kernel/time/timer_list.c
+++ b/kernel/time/timer_list.c
@@ -40,11 +40,9 @@ static void print_name_offset(struct seq_file *m, void *sym)
40{ 40{
41 unsigned long addr = (unsigned long)sym; 41 unsigned long addr = (unsigned long)sym;
42 char namebuf[KSYM_NAME_LEN+1]; 42 char namebuf[KSYM_NAME_LEN+1];
43 unsigned long size, offset;
44 const char *sym_name; 43 const char *sym_name;
45 char *modname;
46 44
47 sym_name = kallsyms_lookup(addr, &size, &offset, &modname, namebuf); 45 sym_name = kallsyms_lookup(addr, NULL, NULL, NULL, namebuf);
48 if (sym_name) 46 if (sym_name)
49 SEQ_printf(m, "%s", sym_name); 47 SEQ_printf(m, "%s", sym_name);
50 else 48 else
diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
index 1bc4882e28e0..946ed45f7d2f 100644
--- a/kernel/time/timer_stats.c
+++ b/kernel/time/timer_stats.c
@@ -258,11 +258,9 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
258static void print_name_offset(struct seq_file *m, unsigned long addr) 258static void print_name_offset(struct seq_file *m, unsigned long addr)
259{ 259{
260 char namebuf[KSYM_NAME_LEN+1]; 260 char namebuf[KSYM_NAME_LEN+1];
261 unsigned long size, offset;
262 const char *sym_name; 261 const char *sym_name;
263 char *modname;
264 262
265 sym_name = kallsyms_lookup(addr, &size, &offset, &modname, namebuf); 263 sym_name = kallsyms_lookup(addr, NULL, NULL, NULL, namebuf);
266 if (sym_name) 264 if (sym_name)
267 seq_printf(m, "%s", sym_name); 265 seq_printf(m, "%s", sym_name);
268 else 266 else