summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVyacheslav Cherkashin <v.cherkashin@samsung.com>2015-03-11 19:50:21 +0300
committerAlexander Aksenov <a.aksenov@samsung.com>2015-08-12 12:45:57 +0300
commit5f59b203b26826b65c42f1d9c5db005d548524d1 (patch)
treec45ce3c1b447344023322d21b1a7070e2f177f8d
parent182d4a192da71c195b6391a0c2d87b0124a1296f (diff)
downloadswap-modules-5f59b203b26826b65c42f1d9c5db005d548524d1.tar.gz
swap-modules-5f59b203b26826b65c42f1d9c5db005d548524d1.tar.bz2
swap-modules-5f59b203b26826b65c42f1d9c5db005d548524d1.zip
[FEATURE] master module implement
1. create swap_initializer 2. move swap_debugfs to this module from driver module Change-Id: Id81d0ba55c304ed969447d658b6876fa0068bc48 Signed-off-by: Vyacheslav Cherkashin <v.cherkashin@samsung.com>
-rw-r--r--Kbuild3
-rw-r--r--driver/Kbuild3
-rw-r--r--driver/swap_debugfs.c73
-rw-r--r--driver/swap_driver_module.c7
-rw-r--r--energy/debugfs_energy.c4
-rw-r--r--master/Kbuild6
-rw-r--r--master/master_module.c41
-rw-r--r--master/swap_debugfs.c173
-rw-r--r--master/swap_debugfs.h (renamed from driver/swap_debugfs.h)14
-rw-r--r--master/swap_initializer.c352
-rw-r--r--master/swap_initializer.h100
-rwxr-xr-xpackaging/swap-modules.spec2
-rw-r--r--us_manager/debugfs_us_manager.c4
-rw-r--r--writer/debugfs_writer.c4
14 files changed, 690 insertions, 96 deletions
diff --git a/Kbuild b/Kbuild
index e334a390..87ee1e54 100644
--- a/Kbuild
+++ b/Kbuild
@@ -1,6 +1,7 @@
EXTRA_CFLAGS := $(extra_cflags)
-obj-m := buffer/ \
+obj-m := master/ \
+ buffer/ \
ksyms/ \
driver/ \
writer/ \
diff --git a/driver/Kbuild b/driver/Kbuild
index bfee0652..b3e30301 100644
--- a/driver/Kbuild
+++ b/driver/Kbuild
@@ -4,8 +4,7 @@ KBUILD_EXTRA_SYMBOLS = $(src)/../buffer/Module.symvers
obj-m := swap_driver.o
swap_driver-y := swap_driver_module.o \
device_driver.o \
- driver_to_buffer.o \
- swap_debugfs.o
+ driver_to_buffer.o
ifeq ($(CONFIG_CONNECTOR),y)
swap_driver-y += us_interaction.o
diff --git a/driver/swap_debugfs.c b/driver/swap_debugfs.c
deleted file mode 100644
index 976ed79c..00000000
--- a/driver/swap_debugfs.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/**
- * driver/swap_debugfs.c
- * @author Vyacheslav Cherkashin <v.cherkashin@samsung.com>
- *
- * @section LICENSE
- *
- * 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.
- *
- * @section COPYRIGHT
- *
- * Copyright (C) Samsung Electronics, 2013
- *
- * @section DESCRIPTION
- *
- * Initializes root debugfs for all SWAP modules
- */
-
-
-#include <linux/module.h>
-#include <linux/debugfs.h>
-
-
-static struct dentry *swap_dir = NULL;
-
-/**
- * @brief Get debugfs dir.
- *
- * @return Pointer to dentry stuct.
- */
-struct dentry *get_swap_debugfs_dir(void)
-{
- return swap_dir;
-}
-EXPORT_SYMBOL_GPL(get_swap_debugfs_dir);
-
-/**
- * @brief Initializes SWAP debugfs.
- *
- * @return 0 on success, negative error code on error.
- */
-int swap_debugfs_init(void)
-{
- swap_dir = debugfs_create_dir("swap", NULL);
- if (swap_dir == NULL)
- return -ENOMEM;
-
- return 0;
-}
-
-/**
- * @brief Deinitializes SWAP debugfs and recursively removes all its files.
- *
- * @return Void.
- */
-void swap_debugfs_exit(void)
-{
- struct dentry *dir = swap_dir;
-
- swap_dir = NULL;
- debugfs_remove_recursive(dir);
-}
diff --git a/driver/swap_driver_module.c b/driver/swap_driver_module.c
index 08fb151a..f226a648 100644
--- a/driver/swap_driver_module.c
+++ b/driver/swap_driver_module.c
@@ -31,17 +31,12 @@
#include "driver_defs.h"
#include "device_driver.h"
-#include "swap_debugfs.h"
#include "us_interaction.h"
static int __init swap_driver_init(void)
{
int ret;
- ret = swap_debugfs_init();
- if (ret)
- return ret;
-
ret = swap_device_init();
if (ret)
goto dev_init_fail;
@@ -55,7 +50,6 @@ static int __init swap_driver_init(void)
return 0;
dev_init_fail:
- swap_debugfs_exit();
swap_device_exit();
return ret;
@@ -65,7 +59,6 @@ static void __exit swap_driver_exit(void)
{
us_interaction_destroy();
swap_device_exit();
- swap_debugfs_exit();
print_msg("Driver module uninitialized\n");
}
diff --git a/energy/debugfs_energy.c b/energy/debugfs_energy.c
index bf72a66b..e09addca 100644
--- a/energy/debugfs_energy.c
+++ b/energy/debugfs_energy.c
@@ -27,7 +27,7 @@
#include <linux/module.h>
#include <linux/debugfs.h>
#include <linux/math64.h>
-#include <driver/swap_debugfs.h>
+#include <master/swap_debugfs.h>
#include "energy.h"
#include "rational_debugfs.h"
#include "lcd/lcd_debugfs.h"
@@ -259,7 +259,7 @@ int init_debugfs_energy(void)
int i;
struct dentry *swap_dir, *dentry;
- swap_dir = get_swap_debugfs_dir();
+ swap_dir = swap_debugfs_getdir();
if (swap_dir == NULL)
return -ENOENT;
diff --git a/master/Kbuild b/master/Kbuild
new file mode 100644
index 00000000..83733a74
--- /dev/null
+++ b/master/Kbuild
@@ -0,0 +1,6 @@
+EXTRA_CFLAGS := $(extra_cflags)
+
+obj-m := swap_master.o
+swap_master-y := master_module.o \
+ swap_debugfs.o \
+ swap_initializer.o
diff --git a/master/master_module.c b/master/master_module.c
new file mode 100644
index 00000000..e3b75530
--- /dev/null
+++ b/master/master_module.c
@@ -0,0 +1,41 @@
+/*
+ * 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, 2015
+ *
+ * 2015 Vyacheslav Cherkashin <v.cherkashin@samsung.com>
+ *
+ */
+
+
+#include <linux/module.h>
+#include "swap_debugfs.h"
+#include "swap_initializer.h"
+
+
+static int __init master_init(void)
+{
+ return swap_debugfs_init();
+}
+
+static void __exit master_exit(void)
+{
+ swap_debugfs_uninit();
+}
+
+module_init(master_init);
+module_exit(master_exit);
+
+MODULE_LICENSE("GPL");
diff --git a/master/swap_debugfs.c b/master/swap_debugfs.c
new file mode 100644
index 00000000..d35f75e4
--- /dev/null
+++ b/master/swap_debugfs.c
@@ -0,0 +1,173 @@
+/*
+ * 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, 2015
+ *
+ * 2015 Vyacheslav Cherkashin <v.cherkashin@samsung.com>
+ *
+ */
+
+
+#include <linux/module.h>
+#include <linux/debugfs.h>
+#include <asm/uaccess.h>
+#include "swap_initializer.h"
+
+
+static int set_enable(int enable)
+{
+ int ret = 0, change, enable_current;
+
+ enable_current = swap_init_stat_get();
+
+ change = ((!!enable_current) << 1) | (!!enable);
+ switch (change) {
+ case 0b01: /* init */
+ ret = swap_init_init();
+ break;
+ case 0b10: /* uninit */
+ ret = swap_init_uninit();
+ break;
+ default:
+ ret = -EINVAL;
+ break;
+ }
+
+ swap_init_stat_put();
+
+ return ret;
+}
+
+static ssize_t read_enable(struct file *file, char __user *user_buf,
+ size_t count, loff_t *ppos)
+{
+ char buf[3];
+ int enable;
+
+ enable = swap_init_stat_get();
+ swap_init_stat_put();
+
+ if (enable)
+ buf[0] = '1';
+ else
+ buf[0] = '0';
+ buf[1] = '\n';
+ buf[2] = '\0';
+
+ return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
+}
+
+static int do_write_enable(const char *buf, size_t size)
+{
+ if (size < 1)
+ return -EINVAL;
+
+ switch (buf[0]) {
+ case '1':
+ return set_enable(1);
+ case '0':
+ return set_enable(0);
+ }
+
+ return -EINVAL;
+}
+
+static ssize_t write_enable(struct file *file, const char __user *user_buf,
+ size_t count, loff_t *ppos)
+{
+ int ret;
+ char buf[32];
+ size_t buf_size;
+
+ buf_size = min(count, (sizeof(buf) - 1));
+ if (copy_from_user(buf, user_buf, buf_size))
+ return -EFAULT;
+
+ ret = do_write_enable(buf, buf_size);
+
+ return ret ? ret : count;
+}
+
+static const struct file_operations fops_enable = {
+ .owner = THIS_MODULE,
+ .read = read_enable,
+ .write = write_enable,
+ .llseek = default_llseek,
+};
+
+
+static struct dentry *swap_dir = NULL;
+
+/**
+ * @brief Get debugfs dir.
+ *
+ * @return Pointer to dentry stuct.
+ */
+struct dentry *swap_debugfs_getdir(void)
+{
+ return swap_dir;
+}
+EXPORT_SYMBOL_GPL(swap_debugfs_getdir);
+
+static int debugfs_dir_init(void)
+{
+ swap_dir = debugfs_create_dir("swap", NULL);
+ if (swap_dir == NULL)
+ return -ENOMEM;
+
+ return 0;
+}
+
+static void debugfs_dir_exit(void)
+{
+ struct dentry *dir = swap_dir;
+
+ swap_dir = NULL;
+ debugfs_remove_recursive(dir);
+}
+
+/**
+ * @brief Initializes SWAP debugfs.
+ *
+ * @return 0 on success, negative error code on error.
+ */
+int swap_debugfs_init(void)
+{
+ int ret;
+ struct dentry *dentry;
+
+ ret = debugfs_dir_init();
+ if (ret)
+ return ret;
+
+ dentry = debugfs_create_file("enable", 0600, swap_dir, NULL,
+ &fops_enable);
+ if (dentry == NULL) {
+ debugfs_dir_exit();
+ return -ENOMEM;
+ }
+
+ return 0;
+}
+
+/**
+ * @brief Deinitializes SWAP debugfs and recursively removes all its files.
+ *
+ * @return Void.
+ */
+void swap_debugfs_uninit(void)
+{
+ debugfs_dir_exit();
+}
diff --git a/driver/swap_debugfs.h b/master/swap_debugfs.h
index a1912a2b..0df8c3a7 100644
--- a/driver/swap_debugfs.h
+++ b/master/swap_debugfs.h
@@ -1,5 +1,4 @@
/**
- * @file driver/swap_debugfs.h
* @author Vyacheslav Cherkashin <v.cherkashin@samsung.com>
*
* @section LICENSE
@@ -20,22 +19,23 @@
*
* @section COPYRIGHT
*
- * Copyright (C) Samsung Electronics, 2013
+ * Copyright (C) Samsung Electronics, 2015
*
* @section DESCRIPTION
*
* SWAP debugfs interface definition.
*/
+#ifndef _SWAP_DEBUGFS_H
+#define _SWAP_DEBUGFS_H
-#ifndef _SWAP_DEBUG_FS_H
-#define _SWAP_DEBUG_FS_H
struct dentry;
+struct dentry *swap_debugfs_getdir(void);
-struct dentry *get_swap_debugfs_dir(void);
int swap_debugfs_init(void);
-void swap_debugfs_exit(void);
+void swap_debugfs_uninit(void);
-#endif /* _SWAP_DEBUG_FS_H */
+
+#endif /* _SWAP_DEBUGFS_H */
diff --git a/master/swap_initializer.c b/master/swap_initializer.c
new file mode 100644
index 00000000..8b887fdb
--- /dev/null
+++ b/master/swap_initializer.c
@@ -0,0 +1,352 @@
+/*
+ * 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, 2015
+ *
+ * 2015 Vyacheslav Cherkashin <v.cherkashin@samsung.com>
+ *
+ */
+
+
+#include <linux/slab.h>
+#include <linux/list.h>
+#include <linux/mutex.h>
+#include <linux/types.h>
+#include <linux/spinlock.h>
+#include "swap_initializer.h"
+
+
+enum init_level {
+ IL_CORE,
+ IL_FS
+};
+
+static swap_init_t sis_get_fn_init(struct swap_init_struct *init,
+ enum init_level level)
+{
+ switch (level) {
+ case IL_CORE:
+ return init->core_init;
+ case IL_FS:
+ return init->fs_init;
+ default:
+ return NULL;
+ }
+}
+
+static swap_uninit_t sis_get_fn_uninit(struct swap_init_struct *init,
+ enum init_level level)
+{
+ switch (level) {
+ case IL_CORE:
+ return init->core_uninit;
+ case IL_FS:
+ return init->fs_uninit;
+ }
+
+ return NULL;
+}
+
+static void sis_set_flag(struct swap_init_struct *init,
+ enum init_level level, bool val)
+{
+ switch (level) {
+ case IL_CORE:
+ init->core_flag = val;
+ break;
+ case IL_FS:
+ init->fs_flag = val;
+ break;
+ }
+}
+
+static bool sis_get_flag(struct swap_init_struct *init, enum init_level level)
+{
+ switch (level) {
+ case IL_CORE:
+ return init->core_flag;
+ case IL_FS:
+ return init->fs_flag;
+ }
+
+ return false;
+}
+
+static int sis_once(struct swap_init_struct *init)
+{
+ swap_init_t once;
+
+ once = init->once;
+ if (!init->once_flag && once) {
+ int ret;
+
+ ret = once();
+ if (ret)
+ return ret;
+
+ init->once_flag = true;
+ }
+
+ return 0;
+}
+
+static int sis_init_level(struct swap_init_struct *init, enum init_level level)
+{
+ int ret;
+ swap_init_t fn;
+
+ if (sis_get_flag(init, level))
+ return -EPERM;
+
+ fn = sis_get_fn_init(init, level);
+ if (fn) {
+ ret = fn();
+ if (ret)
+ return ret;
+ }
+
+ sis_set_flag(init, level, true);
+ return 0;
+}
+
+static void sis_uninit_level(struct swap_init_struct *init,
+ enum init_level level)
+{
+ if (sis_get_flag(init, level)) {
+ swap_uninit_t fn = sis_get_fn_uninit(init, level);
+ if (fn)
+ fn();
+ sis_set_flag(init, level, false);
+ }
+}
+
+static int sis_init(struct swap_init_struct *init)
+{
+ int ret;
+
+ ret = sis_once(init);
+ if (ret)
+ return ret;
+
+ ret = sis_init_level(init, IL_CORE);
+ if (ret)
+ return ret;
+
+ ret = sis_init_level(init, IL_FS);
+ if (ret)
+ sis_uninit_level(init, IL_CORE);
+
+ return ret;
+}
+
+static void sis_uninit(struct swap_init_struct *init)
+{
+ sis_uninit_level(init, IL_FS);
+ sis_uninit_level(init, IL_CORE);
+}
+
+static LIST_HEAD(init_list);
+static DEFINE_MUTEX(inst_mutex);
+static unsigned init_flag = 0;
+
+static int do_once(void)
+{
+ int ret;
+ struct swap_init_struct *init;
+
+ list_for_each_entry(init, &init_list, list) {
+ ret = sis_once(init);
+ if (ret)
+ return ret;
+ }
+
+ return 0;
+}
+
+static void do_uninit_level(enum init_level level)
+{
+ struct swap_init_struct *init;
+
+ list_for_each_entry(init, &init_list, list)
+ sis_uninit_level(init, level);
+}
+
+static int do_init_level(enum init_level level)
+{
+ int ret;
+ struct swap_init_struct *init;
+
+ list_for_each_entry(init, &init_list, list) {
+ ret = sis_init_level(init, level);
+ if (ret) {
+ do_uninit_level(level);
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
+static int do_init(void)
+{
+ int ret;
+
+ ret = do_once();
+ if (ret)
+ return ret;
+
+ ret = do_init_level(IL_CORE);
+ if (ret)
+ return ret;
+
+ ret = do_init_level(IL_FS);
+ if (ret)
+ do_uninit_level(IL_CORE);
+
+ init_flag = 1;
+
+ return 0;
+}
+
+static void do_uninit(void)
+{
+ do_uninit_level(IL_FS);
+ do_uninit_level(IL_CORE);
+
+ init_flag = 0;
+}
+
+
+static atomic_t init_use = ATOMIC_INIT(0);
+
+enum init_stat_t {
+ IS_OFF,
+ IS_SWITCHING,
+ IS_ON,
+};
+
+static enum init_stat_t init_stat;
+static DEFINE_SPINLOCK(init_stat_lock);
+
+
+static bool swap_init_try_get(void)
+{
+ spin_lock(&init_stat_lock);
+ if (init_stat != IS_ON) {
+ spin_unlock(&init_stat_lock);
+ return false;
+ }
+ spin_unlock(&init_stat_lock);
+
+ atomic_inc(&init_use);
+
+ return true;
+}
+
+static void swap_init_put(void)
+{
+ atomic_dec(&init_use);
+}
+
+int swap_init_simple_open(struct inode *inode, struct file *file)
+{
+ if (swap_init_try_get() == false)
+ return -EBUSY;
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(swap_init_simple_open);
+
+int swap_init_simple_release(struct inode *inode, struct file *file)
+{
+ swap_init_put();
+ return 0;
+}
+EXPORT_SYMBOL_GPL(swap_init_simple_release);
+
+int swap_init_init(void)
+{
+ int ret;
+
+ spin_lock(&init_stat_lock);
+ init_stat = IS_SWITCHING;
+ spin_unlock(&init_stat_lock);
+
+ ret = do_init();
+
+ spin_lock(&init_stat_lock);
+ init_stat = ret ? IS_OFF : IS_ON;
+ spin_unlock(&init_stat_lock);
+
+ return ret;
+}
+
+int swap_init_uninit(void)
+{
+ spin_lock(&init_stat_lock);
+ init_stat = IS_SWITCHING;
+ if (atomic_read(&init_use)) {
+ init_stat = IS_ON;
+ spin_unlock(&init_stat_lock);
+ return -EBUSY;
+ }
+ spin_unlock(&init_stat_lock);
+
+ do_uninit();
+
+ spin_lock(&init_stat_lock);
+ init_stat = IS_OFF;
+ spin_unlock(&init_stat_lock);
+
+ return 0;
+}
+
+
+int swap_init_stat_get(void)
+{
+ mutex_lock(&inst_mutex);
+
+ return init_flag;
+}
+
+void swap_init_stat_put(void)
+{
+ mutex_unlock(&inst_mutex);
+}
+
+int swap_init_register(struct swap_init_struct *init)
+{
+ int ret = 0;
+
+ mutex_lock(&inst_mutex);
+ if (init_flag)
+ ret = sis_init(init);
+
+ if (ret == 0)
+ list_add(&init->list, &init_list);
+ mutex_unlock(&inst_mutex);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(swap_init_register);
+
+void swap_init_unregister(struct swap_init_struct *init)
+{
+ mutex_lock(&inst_mutex);
+ list_del(&init->list);
+ sis_uninit(init);
+ mutex_unlock(&inst_mutex);
+}
+EXPORT_SYMBOL_GPL(swap_init_unregister);
diff --git a/master/swap_initializer.h b/master/swap_initializer.h
new file mode 100644
index 00000000..e0e6314f
--- /dev/null
+++ b/master/swap_initializer.h
@@ -0,0 +1,100 @@
+/**
+ * @author Vyacheslav Cherkashin <v.cherkashin@samsung.com>
+ *
+ * @section LICENSE
+ *
+ * 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.
+ *
+ * @section COPYRIGHT
+ *
+ * Copyright (C) Samsung Electronics, 2015
+ *
+ * @section DESCRIPTION
+ *
+ * SWAP event notification interface.
+ */
+
+#ifndef _SWAP_INITIALIZER_H
+#define _SWAP_INITIALIZER_H
+
+
+#include <linux/list.h>
+#include <linux/types.h>
+#include <linux/module.h>
+
+
+struct file;
+struct inode;
+
+
+typedef int (*swap_init_t)(void);
+typedef void (*swap_uninit_t)(void);
+
+
+struct swap_init_struct {
+ swap_init_t once; /* to call only on the first initialization */
+
+ swap_init_t core_init;
+ swap_uninit_t core_uninit;
+
+ swap_init_t fs_init;
+ swap_uninit_t fs_uninit;
+
+ /* private fields */
+ struct list_head list;
+ unsigned once_flag:1;
+ unsigned core_flag:1;
+ unsigned fs_flag:1;
+};
+
+
+int swap_init_simple_open(struct inode *inode, struct file *file);
+int swap_init_simple_release(struct inode *inode, struct file *file);
+
+int swap_init_init(void);
+int swap_init_uninit(void);
+
+int swap_init_stat_get(void);
+void swap_init_stat_put(void);
+
+int swap_init_register(struct swap_init_struct *init);
+void swap_init_unregister(struct swap_init_struct *init);
+
+
+#define SWAP_LIGHT_INIT_MODULE(_once, _init, _uninit, _fs_init, _fs_uninit) \
+ static struct swap_init_struct __init_struct = { \
+ .once = _once, \
+ .core_init = _init, \
+ .core_uninit = _uninit, \
+ .fs_init = _fs_init, \
+ .fs_uninit = _fs_uninit, \
+ .list = LIST_HEAD_INIT(__init_struct.list), \
+ .once_flag = false, \
+ .core_flag = false, \
+ .fs_flag = false \
+ }; \
+ static int __init __init_mod(void) \
+ { \
+ return swap_init_register(&__init_struct); \
+ } \
+ static void __exit __exit_mod(void) \
+ { \
+ swap_init_unregister(&__init_struct); \
+ } \
+ module_init(__init_mod); \
+ module_exit(__exit_mod)
+
+
+#endif /* _SWAP_INITIALIZER_H */
diff --git a/packaging/swap-modules.spec b/packaging/swap-modules.spec
index ac0c3173..22f7f5ac 100755
--- a/packaging/swap-modules.spec
+++ b/packaging/swap-modules.spec
@@ -30,6 +30,7 @@ Kernel modules for SWAP
%install
mkdir -p %{buildroot}/opt/swap/sdk
+install -m 666 master/swap_master.ko -t %{buildroot}/opt/swap/sdk
install -m 666 buffer/swap_buffer.ko -t %{buildroot}/opt/swap/sdk
install -m 666 ksyms/swap_ksyms.ko -t %{buildroot}/opt/swap/sdk
install -m 666 driver/swap_driver.ko -t %{buildroot}/opt/swap/sdk
@@ -45,6 +46,7 @@ install -m 666 parser/swap_message_parser.ko -t %{buildroot}/opt/swap/sdk
%files
%defattr(-,root,root)
+/opt/swap/sdk/swap_master.ko
/opt/swap/sdk/swap_buffer.ko
/opt/swap/sdk/swap_ksyms.ko
/opt/swap/sdk/swap_driver.ko
diff --git a/us_manager/debugfs_us_manager.c b/us_manager/debugfs_us_manager.c
index c18f8374..d6106216 100644
--- a/us_manager/debugfs_us_manager.c
+++ b/us_manager/debugfs_us_manager.c
@@ -1,7 +1,7 @@
#include <linux/debugfs.h>
#include <linux/module.h>
-#include <driver/swap_debugfs.h>
+#include <master/swap_debugfs.h>
#include <us_manager/sspt/sspt_proc.h>
#include "debugfs_us_manager.h"
@@ -97,7 +97,7 @@ int init_debugfs_us_manager(void)
{
struct dentry *swap_dir, *dentry;
- swap_dir = get_swap_debugfs_dir();
+ swap_dir = swap_debugfs_getdir();
if (swap_dir == NULL)
return -ENOENT;
diff --git a/writer/debugfs_writer.c b/writer/debugfs_writer.c
index 65347b0e..fd07fecc 100644
--- a/writer/debugfs_writer.c
+++ b/writer/debugfs_writer.c
@@ -33,7 +33,7 @@
#include <linux/vmalloc.h>
#include <linux/slab.h>
#include <asm/uaccess.h>
-#include <driver/swap_debugfs.h>
+#include <master/swap_debugfs.h>
#include "swap_writer_module.h"
#include "event_filter.h"
@@ -262,7 +262,7 @@ int init_debugfs_writer(void)
if (ret)
return ret;
- swap_dir = get_swap_debugfs_dir();
+ swap_dir = swap_debugfs_getdir();
if (swap_dir == NULL)
return -ENOENT;