diff options
author | Adrian McMenamin <adrian@newgolddream.dyndns.info> | 2009-04-25 16:43:18 -0400 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2009-04-26 20:22:31 -0400 |
commit | 6b3480855aad6e22ca90981a4c7893a7f41ffb47 (patch) | |
tree | b75bc44c021af5c520b32dce738acff51347850e /drivers/input | |
parent | 40f4a6d522e68a0203ebefb57f3cbdac4a622169 (diff) |
maple: input: fix up maple mouse driver
The maple mouse driver currently in mainline is broken:
bash-3.1# modprobe maplemouse
[ 56.886378] input: Dreamcast Mouse as /devices/virtual/input/input3
[ 56.918379] Unable to handle kernel NULL pointer dereference at virtual address 00000004
[ 56.930543] pc = c003304e
[ 56.934973] *pde = 00000000
[ 56.944948] Oops: 0000 [#1]
[ 56.947867] Modules linked in: maplemouse(+)
[ 56.952353]
[ 56.953921] Pid : 1157, Comm: \0x09\0x09modprobe
[ 56.958021] CPU : 0 \0x09\0x09Not tainted (2.6.30-rc2-00130-g3e98f9f #1)
[ 56.958052]
[ 56.966567] PC is at dc_mouse_open+0xe/0x40 [maplemouse]
[ 56.972125] PR is at input_open_device+0x8a/0xc0
[ 56.976944] PC : c003304e SP : 8c88bdcc SR : 40008100 TEA : c0033834
[ 56.983854] R0 : 000006c4 R1 : 00000000 R2 : 40008101 R3 : 00000000
[ 56.990744] R4 : 8c8db800 R5 : c0033080 R6 : 00000005 R7 : 00000200
[ 56.997635] R8 : 8c8db800 R9 : 8c8dbe3c R10 : 00000000 R11 : 8c98881c
[ 57.004525] R12 : 8c8dbe64 R13 : 8ca50140 R14 : 8c88bdd4
[ 57.010063] MACH: 00000497 MACL: 00000348 GBR : 29674440 PR : 8c1b4d0a
[ 57.016939]
...
Here is a fix for this, keeping an open and close, so reducing
the load on the system when the mouse is not in use, and also properly
referencing the maple device buffer following the recent update.
Signed-off-by: Adrian McMenamin <adrian@mcmen.demon.co.uk>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'drivers/input')
-rw-r--r-- | drivers/input/mouse/maplemouse.c | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/drivers/input/mouse/maplemouse.c b/drivers/input/mouse/maplemouse.c index d196abfb68bc..5f278176eb9b 100644 --- a/drivers/input/mouse/maplemouse.c +++ b/drivers/input/mouse/maplemouse.c | |||
@@ -2,8 +2,8 @@ | |||
2 | * SEGA Dreamcast mouse driver | 2 | * SEGA Dreamcast mouse driver |
3 | * Based on drivers/usb/usbmouse.c | 3 | * Based on drivers/usb/usbmouse.c |
4 | * | 4 | * |
5 | * Copyright Yaegashi Takeshi, 2001 | 5 | * Copyright (c) Yaegashi Takeshi, 2001 |
6 | * Adrian McMenamin, 2008 | 6 | * Copyright (c) Adrian McMenamin, 2008 - 2009 |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include <linux/kernel.h> | 9 | #include <linux/kernel.h> |
@@ -29,7 +29,7 @@ static void dc_mouse_callback(struct mapleq *mq) | |||
29 | struct maple_device *mapledev = mq->dev; | 29 | struct maple_device *mapledev = mq->dev; |
30 | struct dc_mouse *mse = maple_get_drvdata(mapledev); | 30 | struct dc_mouse *mse = maple_get_drvdata(mapledev); |
31 | struct input_dev *dev = mse->dev; | 31 | struct input_dev *dev = mse->dev; |
32 | unsigned char *res = mq->recvbuf; | 32 | unsigned char *res = mq->recvbuf->buf; |
33 | 33 | ||
34 | buttons = ~res[8]; | 34 | buttons = ~res[8]; |
35 | relx = *(unsigned short *)(res + 12) - 512; | 35 | relx = *(unsigned short *)(res + 12) - 512; |
@@ -47,7 +47,7 @@ static void dc_mouse_callback(struct mapleq *mq) | |||
47 | 47 | ||
48 | static int dc_mouse_open(struct input_dev *dev) | 48 | static int dc_mouse_open(struct input_dev *dev) |
49 | { | 49 | { |
50 | struct dc_mouse *mse = dev->dev.platform_data; | 50 | struct dc_mouse *mse = maple_get_drvdata(to_maple_dev(&dev->dev)); |
51 | 51 | ||
52 | maple_getcond_callback(mse->mdev, dc_mouse_callback, HZ/50, | 52 | maple_getcond_callback(mse->mdev, dc_mouse_callback, HZ/50, |
53 | MAPLE_FUNC_MOUSE); | 53 | MAPLE_FUNC_MOUSE); |
@@ -57,29 +57,33 @@ static int dc_mouse_open(struct input_dev *dev) | |||
57 | 57 | ||
58 | static void dc_mouse_close(struct input_dev *dev) | 58 | static void dc_mouse_close(struct input_dev *dev) |
59 | { | 59 | { |
60 | struct dc_mouse *mse = dev->dev.platform_data; | 60 | struct dc_mouse *mse = maple_get_drvdata(to_maple_dev(&dev->dev)); |
61 | 61 | ||
62 | maple_getcond_callback(mse->mdev, dc_mouse_callback, 0, | 62 | maple_getcond_callback(mse->mdev, dc_mouse_callback, 0, |
63 | MAPLE_FUNC_MOUSE); | 63 | MAPLE_FUNC_MOUSE); |
64 | } | 64 | } |
65 | 65 | ||
66 | 66 | /* allow the mouse to be used */ | |
67 | static int __devinit probe_maple_mouse(struct device *dev) | 67 | static int __devinit probe_maple_mouse(struct device *dev) |
68 | { | 68 | { |
69 | struct maple_device *mdev = to_maple_dev(dev); | 69 | struct maple_device *mdev = to_maple_dev(dev); |
70 | struct maple_driver *mdrv = to_maple_driver(dev->driver); | 70 | struct maple_driver *mdrv = to_maple_driver(dev->driver); |
71 | int error; | ||
71 | struct input_dev *input_dev; | 72 | struct input_dev *input_dev; |
72 | struct dc_mouse *mse; | 73 | struct dc_mouse *mse; |
73 | int error; | ||
74 | 74 | ||
75 | mse = kzalloc(sizeof(struct dc_mouse), GFP_KERNEL); | 75 | mse = kzalloc(sizeof(struct dc_mouse), GFP_KERNEL); |
76 | input_dev = input_allocate_device(); | 76 | if (!mse) { |
77 | |||
78 | if (!mse || !input_dev) { | ||
79 | error = -ENOMEM; | 77 | error = -ENOMEM; |
80 | goto fail; | 78 | goto fail; |
81 | } | 79 | } |
82 | 80 | ||
81 | input_dev = input_allocate_device(); | ||
82 | if (!input_dev) { | ||
83 | error = -ENOMEM; | ||
84 | goto fail_nomem; | ||
85 | } | ||
86 | |||
83 | mse->dev = input_dev; | 87 | mse->dev = input_dev; |
84 | mse->mdev = mdev; | 88 | mse->mdev = mdev; |
85 | 89 | ||
@@ -89,25 +93,24 @@ static int __devinit probe_maple_mouse(struct device *dev) | |||
89 | BIT_MASK(BTN_RIGHT) | BIT_MASK(BTN_MIDDLE); | 93 | BIT_MASK(BTN_RIGHT) | BIT_MASK(BTN_MIDDLE); |
90 | input_dev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y) | | 94 | input_dev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y) | |
91 | BIT_MASK(REL_WHEEL); | 95 | BIT_MASK(REL_WHEEL); |
92 | input_dev->name = mdev->product_name; | ||
93 | input_dev->id.bustype = BUS_HOST; | ||
94 | input_dev->open = dc_mouse_open; | 96 | input_dev->open = dc_mouse_open; |
95 | input_dev->close = dc_mouse_close; | 97 | input_dev->close = dc_mouse_close; |
98 | input_dev->name = mdev->product_name; | ||
99 | input_dev->id.bustype = BUS_HOST; | ||
100 | error = input_register_device(input_dev); | ||
101 | if (error) | ||
102 | goto fail_register; | ||
96 | 103 | ||
97 | mdev->driver = mdrv; | 104 | mdev->driver = mdrv; |
98 | maple_set_drvdata(mdev, mse); | 105 | maple_set_drvdata(mdev, mse); |
99 | 106 | ||
100 | error = input_register_device(input_dev); | 107 | return error; |
101 | if (error) | ||
102 | goto fail; | ||
103 | |||
104 | return 0; | ||
105 | 108 | ||
106 | fail: | 109 | fail_register: |
107 | input_free_device(input_dev); | 110 | input_free_device(input_dev); |
108 | maple_set_drvdata(mdev, NULL); | 111 | fail_nomem: |
109 | kfree(mse); | 112 | kfree(mse); |
110 | mdev->driver = NULL; | 113 | fail: |
111 | return error; | 114 | return error; |
112 | } | 115 | } |
113 | 116 | ||