Ai
1 Star 2 Fork 2

e665107/Linux-Device-Drivers-Development

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
std-timer.c 978 Bytes
一键复制 编辑 原始数据 按行查看 历史
swathym14 提交于 2017-10-13 20:40 +08:00 . Code files
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/timer.h>
static struct timer_list my_timer;
void my_timer_callback( unsigned long data )
{
pr_info( "%s called (%ld).\n", __FUNCTION__, jiffies );
}
static int __init my_init( void )
{
int retval;
pr_info("Timer module loaded\n");
setup_timer( &my_timer, my_timer_callback, 0 );
pr_info( "Setup timer to fire in 300ms (%ld)\n", jiffies );
retval = mod_timer( &my_timer, jiffies + msecs_to_jiffies(300) );
if (retval)
pr_info("Timer firing failed\n");
return 0;
}
static void my_exit( void )
{
int retval;
retval = del_timer( &my_timer );
if (retval)
pr_info("The timer is still in use...\n");
pr_info("Timer module unloaded\n");
return;
}
module_init(my_init);
module_exit(my_exit);
MODULE_AUTHOR("John Madieu <john.madieu@gmail.com>");
MODULE_DESCRIPTION("Standard timer example");
MODULE_LICENSE("GPL");
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/e665107/Linux-Device-Drivers-Development.git
git@gitee.com:e665107/Linux-Device-Drivers-Development.git
e665107
Linux-Device-Drivers-Development
Linux-Device-Drivers-Development
master

搜索帮助