aboutsummaryrefslogtreecommitdiff
path: root/drivers/cpufreq/arm-bl-cpufreq.c
diff options
context:
space:
mode:
authorMathieu Briand <mathieu.briand@linaro.org>2012-05-11 11:29:18 +0200
committerAndrey Konovalov <andrey.konovalov@linaro.org>2013-05-25 13:04:35 +0400
commit0a6da5300c989d978190637506a3a064d3a52492 (patch)
treeac60c00fc5a80cce9ae8579d73714d1478de5fac /drivers/cpufreq/arm-bl-cpufreq.c
parentfd54d96fcaed9c77f1d4fe7d3ba14f8ac4dcee3f (diff)
cpufreq/arm-bl-cpufreq: unit tests
Add in-modules tests on arm-bl-cpufreq cpufreq driver. To build the tests, add the following config option: ARM_BL_CPUFREQ_TEST=y The tests will run when the driver is loaded, but they are not run by default. To run the tests, you need to pass the option test_config=1 to the arm-bl-cpufreq driver when loading it. Signed-off-by: Mathieu Briand <mathieu.briand@linaro.org> Signed-off-by: Dave Martin <dave.martin@linaro.org> Signed-off-by: Nicolas Pitre <nicolas.pitre@linaro.org>
Diffstat (limited to 'drivers/cpufreq/arm-bl-cpufreq.c')
-rw-r--r--drivers/cpufreq/arm-bl-cpufreq.c45
1 files changed, 27 insertions, 18 deletions
diff --git a/drivers/cpufreq/arm-bl-cpufreq.c b/drivers/cpufreq/arm-bl-cpufreq.c
index 0d7d0fcd4e3..bc633f2d7b0 100644
--- a/drivers/cpufreq/arm-bl-cpufreq.c
+++ b/drivers/cpufreq/arm-bl-cpufreq.c
@@ -18,7 +18,8 @@
*/
#define MODULE_NAME "arm-bl-cpufreq"
-#define pr_fmt(fmt) MODULE_NAME ": " fmt
+#define __module_pr_fmt(prefix, fmt) MODULE_NAME ": " prefix fmt
+#define pr_fmt(fmt) __module_pr_fmt("", fmt)
#include <linux/bug.h>
#include <linux/cache.h>
@@ -32,6 +33,17 @@
#include <asm/bL_switcher.h>
+#include "arm-bl-cpufreq.h"
+
+/*
+ * Include tests prototypes and includes
+ * We need to include this file a second time with ARM_BL_CPUFREQ_DEFINE_TESTS
+ * defined to include functions body.
+ */
+#include "arm-bl-cpufreq_tests.c"
+
+#define ARM_BL_CPUFREQ_DEFINE_TESTS
+#include "arm-bl-cpufreq_tests.c"
/* Dummy frequencies representing the big and little clusters: */
#define FREQ_BIG 1000000
@@ -41,22 +53,6 @@
#define CLUSTER_BIG 0
#define CLUSTER_LITTLE 1
-/*
- * Switch latency advertised to cpufreq. This value is bogus and will
- * need to be properly calibrated when running on real hardware.
- */
-#define BL_CPUFREQ_FAKE_LATENCY 1
-
-static struct cpufreq_frequency_table __read_mostly bl_freqs[] = {
- { CLUSTER_BIG, FREQ_BIG },
- { CLUSTER_LITTLE, FREQ_LITTLE },
- { 0, CPUFREQ_TABLE_END },
-};
-
-/* Cached current cluster for each CPU to save on IPIs */
-static DEFINE_PER_CPU(unsigned int, cpu_cur_cluster);
-
-
/* Miscellaneous helpers */
static unsigned int entry_to_freq(
@@ -237,13 +233,26 @@ static int __init bl_cpufreq_module_init(void)
{
int err;
+ /* test_config :
+ * - 0: Do not run tests
+ * - 1: Run tests and then register cpufreq driver if tests passed
+ */
+ if ((test_config > 0) && (pre_init_tests() != 0))
+ return -EINVAL;
+
err = cpufreq_register_driver(&bl_cpufreq_driver);
if(err)
pr_info("cpufreq backend driver registration failed (%d)\n",
err);
- else
+ else {
pr_info("cpufreq backend driver registered.\n");
+ if ((test_config > 0) && (post_init_tests() != 0)) {
+ cpufreq_unregister_driver(&bl_cpufreq_driver);
+ return -EINVAL;
+ }
+ }
+
return err;
}
module_init(bl_cpufreq_module_init);