]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/arm/oprofile/common.c
Merge branch 'hwmon-for-linus' of git://jdelvare.pck.nerim.net/jdelvare-2.6
[linux-2.6-omap-h63xx.git] / arch / arm / oprofile / common.c
index 1415930ceee1a0908d32d540fb8867a1975cdedc..0a007b931f6368f8dcb8eb3dc4b47d4c5ae17b6d 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;
 }
 
@@ -134,11 +135,23 @@ int __init oprofile_arch_init(struct oprofile_operations *ops)
        spec = &op_xscale_spec;
 #endif
 
+#ifdef CONFIG_OPROFILE_ARMV6
+       spec = &op_armv6_spec;
+#endif
+
+#ifdef CONFIG_OPROFILE_MPCORE
+       spec = &op_mpcore_spec;
+#endif
+
        if (spec) {
-               init_MUTEX(&op_arm_sem);
+               ret = spec->init();
+               if (ret < 0)
+                       return ret;
 
-               if (spec->init() < 0)
-                       return -ENODEV;
+               counter_config = kcalloc(spec->num_counters, sizeof(struct op_counter_config),
+                                        GFP_KERNEL);
+               if (!counter_config)
+                       return -ENOMEM;
 
                op_arm_model = spec;
                init_driverfs();
@@ -161,5 +174,5 @@ void oprofile_arch_exit(void)
                exit_driverfs();
                op_arm_model = NULL;
        }
+       kfree(counter_config);
 }
-