Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Chapter03/std-timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/timer.h>
#include <linux/version.h>

static struct timer_list my_timer;

#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
void my_timer_callback( struct timer_list * timer)
#else
void my_timer_callback( unsigned long data )
#endif
{
pr_info( "%s called (%ld).\n", __FUNCTION__, jiffies );
}
Expand All @@ -15,9 +20,12 @@ static int __init my_init( void )
int retval;
pr_info("Timer module loaded\n");

#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
timer_setup( &my_timer, my_timer_callback, 0 );
#else
setup_timer( &my_timer, my_timer_callback, 0 );
#endif
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");
Expand Down
2 changes: 1 addition & 1 deletion Chapter07/ee24lc512.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <linux/mutex.h>
#include <linux/i2c.h>
#include <linux/delay.h>
#include <asm/uaccess.h>
#include <linux/uaccess.h>


/*
Expand Down