Simplify kallsyms_lookup()
authorAlexey Dobriyan <adobriyan@sw.ru>
Tue, 8 May 2007 07:28:41 +0000 (00:28 -0700)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Tue, 8 May 2007 18:15:08 +0000 (11:15 -0700)
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>
arch/parisc/kernel/unwind.c
arch/powerpc/xmon/xmon.c
arch/sh64/kernel/unwind.c
fs/proc/base.c
kernel/kallsyms.c
kernel/kprobes.c
kernel/lockdep.c
kernel/module.c
kernel/time/timer_list.c
kernel/time/timer_stats.c

index 5f75b3e65986d8b9f96a7830f92fd23bde79dffd..89c03707eccc82dcf7dcb9d2b332a275b7b74f4b 100644 (file)
@@ -216,11 +216,8 @@ static void unwind_frame_regs(struct unwind_frame_info *info)
                /* Handle some frequent special cases.... */
                {
                        char symname[KSYM_NAME_LEN+1];
-                       char *modname;
-                       unsigned long symsize, offset;
 
-                       kallsyms_lookup(info->ip, &symsize, &offset,
-                                       &modname, symname);
+                       kallsyms_lookup(info->ip, NULL, NULL, NULL, symname);
 
                        dbg("info->ip = 0x%lx, name = %s\n", info->ip, symname);
 
index b481db1dacb4a7b3f2c35e49a0789612bbc591a7..28fdf4f50c274e2b574aacf58945e13af45c89a3 100644 (file)
@@ -1217,7 +1217,6 @@ static void get_function_bounds(unsigned long pc, unsigned long *startp,
 {
        unsigned long size, offset;
        const char *name;
-       char *modname;
 
        *startp = *endp = 0;
        if (pc == 0)
@@ -1225,7 +1224,7 @@ static void get_function_bounds(unsigned long pc, unsigned long *startp,
        if (setjmp(bus_error_jmp) == 0) {
                catch_memory_errors = 1;
                sync();
-               name = kallsyms_lookup(pc, &size, &offset, &modname, tmpstr);
+               name = kallsyms_lookup(pc, &size, &offset, NULL, tmpstr);
                if (name != NULL) {
                        *startp = pc - offset;
                        *endp = pc - offset + size;
index f934f97f9f9c9f9cf0ac21010f77c7c0c67ae106..1214c78e35844799c4b5fd07ae2ef5c9032e5887 100644 (file)
@@ -46,15 +46,15 @@ static int lookup_prev_stack_frame(unsigned long fp, unsigned long pc,
                      struct pt_regs *regs)
 {
        const char *sym;
-       char *modname, namebuf[128];
-       unsigned long offset, size;
+       char namebuf[128];
+       unsigned long offset;
        unsigned long prologue = 0;
        unsigned long fp_displacement = 0;
        unsigned long fp_prev = 0;
        unsigned long offset_r14 = 0, offset_r18 = 0;
        int i, found_prologue_end = 0;
 
-       sym = kallsyms_lookup(pc, &size, &offset, &modname, namebuf);
+       sym = kallsyms_lookup(pc, NULL, &offset, NULL, namebuf);
        if (!sym)
                return -EINVAL;
 
index a3e77fb867eaadd17ebcc93449cb7297d32e3a54..3b4fe21c7e948e482ced7f9d5a9dd738268f7e5f 100644 (file)
@@ -278,14 +278,13 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
  */
 static int proc_pid_wchan(struct task_struct *task, char *buffer)
 {
-       char *modname;
        const char *sym_name;
-       unsigned long wchan, size, offset;
+       unsigned long wchan;
        char namebuf[KSYM_NAME_LEN+1];
 
        wchan = get_wchan(task);
 
-       sym_name = kallsyms_lookup(wchan, &size, &offset, &modname, namebuf);
+       sym_name = kallsyms_lookup(wchan, NULL, NULL, NULL, namebuf);
        if (sym_name)
                return sprintf(buffer, "%s", sym_name);
        return sprintf(buffer, "%lu", wchan);
index f1ea6f66ac6cb4c5f06cd421920a4917496e8521..f66da025cb7f40cb90ddeabc2bffde4878bdf02b 100644 (file)
@@ -214,8 +214,10 @@ static unsigned long get_symbol_pos(unsigned long addr,
                        symbol_end = (unsigned long)_etext;
        }
 
-       *symbolsize = symbol_end - symbol_start;
-       *offset = addr - symbol_start;
+       if (symbolsize)
+               *symbolsize = symbol_end - symbol_start;
+       if (offset)
+               *offset = addr - symbol_start;
 
        return low;
 }
index 0207045b4f6ff1d7a3157e3a0bce6ff55681559c..bee29bde6adf805033b795d6a57bc6212608c216 100644 (file)
@@ -868,13 +868,13 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
        struct kprobe *p, *kp;
        const char *sym = NULL;
        unsigned int i = *(loff_t *) v;
-       unsigned long size, offset = 0;
+       unsigned long offset = 0;
        char *modname, namebuf[128];
 
        head = &kprobe_table[i];
        preempt_disable();
        hlist_for_each_entry_rcu(p, node, head, hlist) {
-               sym = kallsyms_lookup((unsigned long)p->addr, &size,
+               sym = kallsyms_lookup((unsigned long)p->addr, NULL,
                                        &offset, &modname, namebuf);
                if (p->pre_handler == aggr_pre_handler) {
                        list_for_each_entry_rcu(kp, &p->list, list)
index c1e308a080b87eed578d0ef7f85cd197c8a141b6..7f573136a905d6270baaa5f0d75d000991cf9af0 100644 (file)
@@ -340,10 +340,7 @@ static const char *usage_str[] =
 
 const char * __get_key_name(struct lockdep_subclass_key *key, char *str)
 {
-       unsigned long offs, size;
-       char *modname;
-
-       return kallsyms_lookup((unsigned long)key, &size, &offs, &modname, str);
+       return kallsyms_lookup((unsigned long)key, NULL, NULL, NULL, str);
 }
 
 void
index 5ee65994a3bc86542510f1b81c1cd8e997546371..bf4dccadf7b80885922116e758aa122f3424aa80 100644 (file)
@@ -2098,8 +2098,10 @@ static const char *get_ksymbol(struct module *mod,
        if (!best)
                return NULL;
 
-       *size = nextval - mod->symtab[best].st_value;
-       *offset = addr - mod->symtab[best].st_value;
+       if (size)
+               *size = nextval - mod->symtab[best].st_value;
+       if (offset)
+               *offset = addr - mod->symtab[best].st_value;
        return mod->strtab + mod->symtab[best].st_name;
 }
 
index 59df5e8555a8a40d25321bb9569612e8a29f68b2..fe9314a89f20c78b8df863d3011d87a1a453f9bd 100644 (file)
@@ -40,11 +40,9 @@ static void print_name_offset(struct seq_file *m, void *sym)
 {
        unsigned long addr = (unsigned long)sym;
        char namebuf[KSYM_NAME_LEN+1];
-       unsigned long size, offset;
        const char *sym_name;
-       char *modname;
 
-       sym_name = kallsyms_lookup(addr, &size, &offset, &modname, namebuf);
+       sym_name = kallsyms_lookup(addr, NULL, NULL, NULL, namebuf);
        if (sym_name)
                SEQ_printf(m, "%s", sym_name);
        else
index 1bc4882e28e03ac4150a467efe3afa6410ea3a61..946ed45f7d2fd49cda8abe74fd6ec48c68c959dd 100644 (file)
@@ -258,11 +258,9 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
 static void print_name_offset(struct seq_file *m, unsigned long addr)
 {
        char namebuf[KSYM_NAME_LEN+1];
-       unsigned long size, offset;
        const char *sym_name;
-       char *modname;
 
-       sym_name = kallsyms_lookup(addr, &size, &offset, &modname, namebuf);
+       sym_name = kallsyms_lookup(addr, NULL, NULL, NULL, namebuf);
        if (sym_name)
                seq_printf(m, "%s", sym_name);
        else