[IMPROVE] sampler: remove writer dependency 82/25982/2
authorVyacheslav Cherkashin <v.cherkashin@samsung.com>
Wed, 13 Aug 2014 13:48:02 +0000 (17:48 +0400)
committerVyacheslav Cherkashin <v.cherkashin@samsung.com>
Wed, 13 Aug 2014 13:54:50 +0000 (17:54 +0400)
Change-Id: I768e7b3a44c968c64277f2e4b5f7372de565c6e9
Signed-off-by: Vyacheslav Cherkashin <v.cherkashin@samsung.com>
parser/features.c
sampler/swap_sampler_module.c
sampler/swap_sampler_module.h

index 4b264e6..fae53ea 100644 (file)
@@ -36,6 +36,8 @@
 #include "features.h"
 #include "msg_parser.h"
 
+#include <writer/event_filter.h>
+#include <writer/swap_writer_module.h>
 #include <sampler/swap_sampler_module.h>
 #include <energy/energy.h>
 
@@ -281,6 +283,13 @@ int unset_context_switch(void)
        return ret;
 }
 
+
+static void sampler_cb(struct pt_regs *regs)
+{
+       if (check_event(current))
+               sample_msg(regs);
+}
+
 /**
  * @brief Set sampling feature on.
  *
@@ -291,7 +300,7 @@ int set_func_sampling(struct conf_data *conf)
 {
        int ret;
 
-       ret = swap_sampler_start(conf->data_msg_period);
+       ret = swap_sampler_start(conf->data_msg_period, sampler_cb);
 
        return ret;
 }
index 9867ccf..8bd7e3c 100644 (file)
@@ -35,9 +35,6 @@
 #include <linux/cpu.h>
 #include <linux/module.h>
 
-#include <writer/swap_writer_module.h>
-#include <writer/event_filter.h>
-
 #include "swap_sampler_module.h"
 #include "swap_sampler_errors.h"
 #include "kernel_operations.h"
 
 
 static BLOCKING_NOTIFIER_HEAD(swap_sampler_notifier_list);
+static swap_sample_cb_t sampler_cb;
 
 static restart_ret swap_timer_restart(swap_timer *timer)
 {
-       if (check_event(current))
-               sample_msg(task_pt_regs(current));
+       sampler_cb(task_pt_regs(current));
 
        return sampler_timers_restart(timer);
 }
@@ -127,7 +124,7 @@ static int sampler_run = 0;
  * @param timer_quantum Timer quantum for sampling.
  * @return 0 on success, error code on error.
  */
-int swap_sampler_start(unsigned int timer_quantum)
+int swap_sampler_start(unsigned int timer_quantum, swap_sample_cb_t cb)
 {
        int ret = -EINVAL;
 
@@ -137,6 +134,8 @@ int swap_sampler_start(unsigned int timer_quantum)
                goto unlock;
        }
 
+       sampler_cb = cb;
+
        ret = do_swap_sampler_start(timer_quantum);
        if (ret == 0)
                sampler_run = 1;
index e3663df..7c0ef7d 100644 (file)
 #ifndef __SWAP_SAMPLER_MODULE_H__
 #define __SWAP_SAMPLER_MODULE_H__
 
+
+typedef void (*swap_sample_cb_t)(struct pt_regs *);
+
+
 /* Starts the SWAP Sampler */
-int swap_sampler_start(unsigned int timer_quantum);
+int swap_sampler_start(unsigned int timer_quantum, swap_sample_cb_t cb);
 
 /* Stops the SWAP Sampler */
 int swap_sampler_stop(void);