[REFACTOR] move init/exit() swap_energy module
authorVyacheslav Cherkashin <v.cherkashin@samsung.com>
Thu, 19 Sep 2013 14:23:24 +0000 (18:23 +0400)
committerVyacheslav Cherkashin <v.cherkashin@samsung.com>
Thu, 19 Sep 2013 14:52:51 +0000 (18:52 +0400)
in file energy_module.c

Change-Id: I1e119fe40d1a17316c7cf40cdbf22d0af02e58ee
Signed-off-by: Vyacheslav Cherkashin <v.cherkashin@samsung.com>
energy/Kbuild
energy/energy.c
energy/energy.h
energy/energy_module.c [new file with mode: 0644]

index af1c477..469f5f8 100644 (file)
@@ -1,7 +1,8 @@
 EXTRA_CFLAGS := $(extra_cflags)
 
 obj-m := swap_energy.o
-swap_energy-y := energy.o \
+swap_energy-y := energy_module.o \
+                 energy.o \
                  debugfs_energy.o \
                  lcd/lcd_base.o
 swap_energy-$(CONFIG_LCD_S6E8AA0) += lcd/s6e8aa0.o
index 5317cf7..29d1d8d 100644 (file)
@@ -34,7 +34,6 @@
 #include <ksyms/ksyms.h>
 #include <us_manager/sspt/sspt_proc.h>
 #include <us_manager/sspt/sspt_feature.h>
-#include "debugfs_energy.h"
 
 
 struct energy_data {
@@ -351,15 +350,11 @@ void unset_energy(void)
 }
 EXPORT_SYMBOL_GPL(unset_energy);
 
-static int __init swap_energy_init(void)
+int energy_init(void)
 {
        int ret;
        unsigned long addr;
 
-       ret = init_debugfs_energy();
-       if (ret)
-               return ret;
-
        addr = swap_ksyms("__switch_to");
        if (addr == 0) {
                printk("Cannot find address for __switch_to function!\n");
@@ -386,13 +381,7 @@ static int __init swap_energy_init(void)
        return ret;
 }
 
-static void __exit swap_energy_exit(void)
+void energy_uninit(void)
 {
        uninit_feature();
-       exit_debugfs_energy();
 }
-
-module_init(swap_energy_init);
-module_exit(swap_energy_exit);
-
-MODULE_LICENSE("GPL");
index 180ac93..6a3224d 100644 (file)
  *
  */
 
+
+int energy_init(void);
+void energy_uninit(void);
+
 int set_energy(void);
 void unset_energy(void);
 
diff --git a/energy/energy_module.c b/energy/energy_module.c
new file mode 100644 (file)
index 0000000..874682c
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ *  Dynamic Binary Instrumentation Module based on KProbes
+ *  energy/energy_mod.c
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Copyright (C) Samsung Electronics, 2013
+ *
+ * 2013         Vyacheslav Cherkashin <v.cherkashin@samsung.com>
+ *
+ */
+
+
+#include <linux/module.h>
+#include "energy.h"
+#include "debugfs_energy.h"
+
+
+static int __init swap_energy_init(void)
+{
+       int ret;
+
+       ret = energy_init();
+       if (ret)
+               return ret;
+
+       ret = init_debugfs_energy();
+       if (ret)
+               energy_uninit();
+
+       return ret;
+}
+
+static void __exit swap_energy_exit(void)
+{
+       exit_debugfs_energy();
+       energy_uninit();
+}
+
+module_init(swap_energy_init);
+module_exit(swap_energy_exit);
+
+MODULE_LICENSE("GPL");