#include
struct powerkey_t
{
...
struct tast_struct *p_thread;
...
}
static struct powerkey_t pwk;
static int create_powerkey_thread(void)
{
struct powerkey_t *ppwk = &pwk;
pr_debug("%s\n",__FUNCTION__);
ppwk->p_thread = kthread_run(&powerkey_thread,NULL,"powerkey thread");
if(ppwk->p_thread == NULL){
pr_debug("%s failed\n",__FUNCTION__);
return -1;
}
return 0;
}
static void delete_powerkey_thread(void)
{
struct powerkey_t *ppwk = &pwk;
pr_debug("%s\n",__FUNCTION__);
if(ppwk->p_thread)
kthread_stop(ppwk->p_thread);
ppwk->p_thread = NULL;
}
static int powerkey_thread(void *data)
{
struct powerkey_t *ppwk = &pwk;
long ret;
pr_debug("%s\n",__FUNCTION__);
while(!kthread_should_stop())
{
...
//schedule_timeout();
...
}
pr_debug("%s exit!\n",__FUNCTION__);
return 0;
}
static int pmb_probe(struct platform_device *dev)
{
int ret;
...
create_powerkey_thread();
...
return 0;
}
static int pmb_remove(struct platform_device *dev)
{
int ret;
struct powerkey_t *ppwk = &pwk;
pr_debug("%s\n",__FUNCTION__);
...
delete_powerkey_thread();
...
return 0;
}
阅读(1374) | 评论(0) | 转发(1) |