Hi Jiri,
After merging the hid tree, today's linux-next build (x86_64 allmodconfig)
failed like this:
samples/hidraw/hid-example.c: In function 'main':
samples/hidraw/hid-example.c:103: warning: implicit declaration of function 'HIDIOCSFEATURE'
samples/hidraw/hid-example.c:111: warning: implicit declaration of function 'HIDIOCGFEATURE'
tmp/ccK96SHd.o: In function `main':
hid-example.c:(.text+0x205): undefined reference to `HIDIOCSFEATURE'
hid-example.c:(.text+0x23e): undefined reference to `HIDIOCGFEATURE'
Caused by commit c54ea4918c2b ("HID: Documentation for hidraw"). I can
only assume that linux/hidraw.h is being included from /usr/include and
not the kernel tree being built?
I have used the hid tree from next-20110406 for today.
--
Cheers,
Stephen Rothwell [email protected]
http://www.canb.auug.org.au/~sfr/
On 04/06/2011 09:06 PM, Stephen Rothwell wrote:
> After merging the hid tree, today's linux-next build (x86_64 allmodconfig)
> failed like this:
>
> samples/hidraw/hid-example.c: In function 'main':
> samples/hidraw/hid-example.c:103: warning: implicit declaration of function 'HIDIOCSFEATURE'
> samples/hidraw/hid-example.c:111: warning: implicit declaration of function 'HIDIOCGFEATURE'
> tmp/ccK96SHd.o: In function `main':
> hid-example.c:(.text+0x205): undefined reference to `HIDIOCSFEATURE'
> hid-example.c:(.text+0x23e): undefined reference to `HIDIOCGFEATURE'
>
> Caused by commit c54ea4918c2b ("HID: Documentation for hidraw"). I can
> only assume that linux/hidraw.h is being included from /usr/include and
> not the kernel tree being built?
Hi Stephen,
That sounds like a reasonable explanation. What's the right way to do
this? I suppose I had incorrectly assumed that the include path would be
set by the build system to the kernel tree being built. The other
samples seem to do the same thing (simply #including whatever they
need), and don't seem to do anything special with include paths to make
it use the current tree.
Maybe Randy can shed some light.
Sorry for the bother,
Alan.
On Thu, 7 Apr 2011, Stephen Rothwell wrote:
> Hi Jiri,
>
> After merging the hid tree, today's linux-next build (x86_64 allmodconfig)
> failed like this:
>
> samples/hidraw/hid-example.c: In function 'main':
> samples/hidraw/hid-example.c:103: warning: implicit declaration of function 'HIDIOCSFEATURE'
> samples/hidraw/hid-example.c:111: warning: implicit declaration of function 'HIDIOCGFEATURE'
> tmp/ccK96SHd.o: In function `main':
> hid-example.c:(.text+0x205): undefined reference to `HIDIOCSFEATURE'
> hid-example.c:(.text+0x23e): undefined reference to `HIDIOCGFEATURE'
>
> Caused by commit c54ea4918c2b ("HID: Documentation for hidraw"). I can
> only assume that linux/hidraw.h is being included from /usr/include and
> not the kernel tree being built?
>
> I have used the hid tree from next-20110406 for today.
OK, I have introduced the patch below to the branch now. I am not proud of
it, but I don't see other option currently. Will remove it after some
time.
From: Jiri Kosina <[email protected]>
Subject: [PATCH] HID: hidraw: fix samples miscompilation
On systems where userspace doesn't have new hidraw.h populated to
/usr/include, the hidraw sample won't compile as it's missing the new
ioctl defitions.
Introduce temporary ugly workaround to define the ioctls "manually"
in such cases, just to avoid miscompilation in allmodconfig cases.
Reported-by: Stephen Rothwell <[email protected]>
Signed-off-by: Jiri Kosina <[email protected]>
---
samples/hidraw/hid-example.c | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/samples/hidraw/hid-example.c b/samples/hidraw/hid-example.c
index 40e3d62..816e2dc 100644
--- a/samples/hidraw/hid-example.c
+++ b/samples/hidraw/hid-example.c
@@ -14,6 +14,17 @@
#include <linux/input.h>
#include <linux/hidraw.h>
+/*
+ * Ugly hack to work around failing compilation on systems that don't
+ * yet populate new version of hidraw.h to userspace.
+ *
+ * If you need this, please have your distro update the kernel headers.
+ */
+#ifndef HIDIOCSFEATURE
+#define HIDIOCSFEATURE(len) _IOC(_IOC_WRITE|_IOC_READ, 'H', 0x06, len)
+#define HIDIOCGFEATURE(len) _IOC(_IOC_WRITE|_IOC_READ, 'H', 0x07, len)
+#endif
+
/* Unix */
#include <sys/ioctl.h>
#include <sys/types.h>
--
1.7.3.1