diff options
| author | zy <[email protected]> | 2023-11-08 16:20:01 +0800 |
|---|---|---|
| committer | zy <[email protected]> | 2023-11-08 16:20:01 +0800 |
| commit | e2e4c6856728bbc3d42e64109a397115fc8f2aed (patch) | |
| tree | af4bce51d397c26bcd908ea763e62105fa4368d8 | |
| parent | 72b096d0ca7106847597c26bbccdf537a2fbd91b (diff) | |
fix kernel panic: hr_timer.function should call first
| -rw-r--r-- | watch_module_lib.c | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/watch_module_lib.c b/watch_module_lib.c index 896b1d0..a6f8307 100644 --- a/watch_module_lib.c +++ b/watch_module_lib.c @@ -51,10 +51,6 @@ void *access_user_space_ptr(pid_t pid, unsigned long addr) return kaddr + offset; } -// for timer -#define US2NS (1000) // Interval in microseconds -static struct hrtimer hr_timer; -static ktime_t kt; /// @brief hrTimer handler enum hrtimer_restart hrtimer_hander(struct hrtimer *timer) @@ -85,9 +81,9 @@ int start_hrTimer(unsigned long timeout) kt = ktime_set(0, (unsigned long)timeout * US2NS); // us -> ns // CLOCK_MONOTONIC: time since boot | HRTIMER_MODE_REL : relative time hrtimer_init(&hr_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); + hr_timer.function = hrtimer_hander; // mode the same as hrtimer_init hrtimer_start(&hr_timer, kt, HRTIMER_MODE_REL); - hr_timer.function = hrtimer_hander; return 0; } |
