aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/joystick/grip.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/grip.c
parentbd787d438a59266af3c9f6351644c85ef1dd21fe (diff)
parented28f96ac1960f30f818374d65be71d2fdf811b0 (diff)
Merge ../linux-2.6 by hand
Diffstat (limited to 'drivers/input/joystick/grip.c')
-rw-r--r--drivers/input/joystick/grip.c78
1 files changed, 44 insertions, 34 deletions
diff --git a/drivers/input/joystick/grip.c b/drivers/input/joystick/grip.c
index 9d3f910dd568..a936e7aedb10 100644
--- a/drivers/input/joystick/grip.c
+++ b/drivers/input/joystick/grip.c
@@ -34,6 +34,7 @@
34#include <linux/slab.h> 34#include <linux/slab.h>
35#include <linux/gameport.h> 35#include <linux/gameport.h>
36#include <linux/input.h> 36#include <linux/input.h>
37#include <linux/jiffies.h>
37 38
38#define DRIVER_DESC "Gravis GrIP protocol joystick driver" 39#define DRIVER_DESC "Gravis GrIP protocol joystick driver"
39 40
@@ -55,7 +56,7 @@ MODULE_LICENSE("GPL");
55 56
56struct grip { 57struct grip {
57 struct gameport *gameport; 58 struct gameport *gameport;
58 struct input_dev dev[2]; 59 struct input_dev *dev[2];
59 unsigned char mode[2]; 60 unsigned char mode[2];
60 int reads; 61 int reads;
61 int bads; 62 int bads;
@@ -190,7 +191,7 @@ static void grip_poll(struct gameport *gameport)
190 191
191 for (i = 0; i < 2; i++) { 192 for (i = 0; i < 2; i++) {
192 193
193 dev = grip->dev + i; 194 dev = grip->dev[i];
194 grip->reads++; 195 grip->reads++;
195 196
196 switch (grip->mode[i]) { 197 switch (grip->mode[i]) {
@@ -297,6 +298,7 @@ static void grip_close(struct input_dev *dev)
297static int grip_connect(struct gameport *gameport, struct gameport_driver *drv) 298static int grip_connect(struct gameport *gameport, struct gameport_driver *drv)
298{ 299{
299 struct grip *grip; 300 struct grip *grip;
301 struct input_dev *input_dev;
300 unsigned int data[GRIP_LENGTH_XT]; 302 unsigned int data[GRIP_LENGTH_XT];
301 int i, j, t; 303 int i, j, t;
302 int err; 304 int err;
@@ -339,48 +341,56 @@ static int grip_connect(struct gameport *gameport, struct gameport_driver *drv)
339 gameport_set_poll_handler(gameport, grip_poll); 341 gameport_set_poll_handler(gameport, grip_poll);
340 gameport_set_poll_interval(gameport, 20); 342 gameport_set_poll_interval(gameport, 20);
341 343
342 for (i = 0; i < 2; i++) 344 for (i = 0; i < 2; i++) {
343 if (grip->mode[i]) { 345 if (!grip->mode[i])
346 continue;
344 347
345 sprintf(grip->phys[i], "%s/input%d", gameport->phys, i); 348 grip->dev[i] = input_dev = input_allocate_device();
349 if (!input_dev) {
350 err = -ENOMEM;
351 goto fail3;
352 }
346 353
347 grip->dev[i].private = grip; 354 sprintf(grip->phys[i], "%s/input%d", gameport->phys, i);
348 355
349 grip->dev[i].open = grip_open; 356 input_dev->name = grip_name[grip->mode[i]];
350 grip->dev[i].close = grip_close; 357 input_dev->phys = grip->phys[i];
358 input_dev->id.bustype = BUS_GAMEPORT;
359 input_dev->id.vendor = GAMEPORT_ID_VENDOR_GRAVIS;
360 input_dev->id.product = grip->mode[i];
361 input_dev->id.version = 0x0100;
362 input_dev->cdev.dev = &gameport->dev;
363 input_dev->private = grip;
351 364
352 grip->dev[i].name = grip_name[grip->mode[i]]; 365 input_dev->open = grip_open;
353 grip->dev[i].phys = grip->phys[i]; 366 input_dev->close = grip_close;
354 grip->dev[i].id.bustype = BUS_GAMEPORT;
355 grip->dev[i].id.vendor = GAMEPORT_ID_VENDOR_GRAVIS;
356 grip->dev[i].id.product = grip->mode[i];
357 grip->dev[i].id.version = 0x0100;
358 367
359 grip->dev[i].evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 368 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
360 369
361 for (j = 0; (t = grip_abs[grip->mode[i]][j]) >= 0; j++) { 370 for (j = 0; (t = grip_abs[grip->mode[i]][j]) >= 0; j++) {
362 371
363 if (j < grip_cen[grip->mode[i]]) 372 if (j < grip_cen[grip->mode[i]])
364 input_set_abs_params(&grip->dev[i], t, 14, 52, 1, 2); 373 input_set_abs_params(input_dev, t, 14, 52, 1, 2);
365 else if (j < grip_anx[grip->mode[i]]) 374 else if (j < grip_anx[grip->mode[i]])
366 input_set_abs_params(&grip->dev[i], t, 3, 57, 1, 0); 375 input_set_abs_params(input_dev, t, 3, 57, 1, 0);
367 else 376 else
368 input_set_abs_params(&grip->dev[i], t, -1, 1, 0, 0); 377 input_set_abs_params(input_dev, t, -1, 1, 0, 0);
369 } 378 }
370 379
371 for (j = 0; (t = grip_btn[grip->mode[i]][j]) >= 0; j++) 380 for (j = 0; (t = grip_btn[grip->mode[i]][j]) >= 0; j++)
372 if (t > 0) 381 if (t > 0)
373 set_bit(t, grip->dev[i].keybit); 382 set_bit(t, input_dev->keybit);
374 383
375 printk(KERN_INFO "input: %s on %s\n", 384 input_register_device(grip->dev[i]);
376 grip_name[grip->mode[i]], gameport->phys); 385 }
377 input_register_device(grip->dev + i);
378 }
379 386
380 return 0; 387 return 0;
381 388
382fail2: gameport_close(gameport); 389 fail3: for (i = 0; i < 2; i++)
383fail1: gameport_set_drvdata(gameport, NULL); 390 if (grip->dev[i])
391 input_unregister_device(grip->dev[i]);
392 fail2: gameport_close(gameport);
393 fail1: gameport_set_drvdata(gameport, NULL);
384 kfree(grip); 394 kfree(grip);
385 return err; 395 return err;
386} 396}
@@ -391,8 +401,8 @@ static void grip_disconnect(struct gameport *gameport)
391 int i; 401 int i;
392 402
393 for (i = 0; i < 2; i++) 403 for (i = 0; i < 2; i++)
394 if (grip->mode[i]) 404 if (grip->dev[i])
395 input_unregister_device(grip->dev + i); 405 input_unregister_device(grip->dev[i]);
396 gameport_close(gameport); 406 gameport_close(gameport);
397 gameport_set_drvdata(gameport, NULL); 407 gameport_set_drvdata(gameport, NULL);
398 kfree(grip); 408 kfree(grip);