I'm trying to write a kernel module but I'm stuck with accessing member of structure defined in another module header. I'll try to explain:
Let's say the other module is:
<kernel-src>/drivers/xxx/xxx.c|.h
in xxx.c there are some exported functions which I'm using in my driver. However I want to access the member m1 from struct s_xxx defined in xxx.h:
struct s_xxx {
...
int m1;
};
Next I have this in /usr/include/linux/yyy.h:
struct s_xxx;
struct s_yyy {
...
struct s_xxx *p_xxx;
};
I my driver I've:
#include <linux/yyy.h>
and I'm successfully using the exported symbols from the xxx driver. But of course if I try to access member from s_xxx the compiler complains:
struct s_yyy *p_yyy;
...
m = p_yyy->p_xxx->m1; /* error */
xxx.h can't be found in /usr/include/linux/. So far I've found 2 workarounds:
1) to download the kernel sources and include the full path to xxx.h in my module
2) copy/paste the s_xxx definition from xxx.h to my module
What is the correct way to do this?
(sorry for the long and crappy explanation :@ )