If you want to pass data to your work queue function, just embed the work_struct structure inside your own data structure and use container_of inside your work function to retrieve it.
As for a simple example, the kernel is full of it - just git grep work_struct. You can look at drivers/cpufreq/cpufreq.c (handle_update function) for a simple example. The article below also embeds an example at the end, but it does not use container_of and instead relies on the fact that the first member of a structure has the same address as its parent:
http://www.ibm.com/developerworks/linux/library/l-tasklets/index.html
Answer from Gnurou on Stack OverflowVideos
If you want to pass data to your work queue function, just embed the work_struct structure inside your own data structure and use container_of inside your work function to retrieve it.
As for a simple example, the kernel is full of it - just git grep work_struct. You can look at drivers/cpufreq/cpufreq.c (handle_update function) for a simple example. The article below also embeds an example at the end, but it does not use container_of and instead relies on the fact that the first member of a structure has the same address as its parent:
http://www.ibm.com/developerworks/linux/library/l-tasklets/index.html
It seems like solved, and you have been very helpful to me in order to understand how to use the Work Queues. I give you some code of a simple example in my github, hoping it will be helpful to anyone:
https://github.com/m0r3n/kernel_modules/blob/master/workQueue.c
You can compile with the following Makefile:
KVERSION = $(shell uname -r)
obj-m = workQueue.o
all:
make -C /lib/modules/$(KVERSION)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(KVERSION)/build M=$(PWD) clean
Insert the module by:
# sync; insmod workQueue.ko; sync
And see the logs:
# tailf /var/log/kern.log
EDIT: I just added the delayed version:
https://github.com/m0r3n/kernel_modules/blob/master/workQueueDelayed.c