timer_list在linux kernel4.14以上版本的应用
timer_list在linux kernel4.14以上版本的应用:
#if LINUX_VERSION_CODE < KERNEL_VERSION(4,14,0) init_timer(&dev->getIntrTimer); dev->getIntrTimer.data = (unsigned long) dev; dev->getIntrTimer.function = GetIntrTimerCallback; /* ... */ add_timer(&dev->getIntrTimer); #else timer_setup(&dev->getIntrTimer, GetIntrTimerCallback, 0); /* the third argument may include TIMER_* flags */ /* ... */ #endif
回调函数:
#if LINUX_VERSION_CODE < KERNEL_VERSION(4,14,0) void GetIntrTimerCallback(unsigned long devAddr) { myDevice *dev = (myDevice *) devAddr; #else void GetIntrTimerCallback(struct timer_list *t) { myDevice *dev = from_timer(dev, t, getIntrTimer); #endif