]> git.hungrycats.org Git - linux/commitdiff
[PATCH] bk - fix oprofile for pm driver register
authorJohn Levon <levon@movementarian.org>
Fri, 4 Apr 2003 12:12:09 +0000 (04:12 -0800)
committerLinus Torvalds <torvalds@home.transmeta.com>
Fri, 4 Apr 2003 12:12:09 +0000 (04:12 -0800)
OK, so I screwed up - didn't notice the late_initcall() that was
introduced, which was obviously bogus. This one should build OK for the
module case. I've tested insmod/rmmod alongside a mounted sysfs.

I think the built-in case is OK: oprofile/ is after kernel/ in the link
order. I tested that too.

arch/alpha/oprofile/common.c
arch/i386/Makefile
arch/i386/oprofile/init.c
arch/i386/oprofile/nmi_int.c
arch/parisc/oprofile/init.c
arch/ppc64/oprofile/init.c
arch/sparc64/oprofile/init.c
drivers/oprofile/oprof.c
include/linux/oprofile.h

index 3faf5f796083737acd95626844d37eaed630a918..4f40b8292e9978cafbcee72857281c0d75d984cf 100644 (file)
@@ -186,3 +186,9 @@ oprofile_arch_init(struct oprofile_operations **ops)
 
        return 0;
 }
+
+
+void __exit
+oprofile_arch_exit(void)
+{
+}
index 7eea7c1def29eb851246953c691b3d6096978da4..4a748322d50c6f2a5054845b088e8e1c28cb1b3f 100644 (file)
@@ -84,7 +84,7 @@ core-y                                        += arch/i386/kernel/ \
                                           arch/i386/$(mcore-y)/
 drivers-$(CONFIG_MATH_EMULATION)       += arch/i386/math-emu/
 drivers-$(CONFIG_PCI)                  += arch/i386/pci/
-# FIXME: is drivers- right ?
+# must be linked after kernel/
 drivers-$(CONFIG_OPROFILE)             += arch/i386/oprofile/
 
 CFLAGS += $(mflags-y)
index c1d72e74750698f86220df3eb18dd4c64ea57c07..911c600eb345da5f87fe31138555133efe09ce2c 100644 (file)
@@ -17,6 +17,7 @@
  */
  
 extern int nmi_init(struct oprofile_operations ** ops);
+extern void nmi_exit(void);
 extern void timer_init(struct oprofile_operations ** ops);
 
 int __init oprofile_arch_init(struct oprofile_operations ** ops)
@@ -27,3 +28,11 @@ int __init oprofile_arch_init(struct oprofile_operations ** ops)
                timer_init(ops);
        return 0;
 }
+
+
+void __exit oprofile_arch_exit(void)
+{
+#ifdef CONFIG_X86_LOCAL_APIC
+       nmi_exit();
+#endif
+}
index c158cc89591628042972f3e7da43b98be41a240d..54168cc66918ae3320740d2346d7dc09f3f23c39 100644 (file)
@@ -67,15 +67,22 @@ static struct device device_nmi = {
 };
 
 
-static int __init init_nmi_driverfs(void)
+static int __init init_driverfs(void)
 {
        driver_register(&nmi_driver);
        return device_register(&device_nmi);
 }
 
 
-late_initcall(init_nmi_driverfs);
+static void __exit exit_driverfs(void)
+{
+       device_unregister(&device_nmi);
+       driver_unregister(&nmi_driver);
+}
 
+#else
+#define init_driverfs() do { } while (0)
+#define exit_driverfs() do { } while (0)
 #endif /* CONFIG_PM */
 
 
@@ -297,6 +304,10 @@ static int __init ppro_init(void)
 
 #endif /* !CONFIG_X86_64 */
  
+
+/* in order to get driverfs right */
+static int using_nmi;
+
 int __init nmi_init(struct oprofile_operations ** ops)
 {
        __u8 vendor = current_cpu_data.x86_vendor;
@@ -339,7 +350,16 @@ int __init nmi_init(struct oprofile_operations ** ops)
                        return 0;
        }
 
+       init_driverfs();
+       using_nmi = 1;
        *ops = &nmi_ops;
        printk(KERN_INFO "oprofile: using NMI interrupt.\n");
        return 1;
 }
+
+
+void __exit nmi_exit(void)
+{
+       if (using_nmi)
+               exit_driverfs();
+}
index c7268ba1a8d2b288a3953fae8560795f63fc2e5a..78adf8e9e5aadeb2a271437ec8c574e84990e586 100644 (file)
@@ -18,3 +18,8 @@ int __init oprofile_arch_init(struct oprofile_operations ** ops)
        timer_init(ops);
        return 0;
 }
+
+
+void __exit oprofile_arch_exit()
+{
+}
index c7268ba1a8d2b288a3953fae8560795f63fc2e5a..cb73527a8900a5218abc44cf73528d44eb42ab18 100644 (file)
@@ -18,3 +18,8 @@ int __init oprofile_arch_init(struct oprofile_operations ** ops)
        timer_init(ops);
        return 0;
 }
+
+
+void __exit oprofile_arch_exit(void)
+{
+}
index c7268ba1a8d2b288a3953fae8560795f63fc2e5a..cb73527a8900a5218abc44cf73528d44eb42ab18 100644 (file)
@@ -18,3 +18,8 @@ int __init oprofile_arch_init(struct oprofile_operations ** ops)
        timer_init(ops);
        return 0;
 }
+
+
+void __exit oprofile_arch_exit(void)
+{
+}
index 04f9131c8dd51dc86cb9e77508c1f6574c5e3cac..1515d4a39e852e67841bf44e834b8c24d1b9780b 100644 (file)
@@ -148,6 +148,7 @@ out:
 static void __exit oprofile_exit(void)
 {
        oprofilefs_unregister();
+       oprofile_arch_exit();
 }
 
  
index 5d906c21103fcadb323c62d0b9df61258bef3f15..6dba9058bca0b52c3c1783b968d420ac151da8b4 100644 (file)
@@ -45,6 +45,11 @@ struct oprofile_operations {
  */
 int oprofile_arch_init(struct oprofile_operations ** ops);
  
+/**
+ * One-time exit/cleanup for the arch.
+ */
+void oprofile_arch_exit(void);
+
 /**
  * Add a sample. This may be called from any context. Pass
  * smp_processor_id() as cpu.