-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpic18_worker.c
44 lines (32 loc) · 879 Bytes
/
pic18_worker.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
* Copyright (c) 2012-2013, Stuart Wheater, Newcastle upon Tyne, England. All rights reserved.
*/
#include <linux/kernel.h>
#include <linux/kthread.h>
#include <linux/delay.h>
#include "pic18_io.h"
#include "pic18_worker.h"
static struct task_struct *worker_thread = NULL;
int pic18_worker_init(void)
{
printk(KERN_INFO "pic18_worker: pic18_worker_init\n");
worker_thread = kthread_run(pic18_worker_main, NULL, "pic18 worker");
return 0;
}
int pic18_worker_main(void *data)
{
printk(KERN_INFO "pic18_worker: main started\n");
while (! kthread_should_stop())
{
pic18_io_program();
mdelay(2000);
}
printk(KERN_INFO "pic18_worker: main stopped\n");
return 0;
}
void pic18_worker_exit(void)
{
printk(KERN_INFO "pic18_worker: pic18_worker_exit\n");
if (worker_thread != NULL)
kthread_stop(worker_thread);
}