You are not logged in.
Hello,
I've been following this tutorial about linux drivers:
www.freesoftwaremagazine.com/articles/drivers_linux
Now, when I compile the code, this is what I get (the warnings on lines 117 and 137 don't concern me):
$ make -C /usr/src/kernels/2.6.32-431.11.2.el6.x86_64/ M=`pwd` modules
make: Entering directory `/usr/src/kernels/2.6.32-431.11.2.el6.x86_64'
CC [M] ~/Documents/development/drivers/code_003/memory.o
~/Documents/development/drivers/code_003/memory.c:36: warning: initialization from incompatible pointer type
~/Documents/development/drivers/code_003/memory.c: In function ‘memory_read’:
~/Documents/development/drivers/code_003/memory.c:117: warning: unused variable ‘result’
~/Documents/development/drivers/code_003/memory.c: In function ‘memory_write’:
~/Documents/development/drivers/code_003/memory.c:137: warning: ISO C90 forbids mixed declarations and code
~/Documents/development/drivers/code_003/memory.c:137: warning: unused variable ‘result’
Building modules, stage 2.
MODPOST 1 modules
CC ~/Documents/development/drivers/code_003/memory.mod.o
LD [M] ~/Documents/development/drivers/code_003/memory.ko.unsigned
NO SIGN [M] ~/Documents/development/drivers/code_003/memory.ko
make: Leaving directory `/usr/src/kernels/2.6.32-431.11.2.el6.x86_64'
Here is the source:
https://gist.github.com/anonymous/ff515ebb2f54e267ea69
Why am I getting that first warning? And what's with the structure using colons?
Last edited by publicus (2014-05-28 14:43:29)
Offline
The colons are for bit field assignment.
The warning is likely due to your function not matching the type that is expected - though I'm not sure why yet, your code matches the tutorial.
But are you really using kernel2.6?
Last edited by Trilby (2014-05-27 20:57:25)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Online
And what's with the structure using colons?
https://stackoverflow.com/questions/856 … es-it-mean
tl;dr It gives you the ability to control the packing of things in the structure down to the bit level. Often computer registers use a single word broken into bit fields. The colons tell the compiler how to pack the fields in a very specific way rather than giving the compiler carte blanche.
Edit: Snaked by Trilby. Again.
Last edited by ewaller (2014-05-27 21:00:29)
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way
Offline
Actually Trilby, we are both wrong. Look at answer three in the site I linked.
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way
Offline
I just noticed that - Learn something new every day.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Online
The colons are for bit field assignment.
The warning is likely due to your function not matching the type that is expected - though I'm not sure why yet, your code matches the tutorial.
But are you really using kernel2.6?
This is on a different machine, so, yes, 2.6.
Offline
publicus wrote:And what's with the structure using colons?
https://stackoverflow.com/questions/856 … es-it-mean
tl;dr It gives you the ability to control the packing of things in the structure down to the bit level. Often computer registers use a single word broken into bit fields. The colons tell the compiler how to pack the fields in a very specific way rather than giving the compiler carte blanche.
Edit: Snaked by Trilby. Again.
Thanks.
How weird. GCC is still complaining about it. I still don't understand exactly why this is happening (but then, I know little about writing driver specific code *shrug*.) I'll make a note of this and come back to it.
[edit]
I don't think I can get more out of this thread. Marking it resolved for now.
Last edited by publicus (2014-05-28 14:43:18)
Offline