"
#define DRIVER_DESC "A sample driver"
static int __init init_hello_4(void)
{
- printk(KERN_ALERT "Hello, world 4\n");
+ printk(KERN_INFO "Hello, world 4\n");
return 0;
}
static void __exit cleanup_hello_4(void)
{
- printk(KERN_ALERT "Goodbye, world 4\n");
+ printk(KERN_INFO "Goodbye, world 4\n");
}
module_init(init_hello_4);
diff --git a/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/02-HelloWorld/hello-5.c b/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/02-HelloWorld/hello-5.c
index 75fd500a..77b9d112 100644
--- a/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/02-HelloWorld/hello-5.c
+++ b/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/02-HelloWorld/hello-5.c
@@ -14,6 +14,8 @@ static short int myshort = 1;
static int myint = 420;
static long int mylong = 9999;
static char *mystring = "blah";
+static int myintArray[2] = { -1, -1 };
+static int arr_argc = 0;
/*
* module_param(foo, int, 0000)
@@ -32,19 +34,36 @@ MODULE_PARM_DESC(mylong, "A long integer");
module_param(mystring, charp, 0000);
MODULE_PARM_DESC(mystring, "A character string");
+/*
+ * module_param_array(name, type, num, perm);
+ * The first param is the parameter's (in this case the array's) name
+ * The second param is the data type of the elements of the array
+ * The third argument is a pointer to the variable that will store the number
+ * of elements of the array initialized by the user at module loading time
+ * The fourth argument is the permission bits
+ */
+module_param_array(myintArray, int, &arr_argc, 0000);
+MODULE_PARM_DESC(myintArray, "An array of integers");
+
static int __init hello_5_init(void)
{
- printk(KERN_ALERT "Hello, world 5\n=============\n");
- printk(KERN_ALERT "myshort is a short integer: %hd\n", myshort);
- printk(KERN_ALERT "myint is an integer: %d\n", myint);
- printk(KERN_ALERT "mylong is a long integer: %ld\n", mylong);
- printk(KERN_ALERT "mystring is a string: %s\n", mystring);
+ int i;
+ printk(KERN_INFO "Hello, world 5\n=============\n");
+ printk(KERN_INFO "myshort is a short integer: %hd\n", myshort);
+ printk(KERN_INFO "myint is an integer: %d\n", myint);
+ printk(KERN_INFO "mylong is a long integer: %ld\n", mylong);
+ printk(KERN_INFO "mystring is a string: %s\n", mystring);
+ for (i = 0; i < (sizeof myintArray / sizeof (int)); i++)
+ {
+ printk(KERN_INFO "myintArray[%d] = %d\n", i, myintArray[i]);
+ }
+ printk(KERN_INFO "got %d arguments for myintArray.\n", arr_argc);
return 0;
}
static void __exit hello_5_exit(void)
{
- printk(KERN_ALERT "Goodbye, world 5\n");
+ printk(KERN_INFO "Goodbye, world 5\n");
}
module_init(hello_5_init);
diff --git a/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/02-HelloWorld/start.c b/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/02-HelloWorld/start.c
index 74e1b17a..369035fa 100644
--- a/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/02-HelloWorld/start.c
+++ b/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/02-HelloWorld/start.c
@@ -7,6 +7,6 @@
int init_module(void)
{
- printk("Hello, world - this is the kernel speaking\n");
+ printk(KERN_INFO "Hello, world - this is the kernel speaking\n");
return 0;
}
diff --git a/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/02-HelloWorld/stop.c b/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/02-HelloWorld/stop.c
index 66024e56..3331f5f1 100644
--- a/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/02-HelloWorld/stop.c
+++ b/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/02-HelloWorld/stop.c
@@ -7,5 +7,5 @@
void cleanup_module()
{
- printk("<1>Short is the life of a kernel module\n");
+ printk(KERN_INFO "Short is the life of a kernel module\n");
}
diff --git a/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/04-CharacterDeviceFiles/Makefile b/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/04-CharacterDeviceFiles/Makefile
index 93df0bf5..878fabd2 100644
--- a/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/04-CharacterDeviceFiles/Makefile
+++ b/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/04-CharacterDeviceFiles/Makefile
@@ -1 +1,12 @@
+#
+# This is a sort a recursive Makefile
+# This Makefile is used to compile the module
+#
+
obj-m += chardev.o
+
+all:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
+
+clean:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
diff --git a/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/04-CharacterDeviceFiles/chardev.c b/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/04-CharacterDeviceFiles/chardev.c
index 19de4688..3b76eba1 100644
--- a/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/04-CharacterDeviceFiles/chardev.c
+++ b/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/04-CharacterDeviceFiles/chardev.c
@@ -40,29 +40,30 @@ static struct file_operations fops = {
};
/*
- * Functions
+ * This function is called when the module is loaded
*/
-
int init_module(void)
{
- Major = register_chrdev(0, DEVICE_NAME, &fops);
+ Major = register_chrdev(0, DEVICE_NAME, &fops);
if (Major < 0) {
- printk("Registering the character device failed with %d\n",
- Major);
- return Major;
+ printk(KERN_ALERT "Registering char device failed with %d\n", Major);
+ return Major;
}
- printk("<1>I was assigned major number %d. To talk to\n", Major);
- printk("<1>the driver, create a dev file with\n");
- printk("'mknod /dev/hello c %d 0'.\n", Major);
- printk("<1>Try various minor numbers. Try to cat and echo to\n");
- printk("the device file.\n");
- printk("<1>Remove the device file and module when done.\n");
+ printk(KERN_INFO "I was assigned major number %d. To talk to\n", Major);
+ printk(KERN_INFO "the driver, create a dev file with\n");
+ printk(KERN_INFO "'mknod /dev/%s c %d 0'.\n", DEVICE_NAME, Major);
+ printk(KERN_INFO "Try various minor numbers. Try to cat and echo to\n");
+ printk(KERN_INFO "the device file.\n");
+ printk(KERN_INFO "Remove the device file and module when done.\n");
- return 0;
+ return SUCCESS;
}
+/*
+ * This function is called when the module is unloaded
+ */
void cleanup_module(void)
{
/*
@@ -70,7 +71,7 @@ void cleanup_module(void)
*/
int ret = unregister_chrdev(Major, DEVICE_NAME);
if (ret < 0)
- printk("Error in unregister_chrdev: %d\n", ret);
+ printk(KERN_ALERT "Error in unregister_chrdev: %d\n", ret);
}
/*
@@ -84,8 +85,10 @@ void cleanup_module(void)
static int device_open(struct inode *inode, struct file *file)
{
static int counter = 0;
+
if (Device_Open)
return -EBUSY;
+
Device_Open++;
sprintf(msg, "I already told you %d times Hello world!\n", counter++);
msg_Ptr = msg;
@@ -160,6 +163,6 @@ static ssize_t device_read(struct file *filp, /* see include/linux/fs.h */
static ssize_t
device_write(struct file *filp, const char *buff, size_t len, loff_t * off)
{
- printk("<1>Sorry, this operation isn't supported.\n");
+ printk(KERN_ALERT "Sorry, this operation isn't supported.\n");
return -EINVAL;
}
diff --git a/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/05-TheProcFileSystem/Makefile b/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/05-TheProcFileSystem/Makefile
index cf519b72..2998bec2 100644
--- a/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/05-TheProcFileSystem/Makefile
+++ b/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/05-TheProcFileSystem/Makefile
@@ -1 +1,7 @@
-obj-m += procfs.o
+obj-m += procfs1.o procfs2.o procfs3.o
+
+all:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
+
+clean:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
diff --git a/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/06-UsingProcForInput/Makefile b/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/06-UsingProcForInput/Makefile
index cf519b72..f5dbf526 100644
--- a/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/06-UsingProcForInput/Makefile
+++ b/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/06-UsingProcForInput/Makefile
@@ -1 +1,7 @@
obj-m += procfs.o
+
+all:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
+
+clean:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
diff --git a/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/06-UsingProcForInput/procfs.c b/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/06-UsingProcForInput/procfs.c
index 2651ce77..c42de5fa 100644
--- a/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/06-UsingProcForInput/procfs.c
+++ b/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/06-UsingProcForInput/procfs.c
@@ -165,10 +165,12 @@ int init_module()
Our_Proc_File->gid = 0;
Our_Proc_File->size = 80;
+ printk(KERN_INFO "/proc/rw_test created\n");
return 0; /* success */
}
void cleanup_module()
{
remove_proc_entry(PROC_ENTRY_FILENAME, &proc_root);
+ printk(KERN_INFO "/proc/rw_test removed\n");
}
diff --git a/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/07-TalkingToDeviceFiles/Makefile b/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/07-TalkingToDeviceFiles/Makefile
index 93df0bf5..c73f3b95 100644
--- a/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/07-TalkingToDeviceFiles/Makefile
+++ b/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/07-TalkingToDeviceFiles/Makefile
@@ -1 +1,13 @@
obj-m += chardev.o
+
+all: ioctl module
+
+module:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
+
+install:
+ mknod /proc/char_dev c 100 0
+
+clean:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
+ rm -f ioctl
diff --git a/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/07-TalkingToDeviceFiles/chardev.c b/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/07-TalkingToDeviceFiles/chardev.c
index cc5c6b5d..3e916d91 100644
--- a/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/07-TalkingToDeviceFiles/chardev.c
+++ b/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/07-TalkingToDeviceFiles/chardev.c
@@ -36,7 +36,7 @@ static char *Message_Ptr;
static int device_open(struct inode *inode, struct file *file)
{
#ifdef DEBUG
- printk("device_open(%p)\n", file);
+ printk(KERN_INFO "device_open(%p)\n", file);
#endif
/*
@@ -57,7 +57,7 @@ static int device_open(struct inode *inode, struct file *file)
static int device_release(struct inode *inode, struct file *file)
{
#ifdef DEBUG
- printk("device_release(%p,%p)\n", inode, file);
+ printk(KERN_INFO "device_release(%p,%p)\n", inode, file);
#endif
/*
@@ -85,7 +85,7 @@ static ssize_t device_read(struct file *file, /* see include/linux/fs.h */
int bytes_read = 0;
#ifdef DEBUG
- printk("device_read(%p,%p,%d)\n", file, buffer, length);
+ printk(KERN_INFO "device_read(%p,%p,%d)\n", file, buffer, length);
#endif
/*
@@ -113,7 +113,7 @@ static ssize_t device_read(struct file *file, /* see include/linux/fs.h */
}
#ifdef DEBUG
- printk("Read %d bytes, %d left\n", bytes_read, length);
+ printk(KERN_INFO "Read %d bytes, %d left\n", bytes_read, length);
#endif
/*
@@ -134,7 +134,7 @@ device_write(struct file *file,
int i;
#ifdef DEBUG
- printk("device_write(%p,%s,%d)", file, buffer, length);
+ printk(KERN_INFO "device_write(%p,%s,%d)", file, buffer, length);
#endif
for (i = 0; i < length && i < BUF_LEN; i++)
@@ -247,20 +247,20 @@ int init_module()
* Negative values signify an error
*/
if (ret_val < 0) {
- printk("%s failed with %d\n",
+ printk(KERN_ALERT "%s failed with %d\n",
"Sorry, registering the character device ", ret_val);
return ret_val;
}
- printk("%s The major device number is %d.\n",
+ printk(KERN_INFO "%s The major device number is %d.\n",
"Registeration is a success", MAJOR_NUM);
- printk("If you want to talk to the device driver,\n");
- printk("you'll have to create a device file. \n");
- printk("We suggest you use:\n");
- printk("mknod %s c %d 0\n", DEVICE_FILE_NAME, MAJOR_NUM);
- printk("The device file name is important, because\n");
- printk("the ioctl program assumes that's the\n");
- printk("file you'll use.\n");
+ printk(KERN_INFO "If you want to talk to the device driver,\n");
+ printk(KERN_INFO "you'll have to create a device file. \n");
+ printk(KERN_INFO "We suggest you use:\n");
+ printk(KERN_INFO "mknod %s c %d 0\n", DEVICE_FILE_NAME, MAJOR_NUM);
+ printk(KERN_INFO "The device file name is important, because\n");
+ printk(KERN_INFO "the ioctl program assumes that's the\n");
+ printk(KERN_INFO "file you'll use.\n");
return 0;
}
@@ -281,5 +281,5 @@ void cleanup_module()
* If there's an error, report it
*/
if (ret < 0)
- printk("Error in module_unregister_chrdev: %d\n", ret);
+ printk(KERN_ALERT "Error: unregister_chrdev: %d\n", ret);
}
diff --git a/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/08-SystemCalls/Makefile b/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/08-SystemCalls/Makefile
index 82b11a8e..332678d1 100644
--- a/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/08-SystemCalls/Makefile
+++ b/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/08-SystemCalls/Makefile
@@ -1 +1,7 @@
obj-m += syscall.o
+
+all:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
+
+clean:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
diff --git a/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/08-SystemCalls/syscall.c b/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/08-SystemCalls/syscall.c
index 40dda213..b88247ff 100644
--- a/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/08-SystemCalls/syscall.c
+++ b/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/08-SystemCalls/syscall.c
@@ -112,13 +112,13 @@ int init_module()
* Warning - too late for it now, but maybe for
* next time...
*/
- printk("I'm dangerous. I hope you did a ");
- printk("sync before you insmod'ed me.\n");
- printk("My counterpart, cleanup_module(), is even");
- printk("more dangerous. If\n");
- printk("you value your file system, it will ");
- printk("be \"sync; rmmod\" \n");
- printk("when you remove this module.\n");
+ printk(KERN_ALERT "I'm dangerous. I hope you did a ");
+ printk(KERN_ALERT "sync before you insmod'ed me.\n");
+ printk(KERN_ALERT "My counterpart, cleanup_module(), is even");
+ printk(KERN_ALERT "more dangerous. If\n");
+ printk(KERN_ALERT "you value your file system, it will ");
+ printk(KERN_ALERT "be \"sync; rmmod\" \n");
+ printk(KERN_ALERT "when you remove this module.\n");
/*
* Keep a pointer to the original function in
@@ -133,7 +133,7 @@ int init_module()
* call foo, go to sys_call_table[__NR_foo].
*/
- printk("Spying on UID:%d\n", uid);
+ printk(KERN_INFO "Spying on UID:%d\n", uid);
return 0;
}
@@ -147,10 +147,10 @@ void cleanup_module()
* Return the system call back to normal
*/
if (sys_call_table[__NR_open] != our_sys_open) {
- printk("Somebody else also played with the ");
- printk("open system call\n");
- printk("The system may be left in ");
- printk("an unstable state.\n");
+ printk(KERN_ALERT "Somebody else also played with the ");
+ printk(KERN_ALERT "open system call\n");
+ printk(KERN_ALERT "The system may be left in ");
+ printk(KERN_ALERT "an unstable state.\n");
}
sys_call_table[__NR_open] = original_call;
diff --git a/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/09-BlockingProcesses/Makefile b/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/09-BlockingProcesses/Makefile
index 75332846..d5656d94 100644
--- a/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/09-BlockingProcesses/Makefile
+++ b/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/09-BlockingProcesses/Makefile
@@ -1 +1,10 @@
obj-m += sleep.o
+
+all: cat_noblock module
+
+module:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
+
+clean:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
+ rm -f cat_noblock
diff --git a/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/09-BlockingProcesses/sleep.c b/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/09-BlockingProcesses/sleep.c
index 0397fb4a..9bd4593f 100644
--- a/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/09-BlockingProcesses/sleep.c
+++ b/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/09-BlockingProcesses/sleep.c
@@ -276,8 +276,15 @@ static struct inode_operations Inode_Ops_4_Our_Proc_File = {
int init_module()
{
- int rv = 0;
+
Our_Proc_File = create_proc_entry(PROC_ENTRY_FILENAME, 0644, NULL);
+
+ if (Our_Proc_File == NULL) {
+ remove_proc_entry(PROC_ENTRY_FILENAME, &proc_root);
+ printk(KERN_ALERT "Error: Could not initialize /proc/test\n");
+ return -ENOMEM;
+ }
+
Our_Proc_File->owner = THIS_MODULE;
Our_Proc_File->proc_iops = &Inode_Ops_4_Our_Proc_File;
Our_Proc_File->proc_fops = &File_Ops_4_Our_Proc_File;
@@ -285,14 +292,10 @@ int init_module()
Our_Proc_File->uid = 0;
Our_Proc_File->gid = 0;
Our_Proc_File->size = 80;
-
- if (Our_Proc_File == NULL) {
- rv = -ENOMEM;
- remove_proc_entry(PROC_ENTRY_FILENAME, &proc_root);
- printk(KERN_INFO "Error: Could not initialize /proc/test\n");
- }
-
- return rv;
+
+ printk(KERN_INFO "/proc/test created\n");
+
+ return 0;
}
/*
@@ -304,4 +307,6 @@ int init_module()
void cleanup_module()
{
remove_proc_entry(PROC_ENTRY_FILENAME, &proc_root);
+
+ printk(KERN_INFO "/proc/test removed\n");
}
diff --git a/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/10-ReplacingPrintks/Makefile b/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/10-ReplacingPrintks/Makefile
index 80d46413..156b4534 100644
--- a/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/10-ReplacingPrintks/Makefile
+++ b/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/10-ReplacingPrintks/Makefile
@@ -1,2 +1,8 @@
obj-m += print_string.o
obj-m += kbleds.o
+
+all:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
+
+clean:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
diff --git a/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/11-SchedulingTasks/Makefile b/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/11-SchedulingTasks/Makefile
index 37d9220c..8d9d31a8 100644
--- a/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/11-SchedulingTasks/Makefile
+++ b/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/11-SchedulingTasks/Makefile
@@ -1 +1,7 @@
obj-m += sched.o
+
+all:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
+
+clean:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
diff --git a/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/11-SchedulingTasks/sched.c b/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/11-SchedulingTasks/sched.c
index 5e04f228..19c1dbd8 100644
--- a/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/11-SchedulingTasks/sched.c
+++ b/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/11-SchedulingTasks/sched.c
@@ -76,10 +76,8 @@ procfile_read(char *buffer,
*/
static char my_buffer[80];
- static int count = 1;
-
/*
- * We give all of our information in one go, so if the anybody asks us
+ * We give all of our information in one go, so if anybody asks us
* if we have more information the answer should always be no.
*/
if (offset > 0)
@@ -89,7 +87,6 @@ procfile_read(char *buffer,
* Fill the buffer and get its length
*/
len = sprintf(my_buffer, "Timer called %d times so far\n", TimerIntrpt);
- count++;
/*
* Tell the function which called us where the buffer is
@@ -107,23 +104,18 @@ procfile_read(char *buffer,
*/
int __init init_module()
{
- int rv = 0;
- /*
- * Put the task in the work_timer task queue, so it will be executed at
- * next timer interrupt
+ /*
+ * Create our /proc file
*/
- my_workqueue = create_workqueue(MY_WORK_QUEUE_NAME);
- queue_delayed_work(my_workqueue, &Task, 100);
-
Our_Proc_File = create_proc_entry(PROC_ENTRY_FILENAME, 0644, NULL);
+
if (Our_Proc_File == NULL) {
- rv = -ENOMEM;
remove_proc_entry(PROC_ENTRY_FILENAME, &proc_root);
- printk(KERN_INFO "Error: Could not initialize /proc/%s\n",
+ printk(KERN_ALERT "Error: Could not initialize /proc/%s\n",
PROC_ENTRY_FILENAME);
+ return -ENOMEM;
}
-
-
+
Our_Proc_File->read_proc = procfile_read;
Our_Proc_File->owner = THIS_MODULE;
Our_Proc_File->mode = S_IFREG | S_IRUGO;
@@ -131,7 +123,17 @@ int __init init_module()
Our_Proc_File->gid = 0;
Our_Proc_File->size = 80;
- return rv;
+ /*
+ * Put the task in the work_timer task queue, so it will be executed at
+ * next timer interrupt
+ */
+ my_workqueue = create_workqueue(MY_WORK_QUEUE_NAME);
+ queue_delayed_work(my_workqueue, &Task, 100);
+
+
+ printk(KERN_INFO "/proc/%s created\n", PROC_ENTRY_FILENAME);
+
+ return 0;
}
/*
diff --git a/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/12-InterruptHandlers/Makefile b/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/12-InterruptHandlers/Makefile
index a8ff9a3c..56ff30d1 100644
--- a/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/12-InterruptHandlers/Makefile
+++ b/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/12-InterruptHandlers/Makefile
@@ -1 +1,7 @@
obj-m += intrpt.o
+
+all:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
+
+clean:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
diff --git a/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/12-InterruptHandlers/intrpt.c b/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/12-InterruptHandlers/intrpt.c
index 98b40d2d..428c5265 100644
--- a/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/12-InterruptHandlers/intrpt.c
+++ b/LDP/guide/docbook/lkmpg/2.6/lkmpg-examples/12-InterruptHandlers/intrpt.c
@@ -28,7 +28,7 @@ static struct workqueue_struct *my_workqueue;
*/
static void got_char(void *scancode)
{
- printk("Scan Code %x %s.\n",
+ printk(KERN_INFO "Scan Code %x %s.\n",
(int)*((char *)scancode) & 0x7F,
*((char *)scancode) & 0x80 ? "Released" : "Pressed");
}
diff --git a/LDP/guide/docbook/lkmpg/2.6/lkmpg.sgml b/LDP/guide/docbook/lkmpg/2.6/lkmpg.sgml
index 00729309..5c76b834 100644
--- a/LDP/guide/docbook/lkmpg/2.6/lkmpg.sgml
+++ b/LDP/guide/docbook/lkmpg/2.6/lkmpg.sgml
@@ -29,7 +29,7 @@
-