Skip to content

Commit b233b28

Browse files
Adrian McMenaminpmundt
authored andcommitted
sh: maple: Support block reads and writes.
This patch updates the maple bus to support asynchronous block reads and writes as well as generally improving the quality of the code and supporting concurrency (all needed to support the Dreamcast visual memory unit - a driver will also be posted for that). Changes in the bus driver necessitate some changes in the two maple bus input drivers that are currently in mainline. As well as supporting block reads and writes this code clean up removes some poor handling of locks, uses an atomic status variable to serialise access to devices and more robusly handles the general performance problems of the bus. Signed-off-by: Adrian McMenamin <adrian@mcmen.demon.co.uk> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
1 parent 41480ae commit b233b28

4 files changed

Lines changed: 300 additions & 266 deletions

File tree

‎drivers/input/joystick/maplecontrol.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Based on drivers/usb/iforce.c
44
*
55
* Copyright Yaegashi Takeshi, 2001
6-
* Adrian McMenamin, 2008
6+
* Adrian McMenamin, 2008 - 2009
77
*/
88

99
#include <linux/kernel.h>
@@ -29,7 +29,7 @@ static void dc_pad_callback(struct mapleq *mq)
2929
struct maple_device *mapledev = mq->dev;
3030
struct dc_pad *pad = maple_get_drvdata(mapledev);
3131
struct input_dev *dev = pad->dev;
32-
unsigned char *res = mq->recvbuf;
32+
unsigned char *res = mq->recvbuf->buf;
3333

3434
buttons = ~le16_to_cpup((__le16 *)(res + 8));
3535

‎drivers/input/keyboard/maple_keyb.c‎

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*
22
* SEGA Dreamcast keyboard driver
33
* Based on drivers/usb/usbkbd.c
4-
* Copyright YAEGASHI Takeshi, 2001
5-
* Porting to 2.6 Copyright Adrian McMenamin, 2007, 2008
4+
* Copyright (c) YAEGASHI Takeshi, 2001
5+
* Porting to 2.6 Copyright (c) Adrian McMenamin, 2007 - 2009
66
*
77
* This program is free software; you can redistribute it and/or modify
88
* it under the terms of the GNU General Public License as published by
@@ -33,7 +33,7 @@ static DEFINE_MUTEX(maple_keyb_mutex);
3333

3434
#define NR_SCANCODES 256
3535

36-
MODULE_AUTHOR("YAEGASHI Takeshi, Adrian McMenamin");
36+
MODULE_AUTHOR("Adrian McMenamin <adrian@mcmen.demon.co.uk");
3737
MODULE_DESCRIPTION("SEGA Dreamcast keyboard driver");
3838
MODULE_LICENSE("GPL");
3939

@@ -115,7 +115,7 @@ static void dc_scan_kbd(struct dc_kbd *kbd)
115115
input_event(dev, EV_MSC, MSC_SCAN, code);
116116
input_report_key(dev, keycode, 0);
117117
} else
118-
printk(KERN_DEBUG "maple_keyb: "
118+
dev_dbg(&dev->dev,
119119
"Unknown key (scancode %#x) released.",
120120
code);
121121
}
@@ -127,7 +127,7 @@ static void dc_scan_kbd(struct dc_kbd *kbd)
127127
input_event(dev, EV_MSC, MSC_SCAN, code);
128128
input_report_key(dev, keycode, 1);
129129
} else
130-
printk(KERN_DEBUG "maple_keyb: "
130+
dev_dbg(&dev->dev,
131131
"Unknown key (scancode %#x) pressed.",
132132
code);
133133
}
@@ -140,7 +140,7 @@ static void dc_kbd_callback(struct mapleq *mq)
140140
{
141141
struct maple_device *mapledev = mq->dev;
142142
struct dc_kbd *kbd = maple_get_drvdata(mapledev);
143-
unsigned long *buf = mq->recvbuf;
143+
unsigned long *buf = (unsigned long *)(mq->recvbuf->buf);
144144

145145
/*
146146
* We should always get the lock because the only
@@ -159,22 +159,27 @@ static void dc_kbd_callback(struct mapleq *mq)
159159

160160
static int probe_maple_kbd(struct device *dev)
161161
{
162-
struct maple_device *mdev = to_maple_dev(dev);
163-
struct maple_driver *mdrv = to_maple_driver(dev->driver);
162+
struct maple_device *mdev;
163+
struct maple_driver *mdrv;
164164
int i, error;
165165
struct dc_kbd *kbd;
166166
struct input_dev *idev;
167167

168-
if (!(mdev->function & MAPLE_FUNC_KEYBOARD))
169-
return -EINVAL;
168+
mdev = to_maple_dev(dev);
169+
mdrv = to_maple_driver(dev->driver);
170170

171171
kbd = kzalloc(sizeof(struct dc_kbd), GFP_KERNEL);
172-
idev = input_allocate_device();
173-
if (!kbd || !idev) {
172+
if (!kbd) {
174173
error = -ENOMEM;
175174
goto fail;
176175
}
177176

177+
idev = input_allocate_device();
178+
if (!idev) {
179+
error = -ENOMEM;
180+
goto fail_idev_alloc;
181+
}
182+
178183
kbd->dev = idev;
179184
memcpy(kbd->keycode, dc_kbd_keycode, sizeof(kbd->keycode));
180185

@@ -195,7 +200,7 @@ static int probe_maple_kbd(struct device *dev)
195200

196201
error = input_register_device(idev);
197202
if (error)
198-
goto fail;
203+
goto fail_register;
199204

200205
/* Maple polling is locked to VBLANK - which may be just 50/s */
201206
maple_getcond_callback(mdev, dc_kbd_callback, HZ/50,
@@ -207,10 +212,12 @@ static int probe_maple_kbd(struct device *dev)
207212

208213
return error;
209214

210-
fail:
215+
fail_register:
216+
maple_set_drvdata(mdev, NULL);
211217
input_free_device(idev);
218+
fail_idev_alloc:
212219
kfree(kbd);
213-
maple_set_drvdata(mdev, NULL);
220+
fail:
214221
return error;
215222
}
216223

0 commit comments

Comments
 (0)