aboutsummaryrefslogtreecommitdiffstats
path: root/bsp/mti-malta64/mousedev-mousedev-patch-for-qemumips.patch
blob: f887ee97e6b216dd4e1b98b48cf277c4e8f5fa6b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
From 7b532ebf41b9009bcff5e19a2a234e4234428fc9 Mon Sep 17 00:00:00 2001
From: Richard Griffiths <richard.griffiths@windriver.com>
Date: Tue, 21 Sep 2010 13:22:55 -0700
Subject: [PATCH] mousedev: mousedev patch for qemumips

The consumers of the mousedev data in MIPS uperspace assume
that the data is little endian. So if we are running on a
big endian CPU we force the output data to be little endian.

Note: this may be reverted if/when the consuming devices
add options, or options are found that can byte swap the
data in userspace. This is simply a commit of convienience
to demonstrate an issue.

Signed-off-by: Richard Griffiths <richard.griffiths@windriver.com>
Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
---
 drivers/input/mousedev.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
index b604564dec5c..8311853200e8 100644
--- a/drivers/input/mousedev.c
+++ b/drivers/input/mousedev.c
@@ -26,6 +26,7 @@
 #include <linux/device.h>
 #include <linux/cdev.h>
 #include <linux/kernel.h>
+#include <asm/byteorder.h>
 
 MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
 MODULE_DESCRIPTION("Mouse (ExplorerPS/2) device interfaces");
@@ -714,7 +715,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
 {
 	struct mousedev_client *client = file->private_data;
 	struct mousedev *mousedev = client->mousedev;
-	signed char data[sizeof(client->ps2)];
+	u16 data[sizeof(client->ps2)];
 	int retval = 0;
 
 	if (!client->ready && !client->buffer && mousedev->exist &&
@@ -742,6 +743,11 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
 	memcpy(data, client->ps2 + client->bufsiz - client->buffer, count);
 	client->buffer -= count;
 
+#ifdef CONFIG_CPU_BIG_ENDIAN
+	/* Force mouse data LE in userspace as consumers
+	   of the data expect it in this format */
+	cpu_to_le16p((__u16 *)data);
+#endif
 	spin_unlock_irq(&client->packet_lock);
 
 	if (copy_to_user(buffer, data, count))
-- 
2.5.0