]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/arm/oprofile/common.c
[ARM] 4352/1: AT91: Platform data for LCD and AC97.
[linux-2.6-omap-h63xx.git] / arch / arm / oprofile / common.c
index 6f8bc1f0e6a11a9eae95968f7356ed5a2b895a78..a9de727c9327aa29eb266e45860a681e72f1d55c 100644 (file)
 #include <linux/init.h>
 #include <linux/oprofile.h>
 #include <linux/errno.h>
+#include <linux/slab.h>
 #include <linux/sysdev.h>
-#include <asm/semaphore.h>
+#include <linux/mutex.h>
 
 #include "op_counter.h"
 #include "op_arm_model.h"
 
 static struct op_arm_model_spec *op_arm_model;
 static int op_arm_enabled;
-static struct semaphore op_arm_sem;
+static DEFINE_MUTEX(op_arm_mutex);
 
-struct op_counter_config counter_config[OP_MAX_COUNTER];
+struct op_counter_config *counter_config;
 
 static int op_arm_create_files(struct super_block *sb, struct dentry *root)
 {
@@ -28,7 +29,7 @@ static int op_arm_create_files(struct super_block *sb, struct dentry *root)
 
        for (i = 0; i < op_arm_model->num_counters; i++) {
                struct dentry *dir;
-               char buf[2];
+               char buf[4];
 
                snprintf(buf, sizeof buf, "%d", i);
                dir = oprofilefs_mkdir(sb, root, buf);
@@ -57,40 +58,40 @@ static int op_arm_start(void)
 {
        int ret = -EBUSY;
 
-       down(&op_arm_sem);
+       mutex_lock(&op_arm_mutex);
        if (!op_arm_enabled) {
                ret = op_arm_model->start();
                op_arm_enabled = !ret;
        }
-       up(&op_arm_sem);
+       mutex_unlock(&op_arm_mutex);
        return ret;
 }
 
 static void op_arm_stop(void)
 {
-       down(&op_arm_sem);
+       mutex_lock(&op_arm_mutex);
        if (op_arm_enabled)
                op_arm_model->stop();
        op_arm_enabled = 0;
-       up(&op_arm_sem);
+       mutex_unlock(&op_arm_mutex);
 }
 
 #ifdef CONFIG_PM
 static int op_arm_suspend(struct sys_device *dev, pm_message_t state)
 {
-       down(&op_arm_sem);
+       mutex_lock(&op_arm_mutex);
        if (op_arm_enabled)
                op_arm_model->stop();
-       up(&op_arm_sem);
+       mutex_unlock(&op_arm_mutex);
        return 0;
 }
 
 static int op_arm_resume(struct sys_device *dev)
 {
-       down(&op_arm_sem);
+       mutex_lock(&op_arm_mutex);
        if (op_arm_enabled && op_arm_model->start())
                op_arm_enabled = 0;
-       up(&op_arm_sem);
+       mutex_unlock(&op_arm_mutex);
        return 0;
 }
 
@@ -130,17 +131,30 @@ int __init oprofile_arch_init(struct oprofile_operations *ops)
        struct op_arm_model_spec *spec = NULL;
        int ret = -ENODEV;
 
+       ops->backtrace = arm_backtrace;
+
 #ifdef CONFIG_CPU_XSCALE
        spec = &op_xscale_spec;
 #endif
 
-       if (spec) {
-               init_MUTEX(&op_arm_sem);
+#ifdef CONFIG_OPROFILE_ARMV6
+       spec = &op_armv6_spec;
+#endif
+
+#ifdef CONFIG_OPROFILE_MPCORE
+       spec = &op_mpcore_spec;
+#endif
 
+       if (spec) {
                ret = spec->init();
                if (ret < 0)
                        return ret;
 
+               counter_config = kcalloc(spec->num_counters, sizeof(struct op_counter_config),
+                                        GFP_KERNEL);
+               if (!counter_config)
+                       return -ENOMEM;
+
                op_arm_model = spec;
                init_driverfs();
                ops->create_files = op_arm_create_files;
@@ -149,7 +163,6 @@ int __init oprofile_arch_init(struct oprofile_operations *ops)
                ops->start = op_arm_start;
                ops->stop = op_arm_stop;
                ops->cpu_type = op_arm_model->name;
-               ops->backtrace = arm_backtrace;
                printk(KERN_INFO "oprofile: using %s\n", spec->name);
        }
 
@@ -162,5 +175,5 @@ void oprofile_arch_exit(void)
                exit_driverfs();
                op_arm_model = NULL;
        }
+       kfree(counter_config);
 }
-