hal/hald/linux2/probing probe-input.c,1.14,1.15

David Zeuthen david at kemper.freedesktop.org
Mon May 8 07:47:07 PDT 2006


Update of /cvs/hal/hal/hald/linux2/probing
In directory kemper:/tmp/cvs-serv31951/hald/linux2/probing

Modified Files:
	probe-input.c 
Log Message:
2006-05-08  David Zeuthen  <davidz at redhat.com>

        * hald/linux2/probing/probe-input.c: This patch fixes endian-ness
        issues with the input device support of hal, and thus makes the
        special buttons on a big-endian machine show up through hal. Patch
        from Johannes Berg <johannes at sipsolutions.net>.



Index: probe-input.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/probing/probe-input.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- probe-input.c	23 Feb 2006 00:41:33 -0000	1.14
+++ probe-input.c	8 May 2006 14:47:05 -0000	1.15
@@ -42,13 +42,19 @@
 
 #include "shared.h"
 
-#define test_bit(bit, array) (array[(bit) / 8] & (1 << ((bit) % 8)))
+/* we must use this kernel-compatible implementation */
+#define BITS_PER_LONG (sizeof(long) * 8)
+#define NBITS(x) ((((x)-1)/BITS_PER_LONG)+1)
+#define OFF(x)  ((x)%BITS_PER_LONG)
+#define BIT(x)  (1UL<<OFF(x))
+#define LONG(x) ((x)/BITS_PER_LONG)
+#define test_bit(bit, array)    ((array[LONG(bit)] >> OFF(bit)) & 1)
 
 static void 
 check_abs (int fd, LibHalContext *ctx, const char *udi)
 {
-	char bitmask[(ABS_MAX + 7) / 8];
-	char bitmask_touch[(KEY_MAX + 7) / 8];
+	long bitmask[NBITS(ABS_MAX)];
+	long bitmask_touch[NBITS(KEY_MAX)];
 	DBusError error;
 
 	if (ioctl (fd, EVIOCGBIT(EV_ABS, sizeof (bitmask)), bitmask) < 0) {
@@ -81,7 +87,7 @@
 check_key (int fd, LibHalContext *ctx, const char *udi)
 {
 	unsigned int i;
-	char bitmask[(KEY_MAX + 7) / 8];
+	long bitmask[NBITS(KEY_MAX)];
 	int is_keyboard;
 	DBusError error;
 
@@ -112,7 +118,7 @@
 static void 
 check_rel (int fd, LibHalContext *ctx, const char *udi)
 {
-	char bitmask[(REL_MAX + 7) / 8];
+	long bitmask[NBITS(REL_MAX)];
 	DBusError error;
 
 	if (ioctl (fd, EVIOCGBIT(EV_REL, sizeof (bitmask)), bitmask) < 0) {




More information about the hal-commit mailing list