aboutsummaryrefslogtreecommitdiffstats
path: root/module/splat/splat-internal.h
diff options
context:
space:
mode:
authorChunwei Chen <[email protected]>2016-12-14 18:24:47 -0800
committerBrian Behlendorf <[email protected]>2016-12-15 11:30:11 -0800
commit9c9ad845ef372a4c47a01c20e939fd2c40bc7ac6 (patch)
tree81975a6019ca294556aecdeb180ad6b00a1fe50b /module/splat/splat-internal.h
parent71a3c9c45d7829994d3d66f014410f7c223f88f7 (diff)
Refactor some splat macro to function
Refactor the code by making splat_test_{init,fini}, splat_subsystem_{init,fini} into functions. They don't have reason to be macro and it would be too bloated to inline every call. Signed-off-by: Chunwei Chen <[email protected]>
Diffstat (limited to 'module/splat/splat-internal.h')
-rw-r--r--module/splat/splat-internal.h78
1 files changed, 4 insertions, 74 deletions
diff --git a/module/splat/splat-internal.h b/module/splat/splat-internal.h
index 36cf04da1..9ae6c1d0c 100644
--- a/module/splat/splat-internal.h
+++ b/module/splat/splat-internal.h
@@ -30,80 +30,6 @@
#include <linux/file_compat.h>
#include <linux/version.h>
-#define SPLAT_SUBSYSTEM_INIT(type) \
-({ splat_subsystem_t *_sub_; \
- \
- _sub_ = (splat_subsystem_t *)splat_##type##_init(); \
- if (_sub_ == NULL) { \
- printk(KERN_ERR "splat: Error initializing: " #type "\n"); \
- } else { \
- spin_lock(&splat_module_lock); \
- list_add_tail(&(_sub_->subsystem_list), \
- &splat_module_list); \
- spin_unlock(&splat_module_lock); \
- } \
-})
-
-#define SPLAT_SUBSYSTEM_FINI(type) \
-({ splat_subsystem_t *_sub_, *_tmp_; \
- int _id_, _flag_ = 0; \
- \
- _id_ = splat_##type##_id(); \
- spin_lock(&splat_module_lock); \
- list_for_each_entry_safe(_sub_, _tmp_, &splat_module_list, \
- subsystem_list) { \
- if (_sub_->desc.id == _id_) { \
- list_del_init(&(_sub_->subsystem_list)); \
- spin_unlock(&splat_module_lock); \
- splat_##type##_fini(_sub_); \
- spin_lock(&splat_module_lock); \
- _flag_ = 1; \
- } \
- } \
- spin_unlock(&splat_module_lock); \
- \
- if (!_flag_) \
- printk(KERN_ERR "splat: Error finalizing: " #type "\n"); \
-})
-
-#define SPLAT_TEST_INIT(sub, n, d, tid, func) \
-({ splat_test_t *_test_; \
- \
- _test_ = (splat_test_t *)kmalloc(sizeof(*_test_), GFP_KERNEL); \
- if (_test_ == NULL) { \
- printk(KERN_ERR "splat: Error initializing: " n "/" #tid" \n");\
- } else { \
- memset(_test_, 0, sizeof(*_test_)); \
- strncpy(_test_->desc.name, n, SPLAT_NAME_SIZE-1); \
- strncpy(_test_->desc.desc, d, SPLAT_DESC_SIZE-1); \
- _test_->desc.id = tid; \
- _test_->test = func; \
- INIT_LIST_HEAD(&(_test_->test_list)); \
- spin_lock(&((sub)->test_lock)); \
- list_add_tail(&(_test_->test_list),&((sub)->test_list));\
- spin_unlock(&((sub)->test_lock)); \
- } \
-})
-
-#define SPLAT_TEST_FINI(sub, tid) \
-({ splat_test_t *_test_, *_tmp_; \
- int _flag_ = 0; \
- \
- spin_lock(&((sub)->test_lock)); \
- list_for_each_entry_safe(_test_, _tmp_, \
- &((sub)->test_list), test_list) { \
- if (_test_->desc.id == tid) { \
- list_del_init(&(_test_->test_list)); \
- kfree(_test_); \
- _flag_ = 1; \
- } \
- } \
- spin_unlock(&((sub)->test_lock)); \
- \
- if (!_flag_) \
- printk(KERN_ERR "splat: Error finalizing: " #tid "\n"); \
-})
-
typedef int (*splat_test_func_t)(struct file *, void *);
typedef struct splat_test {
@@ -119,6 +45,10 @@ typedef struct splat_subsystem {
struct list_head test_list;
} splat_subsystem_t;
+void splat_test_init(splat_subsystem_t *sub, const char *name,
+ const char *desc, unsigned int tid, splat_test_func_t func);
+void splat_test_fini(splat_subsystem_t *sub, unsigned int tid);
+
#define SPLAT_INFO_BUFFER_SIZE 65536
#define SPLAT_INFO_BUFFER_REDZONE 256