aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/joystick/interact.c
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2005-10-30 21:37:12 -0500
committerPaul Mackerras <paulus@samba.org>2005-10-30 21:37:12 -0500
commit23fd07750a789a66fe88cf173d52a18f1a387da4 (patch)
tree06fdd6df35fdb835abdaa9b754d62f6b84b97250 /drivers/input/joystick/interact.c
parentbd787d438a59266af3c9f6351644c85ef1dd21fe (diff)
parented28f96ac1960f30f818374d65be71d2fdf811b0 (diff)
Merge ../linux-2.6 by hand
Diffstat (limited to 'drivers/input/joystick/interact.c')
-rw-r--r--drivers/input/joystick/interact.c54
1 files changed, 30 insertions, 24 deletions
diff --git a/drivers/input/joystick/interact.c b/drivers/input/joystick/interact.c
index d7b3472bd686..c4ed01758226 100644
--- a/drivers/input/joystick/interact.c
+++ b/drivers/input/joystick/interact.c
@@ -38,6 +38,7 @@
38#include <linux/init.h> 38#include <linux/init.h>
39#include <linux/gameport.h> 39#include <linux/gameport.h>
40#include <linux/input.h> 40#include <linux/input.h>
41#include <linux/jiffies.h>
41 42
42#define DRIVER_DESC "InterAct digital joystick driver" 43#define DRIVER_DESC "InterAct digital joystick driver"
43 44
@@ -54,7 +55,7 @@ MODULE_LICENSE("GPL");
54 55
55struct interact { 56struct interact {
56 struct gameport *gameport; 57 struct gameport *gameport;
57 struct input_dev dev; 58 struct input_dev *dev;
58 int bads; 59 int bads;
59 int reads; 60 int reads;
60 unsigned char type; 61 unsigned char type;
@@ -130,7 +131,7 @@ static int interact_read_packet(struct gameport *gameport, int length, u32 *data
130static void interact_poll(struct gameport *gameport) 131static void interact_poll(struct gameport *gameport)
131{ 132{
132 struct interact *interact = gameport_get_drvdata(gameport); 133 struct interact *interact = gameport_get_drvdata(gameport);
133 struct input_dev *dev = &interact->dev; 134 struct input_dev *dev = interact->dev;
134 u32 data[3]; 135 u32 data[3];
135 int i; 136 int i;
136 137
@@ -208,14 +209,20 @@ static void interact_close(struct input_dev *dev)
208static int interact_connect(struct gameport *gameport, struct gameport_driver *drv) 209static int interact_connect(struct gameport *gameport, struct gameport_driver *drv)
209{ 210{
210 struct interact *interact; 211 struct interact *interact;
212 struct input_dev *input_dev;
211 __u32 data[3]; 213 __u32 data[3];
212 int i, t; 214 int i, t;
213 int err; 215 int err;
214 216
215 if (!(interact = kzalloc(sizeof(struct interact), GFP_KERNEL))) 217 interact = kzalloc(sizeof(struct interact), GFP_KERNEL);
216 return -ENOMEM; 218 input_dev = input_allocate_device();
219 if (!interact || !input_dev) {
220 err = -ENOMEM;
221 goto fail1;
222 }
217 223
218 interact->gameport = gameport; 224 interact->gameport = gameport;
225 interact->dev = input_dev;
219 226
220 gameport_set_drvdata(gameport, interact); 227 gameport_set_drvdata(gameport, interact);
221 228
@@ -249,41 +256,40 @@ static int interact_connect(struct gameport *gameport, struct gameport_driver *d
249 interact->type = i; 256 interact->type = i;
250 interact->length = interact_type[i].length; 257 interact->length = interact_type[i].length;
251 258
252 interact->dev.private = interact; 259 input_dev->name = interact_type[i].name;
253 interact->dev.open = interact_open; 260 input_dev->phys = interact->phys;
254 interact->dev.close = interact_close; 261 input_dev->id.bustype = BUS_GAMEPORT;
262 input_dev->id.vendor = GAMEPORT_ID_VENDOR_INTERACT;
263 input_dev->id.product = interact_type[i].id;
264 input_dev->id.version = 0x0100;
265 input_dev->private = interact;
255 266
256 interact->dev.name = interact_type[i].name; 267 input_dev->open = interact_open;
257 interact->dev.phys = interact->phys; 268 input_dev->close = interact_close;
258 interact->dev.id.bustype = BUS_GAMEPORT;
259 interact->dev.id.vendor = GAMEPORT_ID_VENDOR_INTERACT;
260 interact->dev.id.product = interact_type[i].id;
261 interact->dev.id.version = 0x0100;
262 269
263 interact->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 270 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
264 271
265 for (i = 0; (t = interact_type[interact->type].abs[i]) >= 0; i++) { 272 for (i = 0; (t = interact_type[interact->type].abs[i]) >= 0; i++) {
266 set_bit(t, interact->dev.absbit); 273 set_bit(t, input_dev->absbit);
267 if (i < interact_type[interact->type].b8) { 274 if (i < interact_type[interact->type].b8) {
268 interact->dev.absmin[t] = 0; 275 input_dev->absmin[t] = 0;
269 interact->dev.absmax[t] = 255; 276 input_dev->absmax[t] = 255;
270 } else { 277 } else {
271 interact->dev.absmin[t] = -1; 278 input_dev->absmin[t] = -1;
272 interact->dev.absmax[t] = 1; 279 input_dev->absmax[t] = 1;
273 } 280 }
274 } 281 }
275 282
276 for (i = 0; (t = interact_type[interact->type].btn[i]) >= 0; i++) 283 for (i = 0; (t = interact_type[interact->type].btn[i]) >= 0; i++)
277 set_bit(t, interact->dev.keybit); 284 set_bit(t, input_dev->keybit);
278 285
279 input_register_device(&interact->dev); 286 input_register_device(interact->dev);
280 printk(KERN_INFO "input: %s on %s\n",
281 interact_type[interact->type].name, gameport->phys);
282 287
283 return 0; 288 return 0;
284 289
285fail2: gameport_close(gameport); 290fail2: gameport_close(gameport);
286fail1: gameport_set_drvdata(gameport, NULL); 291fail1: gameport_set_drvdata(gameport, NULL);
292 input_free_device(input_dev);
287 kfree(interact); 293 kfree(interact);
288 return err; 294 return err;
289} 295}
@@ -292,7 +298,7 @@ static void interact_disconnect(struct gameport *gameport)
292{ 298{
293 struct interact *interact = gameport_get_drvdata(gameport); 299 struct interact *interact = gameport_get_drvdata(gameport);
294 300
295 input_unregister_device(&interact->dev); 301 input_unregister_device(interact->dev);
296 gameport_close(gameport); 302 gameport_close(gameport);
297 gameport_set_drvdata(gameport, NULL); 303 gameport_set_drvdata(gameport, NULL);
298 kfree(interact); 304 kfree(interact);