diff options
author | Dmitry Torokhov <dtor_core@ameritech.net> | 2005-09-15 03:01:52 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2005-10-28 12:52:53 -0400 |
commit | 17dd3f0f7aa729a042af5d3318ff9b3e7781b45b (patch) | |
tree | 261580f0229e6365f044cd26925dfb2735e0754d /drivers/input/joystick/grip.c | |
parent | 0259567ad60df13a55583b84d2cddb5526705907 (diff) |
[PATCH] drivers/input/joystick: convert to dynamic input_dev allocation
Input: convert drivers/input/joystick to dynamic input_dev allocation
This is required for input_dev sysfs integration
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/input/joystick/grip.c')
-rw-r--r-- | drivers/input/joystick/grip.c | 77 |
1 files changed, 43 insertions, 34 deletions
diff --git a/drivers/input/joystick/grip.c b/drivers/input/joystick/grip.c index 9d3f910dd568..e206bb56e53c 100644 --- a/drivers/input/joystick/grip.c +++ b/drivers/input/joystick/grip.c | |||
@@ -55,7 +55,7 @@ MODULE_LICENSE("GPL"); | |||
55 | 55 | ||
56 | struct grip { | 56 | struct grip { |
57 | struct gameport *gameport; | 57 | struct gameport *gameport; |
58 | struct input_dev dev[2]; | 58 | struct input_dev *dev[2]; |
59 | unsigned char mode[2]; | 59 | unsigned char mode[2]; |
60 | int reads; | 60 | int reads; |
61 | int bads; | 61 | int bads; |
@@ -190,7 +190,7 @@ static void grip_poll(struct gameport *gameport) | |||
190 | 190 | ||
191 | for (i = 0; i < 2; i++) { | 191 | for (i = 0; i < 2; i++) { |
192 | 192 | ||
193 | dev = grip->dev + i; | 193 | dev = grip->dev[i]; |
194 | grip->reads++; | 194 | grip->reads++; |
195 | 195 | ||
196 | switch (grip->mode[i]) { | 196 | switch (grip->mode[i]) { |
@@ -297,6 +297,7 @@ static void grip_close(struct input_dev *dev) | |||
297 | static int grip_connect(struct gameport *gameport, struct gameport_driver *drv) | 297 | static int grip_connect(struct gameport *gameport, struct gameport_driver *drv) |
298 | { | 298 | { |
299 | struct grip *grip; | 299 | struct grip *grip; |
300 | struct input_dev *input_dev; | ||
300 | unsigned int data[GRIP_LENGTH_XT]; | 301 | unsigned int data[GRIP_LENGTH_XT]; |
301 | int i, j, t; | 302 | int i, j, t; |
302 | int err; | 303 | int err; |
@@ -339,48 +340,56 @@ static int grip_connect(struct gameport *gameport, struct gameport_driver *drv) | |||
339 | gameport_set_poll_handler(gameport, grip_poll); | 340 | gameport_set_poll_handler(gameport, grip_poll); |
340 | gameport_set_poll_interval(gameport, 20); | 341 | gameport_set_poll_interval(gameport, 20); |
341 | 342 | ||
342 | for (i = 0; i < 2; i++) | 343 | for (i = 0; i < 2; i++) { |
343 | if (grip->mode[i]) { | 344 | if (!grip->mode[i]) |
345 | continue; | ||
344 | 346 | ||
345 | sprintf(grip->phys[i], "%s/input%d", gameport->phys, i); | 347 | grip->dev[i] = input_dev = input_allocate_device(); |
348 | if (!input_dev) { | ||
349 | err = -ENOMEM; | ||
350 | goto fail3; | ||
351 | } | ||
346 | 352 | ||
347 | grip->dev[i].private = grip; | 353 | sprintf(grip->phys[i], "%s/input%d", gameport->phys, i); |
348 | 354 | ||
349 | grip->dev[i].open = grip_open; | 355 | input_dev->name = grip_name[grip->mode[i]]; |
350 | grip->dev[i].close = grip_close; | 356 | input_dev->phys = grip->phys[i]; |
357 | input_dev->id.bustype = BUS_GAMEPORT; | ||
358 | input_dev->id.vendor = GAMEPORT_ID_VENDOR_GRAVIS; | ||
359 | input_dev->id.product = grip->mode[i]; | ||
360 | input_dev->id.version = 0x0100; | ||
361 | input_dev->cdev.dev = &gameport->dev; | ||
362 | input_dev->private = grip; | ||
351 | 363 | ||
352 | grip->dev[i].name = grip_name[grip->mode[i]]; | 364 | input_dev->open = grip_open; |
353 | grip->dev[i].phys = grip->phys[i]; | 365 | 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 | 366 | ||
359 | grip->dev[i].evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 367 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); |
360 | 368 | ||
361 | for (j = 0; (t = grip_abs[grip->mode[i]][j]) >= 0; j++) { | 369 | for (j = 0; (t = grip_abs[grip->mode[i]][j]) >= 0; j++) { |
362 | 370 | ||
363 | if (j < grip_cen[grip->mode[i]]) | 371 | if (j < grip_cen[grip->mode[i]]) |
364 | input_set_abs_params(&grip->dev[i], t, 14, 52, 1, 2); | 372 | input_set_abs_params(input_dev, t, 14, 52, 1, 2); |
365 | else if (j < grip_anx[grip->mode[i]]) | 373 | else if (j < grip_anx[grip->mode[i]]) |
366 | input_set_abs_params(&grip->dev[i], t, 3, 57, 1, 0); | 374 | input_set_abs_params(input_dev, t, 3, 57, 1, 0); |
367 | else | 375 | else |
368 | input_set_abs_params(&grip->dev[i], t, -1, 1, 0, 0); | 376 | input_set_abs_params(input_dev, t, -1, 1, 0, 0); |
369 | } | 377 | } |
370 | 378 | ||
371 | for (j = 0; (t = grip_btn[grip->mode[i]][j]) >= 0; j++) | 379 | for (j = 0; (t = grip_btn[grip->mode[i]][j]) >= 0; j++) |
372 | if (t > 0) | 380 | if (t > 0) |
373 | set_bit(t, grip->dev[i].keybit); | 381 | set_bit(t, input_dev->keybit); |
374 | 382 | ||
375 | printk(KERN_INFO "input: %s on %s\n", | 383 | input_register_device(grip->dev[i]); |
376 | grip_name[grip->mode[i]], gameport->phys); | 384 | } |
377 | input_register_device(grip->dev + i); | ||
378 | } | ||
379 | 385 | ||
380 | return 0; | 386 | return 0; |
381 | 387 | ||
382 | fail2: gameport_close(gameport); | 388 | fail3: for (i = 0; i < 2; i++) |
383 | fail1: gameport_set_drvdata(gameport, NULL); | 389 | if (grip->dev[i]) |
390 | input_unregister_device(grip->dev[i]); | ||
391 | fail2: gameport_close(gameport); | ||
392 | fail1: gameport_set_drvdata(gameport, NULL); | ||
384 | kfree(grip); | 393 | kfree(grip); |
385 | return err; | 394 | return err; |
386 | } | 395 | } |
@@ -391,8 +400,8 @@ static void grip_disconnect(struct gameport *gameport) | |||
391 | int i; | 400 | int i; |
392 | 401 | ||
393 | for (i = 0; i < 2; i++) | 402 | for (i = 0; i < 2; i++) |
394 | if (grip->mode[i]) | 403 | if (grip->dev[i]) |
395 | input_unregister_device(grip->dev + i); | 404 | input_unregister_device(grip->dev[i]); |
396 | gameport_close(gameport); | 405 | gameport_close(gameport); |
397 | gameport_set_drvdata(gameport, NULL); | 406 | gameport_set_drvdata(gameport, NULL); |
398 | kfree(grip); | 407 | kfree(grip); |