LKMPG (Linux Kernel Module Programming Guide) and me.....Help!!!
hi there,
this is gaurav.i trying to explore the magic of kernel programming through LKMPG(Linux Kernel Module Programming Guide).Somehow manage to sailed easily through the initial topics...but facing problem while implementing the advance topics...like k/b led on-off,scheduler....i'm using Fedora core 8,kernel 2.6.25,working on AMD64 Athlon x2 platform.i doesnt have previous programming experience for kernel.i am an embedded engineer with experience of progamming for 8,16,32 bit processors.For the scheduler module....i m getting following errors.... [root@localhost src]# make make -C /lib/modules/2.6.25/build M=/usr/src modules make[1]: Entering directory `/usr/src/linux-2.6.25' CC [M] /usr/src/sched.o /usr/src/sched.c:21:45: error: macro "DECLARE_WORK" passed 3 arguments, but takes just 2 /usr/src/sched.c:21: warning: type defaults to ‘int’ in declaration of ‘DECLARE_WORK’ /usr/src/sched.c: In function ‘intrpt_routine’: /usr/src/sched.c:27: warning: passing argument 2 of ‘queue_delayed_work’ from incompatible pointer type /usr/src/sched.c: In function ‘init_module’: /usr/src/sched.c:64: warning: passing argument 2 of ‘queue_delayed_work’ from incompatible pointer type /usr/src/sched.c: In function ‘cleanup_module’: /usr/src/sched.c:76: warning: passing argument 1 of ‘cancel_delayed_work’ from incompatible pointer type make[2]: *** [/usr/src/sched.o] Error 1 make[1]: *** [_module_/usr/src] Error 2 make[1]: Leaving directory `/usr/src/linux-2.6.25' make: *** [all] Error 2 your valuable guidance needed.....plz help Best Regards, Gaurav Holey |
Wrong forum. But, may be some mod will move it. Anyway, It looks like you are looking at a tutorial that is dated. The current DECLARE_WORK macro takes only two arguments. The first one is the name of the task structure and the next is the function that need to be run. Had a quick look at the tut that you were mentioning. Open you sched.c and look for
Quote:
Quote:
|
hi there,
lately i have tried removing the 3rd argument from macro DECLARE_WORK as per new kernel standards....my code got compiled with few warnings as under... [root@localhost src]# make make -C /lib/modules/2.6.25/build M=/usr/src modules make[1]: Entering directory `/usr/src/linux-2.6.25' CC [M] /usr/src/sched.o /usr/src/sched.c:21: warning: initialization from incompatible pointer type /usr/src/sched.c: In function ‘intrpt_routine’: /usr/src/sched.c:27: warning: passing argument 2 of ‘queue_delayed_work’ from incompatible pointer type /usr/src/sched.c: In function ‘init_module’: /usr/src/sched.c:64: warning: passing argument 2 of ‘queue_delayed_work’ from incompatible pointer type /usr/src/sched.c: In function ‘cleanup_module’: /usr/src/sched.c:76: warning: passing argument 1 of ‘cancel_delayed_work’ from incompatible pointer type Building modules, stage 2. MODPOST 5 modules LD [M] /usr/src/sched.ko make[1]: Leaving directory `/usr/src/linux-2.6.25' i have tried insmoding it but system hangs and i have to reboot it forcefully....and very foolish thing i should mention that i am unable to find out the exact output and working of this particular module...need your help.... Best Regards, Gaurav Holey |
LKMPG (Linux Kernel Module Programming Guide) and Help me AGAIN...!!
hi there,
This is in reference with the my first post...."LKMPG (Linux Kernel Module Programming Guide) and me...HELP!!!" lately i have tried removing the 3rd argument from macro DECLARE_WORK as per new kernel standards....my code got compiled with few warnings as under... [root@localhost src]# make make -C /lib/modules/2.6.25/build M=/usr/src modules make[1]: Entering directory `/usr/src/linux-2.6.25' CC [M] /usr/src/sched.o /usr/src/sched.c:21: warning: initialization from incompatible pointer type /usr/src/sched.c: In function ‘intrpt_routine’: /usr/src/sched.c:27: warning: passing argument 2 of ‘queue_delayed_work’ from incompatible pointer type /usr/src/sched.c: In function ‘init_module’: /usr/src/sched.c:64: warning: passing argument 2 of ‘queue_delayed_work’ from incompatible pointer type /usr/src/sched.c: In function ‘cleanup_module’: /usr/src/sched.c:76: warning: passing argument 1 of ‘cancel_delayed_work’ from incompatible pointer type Building modules, stage 2. MODPOST 5 modules LD [M] /usr/src/sched.ko make[1]: Leaving directory `/usr/src/linux-2.6.25' i have tried insmoding it but system hangs and i have to reboot it forcefully....and very foolish thing i should mention that i am unable to find out the exact output and working of this particular module...need your help.... Best Regards, Gaurav Holey |
You need to look at what the kernel your working with requires, take a look at those functions/macros and see what you should be passing them.
|
Quote:
I have merged your two threads. |
Corrected for 2.6.23-17. Hope this will work on 2.6.25.
Code:
/* while true; do cat /proc/sched;sleep 3; done To exit, press "ctrl-c". "rmmod sched" after testing and do "ls /proc/sched". You will find that the file has disappeared. What does it do? Schedules the function intrpt_routine. This function can schedule itself once called. The same function increments a variable TimerIntrpt. When you read /proc/sched, you get the value of TimerIntrpt. |
sorry for my shabby work....i'll keep that thing in mind.....my question still remains unanswered....how should i approach the problem .....plz help...i m stuck...
hgaurav |
For the approach, look at the post by estabroo. For the solution, look at my post above.
|
hi there,
thanks,finally it worked...but while going through the sarin's code the two changes observed are...the use of Macro DECLARE_DELAYED_WORK and the function intrpt_routine.... i have gone through the interrupt.h and the other related header files but not able to understand the parameter pass to this function....please guide... Best Regards, Gaurav Holey |
still about the warnings
I recently have had some warnings on the same function DECLARE_WORK and all the places in code i have the first term of DECLARE_WORK.
As far as i know it's not ok to have warnings, and in general it is always possible to get rid of them. so i have: static struct task; DECLARE_WORK(task, function); i have a warning for this: warning: initialization from incompatible pointer type and after that queue_delayed_work(my_queue, &task, 1); anyway all the places i use task i got errors: warning: passing argument 2 of ‘queue_delayed_work’ from incompatible pointer type what is the problem actually, does someone know? Thanks in advance, and yes all i want is just to get rid of those warnings. |
Thanks alot to sarin and estabroo. I signed up to say thanx. You gave me the lead I needed, both working code and a point in the right direction as to where to look for such info. Gracias
OGRE |
All times are GMT -5. The time now is 02:29 AM. |