- 论坛徽章:
- 0
|
使用环境大体是这样的:
static long do_ioctrl(struct file *file, unsigned int cmd, void *arg) {
struct A *handle = (struct uvc_fh *)file->private_data;
struct B *stream = handle->stream;
switch(cmd) {
...
STREAMON:
struct timer_list cap_timer = TIMER_INITIALIZER(trigger,0,(unsigned long)stream);
....
mod_timer(&cap_timer, jiffies +300);
break;
}
}
在另外一个文件中定义了trigger
void trigger(unsigned long val) {
printk(KERN_INFO "fuck!");
}
我原本只是想利用定时器做一个触发,简单写了个模板,上层程序也会调到这个ioctrl。可是当程序跑起来以后,定时器触发时就死掉了。但如果将(unsigned long)stream换成一个具体的数字(如(unsigned long)stream的地址)就可以打印出来,一切都正常。我看了定时器的源码,也只是把data域传入到(fn)的回调函数中,所以对这个现象很不解。有没有用过这种将指针作为回调参数的方法的兄弟啊,请大家指教。。 |
|