patch-2.3.48 linux/drivers/usb/hid.c

Next file: linux/drivers/usb/inode.c
Previous file: linux/drivers/usb/graphire.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.47/linux/drivers/usb/hid.c linux/drivers/usb/hid.c
@@ -40,6 +40,8 @@
 #include <linux/smp_lock.h>
 #include <linux/spinlock.h>
 
+#include <asm/unaligned.h>
+
 #undef DEBUG
 #undef DEBUG_DATA
 
@@ -573,14 +575,14 @@
 
 				case 2: 
 					if ((end - start) >= 2) {
-						item->data.u16 = le16_to_cpu( *((__u16*)start)++);
+						item->data.u16 = le16_to_cpu( get_unaligned(((__u16*)start)++));
 						return start;
 					}
 
 				case 3: 
 					item->size++;
 					if ((end - start) >= 4) {
-						item->data.u32 = le32_to_cpu( *((__u32*)start)++);
+						item->data.u32 = le32_to_cpu( get_unaligned(((__u32*)start)++));
 						return start;
 					}
 			}
@@ -706,7 +708,7 @@
 static __inline__ __u32 extract(__u8 *report, unsigned offset, unsigned n)
 {
 	report += (offset >> 5) << 2; offset &= 31;
-	return (le64_to_cpu(*(__u64*)report) >> offset) & ((1 << n) - 1);
+	return (le64_to_cpu(get_unaligned((__u64*)report)) >> offset) & ((1 << n) - 1);
 }
 
 static __inline__ void implement(__u8 *report, unsigned offset, unsigned n, __u32 value)
@@ -1408,19 +1410,16 @@
 	disconnect:	hid_disconnect
 };
 
-#ifdef MODULE
-void cleanup_module(void)
+static int __init hid_init(void)
 {
-	usb_deregister(&hid_driver);
+	usb_register(&hid_driver);
+	return 0;
 }
 
-int init_module(void)
-#else
-int hid_init(void)
-#endif
+static void __exit hid_exit(void)
 {
-	usb_register(&hid_driver);
-	return 0;
+	usb_deregister(&hid_driver);
 }
 
-__initcall(hid_init);
+module_init(hid_init);
+module_exit(hid_exit);

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)