Bläddra i källkod

Clean up 'print_fn_descriptor_symbol()' types

Everybody wants to pass it a function pointer, and in fact, that is what
you _must_ pass it for it to make sense (since it knows that ia64 and
ppc64 use descriptors for function pointers and fetches the actual
address from there).

So don't make the argument be a 'unsigned long' and force everybody to
add a cast.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Linus Torvalds 17 år sedan
förälder
incheckning
a442ac512f
5 ändrade filer med 20 tillägg och 21 borttagningar
  1. 1 1
      drivers/base/power/main.c
  2. 1 2
      drivers/pci/quirks.c
  3. 1 2
      drivers/pnp/quirks.c
  4. 14 10
      include/linux/kallsyms.h
  5. 3 6
      init/main.c

+ 1 - 1
drivers/base/power/main.c

@@ -418,7 +418,7 @@ void __suspend_report_result(const char *function, void *fn, int ret)
 {
 {
 	if (ret) {
 	if (ret) {
 		printk(KERN_ERR "%s(): ", function);
 		printk(KERN_ERR "%s(): ", function);
-		print_fn_descriptor_symbol("%s() returns ", (unsigned long)fn);
+		print_fn_descriptor_symbol("%s returns ", fn);
 		printk("%d\n", ret);
 		printk("%d\n", ret);
 	}
 	}
 }
 }

+ 1 - 2
drivers/pci/quirks.c

@@ -1503,8 +1503,7 @@ static void pci_do_fixups(struct pci_dev *dev, struct pci_fixup *f, struct pci_f
  		    (f->device == dev->device || f->device == (u16) PCI_ANY_ID)) {
  		    (f->device == dev->device || f->device == (u16) PCI_ANY_ID)) {
 #ifdef DEBUG
 #ifdef DEBUG
 			dev_dbg(&dev->dev, "calling ");
 			dev_dbg(&dev->dev, "calling ");
-			print_fn_descriptor_symbol("%s()\n",
-				(unsigned long) f->hook);
+			print_fn_descriptor_symbol("%s\n", f->hook);
 #endif
 #endif
 			f->hook(dev);
 			f->hook(dev);
 		}
 		}

+ 1 - 2
drivers/pnp/quirks.c

@@ -331,8 +331,7 @@ void pnp_fixup_device(struct pnp_dev *dev)
 			continue;
 			continue;
 #ifdef DEBUG
 #ifdef DEBUG
 		dev_dbg(&dev->dev, "%s: calling ", f->id);
 		dev_dbg(&dev->dev, "%s: calling ", f->id);
-		print_fn_descriptor_symbol("%s\n",
-				(unsigned long) f->quirk_function);
+		print_fn_descriptor_symbol("%s\n", f->quirk_function);
 #endif
 #endif
 		f->quirk_function(dev);
 		f->quirk_function(dev);
 	}
 	}

+ 14 - 10
include/linux/kallsyms.h

@@ -83,16 +83,6 @@ __attribute__((format(printf,1,2)));
 static inline void __check_printsym_format(const char *fmt, ...)
 static inline void __check_printsym_format(const char *fmt, ...)
 {
 {
 }
 }
-/* ia64 and ppc64 use function descriptors, which contain the real address */
-#if defined(CONFIG_IA64) || defined(CONFIG_PPC64)
-#define print_fn_descriptor_symbol(fmt, addr)		\
-do {						\
-	unsigned long *__faddr = (unsigned long*) addr;		\
-	print_symbol(fmt, __faddr[0]);		\
-} while (0)
-#else
-#define print_fn_descriptor_symbol(fmt, addr) print_symbol(fmt, addr)
-#endif
 
 
 static inline void print_symbol(const char *fmt, unsigned long addr)
 static inline void print_symbol(const char *fmt, unsigned long addr)
 {
 {
@@ -101,6 +91,20 @@ static inline void print_symbol(const char *fmt, unsigned long addr)
 		       __builtin_extract_return_addr((void *)addr));
 		       __builtin_extract_return_addr((void *)addr));
 }
 }
 
 
+/*
+ * Pretty-print a function pointer.
+ *
+ * ia64 and ppc64 function pointers are really function descriptors,
+ * which contain a pointer the real address.
+ */
+static inline void print_fn_descriptor_symbol(const char *fmt, void *addr)
+{
+#if defined(CONFIG_IA64) || defined(CONFIG_PPC64)
+	addr = *(void **)addr;
+#endif
+	print_symbol(fmt, (unsigned long)addr);
+}
+
 #ifndef CONFIG_64BIT
 #ifndef CONFIG_64BIT
 #define print_ip_sym(ip)		\
 #define print_ip_sym(ip)		\
 do {					\
 do {					\

+ 3 - 6
init/main.c

@@ -706,8 +706,7 @@ static void __init do_initcalls(void)
 		int result;
 		int result;
 
 
 		if (initcall_debug) {
 		if (initcall_debug) {
-			print_fn_descriptor_symbol("calling  %s()\n",
-					(unsigned long) *call);
+			print_fn_descriptor_symbol("calling  %s\n", *call);
 			t0 = ktime_get();
 			t0 = ktime_get();
 		}
 		}
 
 
@@ -717,8 +716,7 @@ static void __init do_initcalls(void)
 			t1 = ktime_get();
 			t1 = ktime_get();
 			delta = ktime_sub(t1, t0);
 			delta = ktime_sub(t1, t0);
 
 
-			print_fn_descriptor_symbol("initcall %s()",
-					(unsigned long) *call);
+			print_fn_descriptor_symbol("initcall %s", *call);
 			printk(" returned %d after %Ld msecs\n", result,
 			printk(" returned %d after %Ld msecs\n", result,
 				(unsigned long long) delta.tv64 >> 20);
 				(unsigned long long) delta.tv64 >> 20);
 		}
 		}
@@ -737,8 +735,7 @@ static void __init do_initcalls(void)
 			local_irq_enable();
 			local_irq_enable();
 		}
 		}
 		if (msgbuf[0]) {
 		if (msgbuf[0]) {
-			print_fn_descriptor_symbol(KERN_WARNING "initcall %s()",
-					(unsigned long) *call);
+			print_fn_descriptor_symbol(KERN_WARNING "initcall %s", *call);
 			printk(" returned with %s\n", msgbuf);
 			printk(" returned with %s\n", msgbuf);
 		}
 		}
 	}
 	}