写内核定时器时,出现的警告及改正

来源:互联网 发布:淘宝分销网址 编辑:程序博客网 时间:2024/05/17 17:40

1、warning:functin declaration isn't prototype

错因:函数没有按照标准类型定义

比如:驱动加载及卸载函数static int __inti timer_init(void)

我没写()内的void造成的。

总结:驱动中,很多函数都有固定的模式,必须完全按照模式写!

2、warning:assignment from incompatible pointer type

错因:指针指向的类型不对

比如:timer.function的函数参数必须是unsigned long ,我写成了int。

timer的初始化需要注意:因为struct timer_list共5项内容,其中2项通过函数init_timer(&timer)初始化完成。

然后剩余的3项需要自己初始化。如:timer.data=5;timer.function=timer_function;(此处为自己定义好的函数名);timer.expires=jiffies+5*HZ。


0 0
原创粉丝点击